-
Notifications
You must be signed in to change notification settings - Fork 1
/
statusfinder.py
executable file
·63 lines (52 loc) · 1.14 KB
/
statusfinder.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
#! /user/bin/env python
import random
import datetime
def getRandomStatus():
s = readStatusStrings()
return s[random.randint(0,len(s)-1)].rstrip()
def getNextStatus():
s = readStatusStrings()
last = getLastStatus()
# iterate through array to find next tweet
save = False
next = s[0]
if last:
for line in s:
if save == True:
next = line
save = False
elif line == last:
save = True
saveLastStatus(next)
return next
def saveStatus(s):
# save all transmitted tweets, just for sake of recording
f = open("sent.txt", "a")
f.write(s)
f.write(" | ")
f.write(get_timestamp())
f.write("\n")
f.close()
def readStatusStrings():
# array of strings
f = open( "status.txt", "r" )
s = []
for line in f:
s.append( line.rstrip('\n') )
f.close()
return s
def getLastStatus():
# grab the last quote
f = open("laststatus.txt", "r")
last = f.read()
f.close
last = last.rstrip('\n')
return last
def saveLastStatus(s):
# grab the last quote
f = open("laststatus.txt", "w")
f.write(s)
f.close()
# returns our custom timestamp for logging
def get_timestamp():
return datetime.datetime.today().strftime("%B %d %Y %H:%M")