-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTwitterBot.py
174 lines (167 loc) · 3.9 KB
/
TwitterBot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/env python
import tweepy
#from tkinter import *
import os
from os import environ
# consumer_key = 'consumer key'
# consumer_secret = 'consumer secrets'
# access_token = 'access token'
# access_token_secret = 'access token secret'
consumer_key = environ['consumer_key']
consumer_secret = environ['consumer_secret']
access_token = environ['access_token']
access_token_secret = environ['access_token_secret']
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
user = api.me()
print(user.name)
print(user.location)
for follower in tweepy.Cursor(api.followers).items():
follower.follow()
print("Followed everyone that is following " + user.name)
# root = Tk()
#
# label1 = Label( root, text="Search")
# E1 = Entry(root, bd =5)
#
# label2 = Label( root, text="Number of Tweets")
# E2 = Entry(root, bd =5)
#
# label3 = Label( root, text="Response")
# E3 = Entry(root, bd =5)
#
# label4 = Label( root, text="Reply?")
# E4 = Entry(root, bd =5)
#
# label5 = Label( root, text="Retweet?")
# E5 = Entry(root, bd =5)
#
# label6 = Label( root, text="Favorite?")
# E6 = Entry(root, bd =5)
#
# label7 = Label( root, text="Follow?")
# E7 = Entry(root, bd =5)
#
# def getE1():
# return E1.get()
#
# def getE2():
# return E2.get()
#
# def getE3():
# return E3.get()
#
#
# def getE4():
# return E4.get()
#
# def getE5():
# return E5.get()
#
# def getE6():
# return E6.get()
#
# def getE7():
# return E7.get()
#
#
# def mainFunction():
# getE1()
# search = getE1()
#
# getE2()
# numberOfTweets = getE2()
# numberOfTweets = int(numberOfTweets)
#
# getE3()
# phrase = getE3()
#
# getE4()
# reply = getE4()
#
# getE5()
# retweet = getE5()
#
# getE6()
# favorite = getE6()
#
# getE7()
# follow = getE7()
#
# if reply == "yes":
# for tweet in tweepy.Cursor(api.search, search).items(numberOfTweets):
# try:
# #Reply
# print('\nTweet by: @' + tweet.user.screen_name)
# print('ID: @' + str(tweet.user.id))
# tweetId = tweet.user.id
# username = tweet.user.screen_name
# api.update_status("@" + username + " " + phrase, in_reply_to_status_id = tweetId)
# print ("Replied with " + phrase)
#
# except tweepy.TweepError as e:
# print(e.reason)
#
# except StopIteration:
# break
#
#
# if retweet == "yes":
# for tweet in tweepy.Cursor(api.search, search).items(numberOfTweets):
# try:
# #Retweet
# tweet.retweet()
# print('Retweeted the tweet')
#
# except tweepy.TweepError as e:
# print(e.reason)
#
# except StopIteration:
# break
#
# if favorite == "yes":
# for tweet in tweepy.Cursor(api.search, search).items(numberOfTweets):
# try:
# #Favorite
# tweet.favorite()
# print('Favorited the tweet')
#
# except tweepy.TweepError as e:
# print(e.reason)
#
# except StopIteration:
# break
#
# if follow == "yes":
# for tweet in tweepy.Cursor(api.search, search).items(numberOfTweets):
# try:
# #Follow
# tweet.user.follow()
# print('Followed the user')
#
# except tweepy.TweepError as e:
# print(e.reason)
#
# except StopIteration:
# break
#
# submit = Button(root, text ="Submit", command = mainFunction)
#
# label1.pack()
# E1.pack()
# label2.pack()
# E2.pack()
# label3.pack()
# E3.pack()
# label4.pack()
# E4.pack()
# label5.pack()
# E5.pack()
# label6.pack()
# E6.pack()
# label7.pack()
# E7.pack()
# submit.pack(side =BOTTOM)
#
# root.mainloop()