-
Notifications
You must be signed in to change notification settings - Fork 31
/
w.py
41 lines (29 loc) · 1011 Bytes
/
w.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
#!/usr/bin/env python
# encoding: utf-8
"""
w.py
Created by Hilary Mason on 2010-08-21.
"""
import sys, os
from optparse import OptionParser
import pickle
import tweepy
import settings
from lib import mongodb
class writeTweet(object):
def __init__(self, options, args):
if options.debug:
print options
print args
auth = tweepy.OAuthHandler(settings.CONSUMER_KEY, settings.CONSUMER_SECRET)
auth.set_access_token(settings.ACCESS_KEY, settings.ACCESS_SECRET)
self.api = tweepy.API(auth)
tweet = args[0]
self.post_tweet(tweet)
def post_tweet(self, tweet):
self.api.update_status(tweet)
if __name__ == '__main__':
parser = OptionParser("usage: %prog [options] [tweet]") # no args this time
parser.add_option("-d", "--debug", dest="debug", action="store_true", default=False, help="set debug mode = True")
(options, args) = parser.parse_args()
l = writeTweet(options, args)