-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (26 loc) · 679 Bytes
/
main.py
File metadata and controls
34 lines (26 loc) · 679 Bytes
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
import sys
import random
import datetime
import config
from twython import Twython
import random
twitter = Twython("",
"",
"",
"")
def get_line(file_name):
lines = open(file_name, encoding="utf8").read().splitlines()
myline =random.choice(lines)
return myline
def tweet(sentence):
try:
sys.stdout.write("{} {}\n".format(len(sentence), sentence))
twitter.update_status(status=sentence)
except:
pass
def do_tweet(file_name):
line = get_line(file_name)
tweet(line)
def main(event, context):
file_name = config.config_vars['text_file_path']
do_tweet(file_name)