-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwordBot.py
79 lines (60 loc) · 1.83 KB
/
wordBot.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
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 24 20:01:32 2016
@author: Gareth Miller
"""
import tweepy, time
from twilio.rest import TwilioRestClient
from gettweetsbot import getLastTweet
from random import randint
from credentials import *
# twitter credentials
auth = tweepy.OAuthHandler("EDITED OUT", "EDITED OUT")
auth.set_access_token("EDITED OUT", "EDITED OUT")
api = tweepy.API(auth)
user = ["@ctingcter ", "@runwithalice "]
#twilio variables
myTwilioNumber = "EDITED OUT"
myPhoneNumber = "EDITED OUT"
accountSID = "EDITED OUT"
authToken = "EDITED OUT"
twilioCli = TwilioRestClient(accountSID, authToken)
# read in the text from the file
filename = open('definitions.txt', 'r')
tweettext = filename.readlines()
filename.close()
def textWord():
message = twilioCli.messages.create(body=tweettext[i], from_=myTwilioNumber, to=myPhoneNumber)
def findLocationLastTweet(name):
lastTweet = getLastTweet('WorddefinitionG')
words = lastTweet.split(" ")
i = 0
for line in tweettext:
i += 1
if line == words[1]:
print(i)
return i
i = randint(0, len(tweettext))
if i % 2 != 0:
return i+1
else:
return i
findLocationLastTweet(user)
while True:
i = findLocationLastTweet(user)
for name in user:
if int(i) < len(tweettext):
if name == "@ctingcter ":
textWord()
currentTweet = name + tweettext[i]
print(currentTweet)
api.update_status(currentTweet)
i += 1
if name == "@ctingcter ":
textWord()
currentTweet = name + tweettext[i]
print(currentTweet)
api.update_status(currentTweet)
i -= 1
i += 2
time.sleep(86400) #sleep for 24 hours