-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.py
42 lines (32 loc) · 1008 Bytes
/
bot.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
import ConfigParser
from twitter import Twitter, OAuth
import time
import re
import math
import itertools
import logging
import os
config= ConfigParser.ConfigParser()
config.read('config.cfg')
# Setup Twitter client
oauth = OAuth(config.get('OAuth','accesstoken'),
config.get('OAuth','accesstokenkey'),
config.get('OAuth','consumerkey'),
config.get('OAuth','consumersecret'))
t = Twitter(auth=oauth)
# Setup Logging
logpath = config.get('Logging','logpath')
if not os.path.exists(logpath):
os.makedirs(logpath)
##cruft?
logger = logging.getLogger('log')
#todo: use date/time as the log file name
hdlr = logging.FileHandler(os.path.join(logpath,
"%s.log" % datetime.now().isoformat()))
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
line = "Hello world!"
t.statuses.update(status=line)
logger.debug(line)