-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbletchley_bot.py
More file actions
31 lines (24 loc) · 852 Bytes
/
bletchley_bot.py
File metadata and controls
31 lines (24 loc) · 852 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import tweepy
import time
import sys
import os
from random import randint
argfile = str(sys.argv[1])
# enter the corresponding information from your Twitter application:
CONSUMER_KEY = os.environ['CONSUMER_KEY']
CONSUMER_SECRET = os.environ['CONSUMER_SECRET']
ACCESS_KEY = os.environ['ACCESS_KEY']
ACCESS_SECRET = os.environ['ACCESS_SECRET']
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
if __name__ == "__main__":
while True:
with open(argfile) as f:
lines = f.readlines()
rand_line_num = randint(0, len(lines) - 1)
line = lines[rand_line_num]
api.update_status(line)
time.sleep(1800) # Tweet every 30 minutes