add tweet subcommand to twitter, to send tweets.

needs admin, until i figure out if i want more authentication for it
This commit is contained in:
Brian S. Stephan 2010-12-24 13:19:50 -06:00
parent d9b85f4364
commit 0e7e2bf50c
1 changed files with 13 additions and 0 deletions

View File

@ -82,6 +82,19 @@ class Twitter(Module):
return self.reply(connection, replypath, self.tweet_or_retweet_text(tweet=tweet))
except twitter.TwitterError as e:
return self.reply(connection, replypath, 'Couldn\'t obtain status: ' + str(e))
elif whats[1] == 'tweet' and len(whats) >= 3:
if self.authed is False:
return self.reply(connection, replypath, 'You must be authenticated to tweet.')
if admin_unlocked is False:
return self.reply(connection, replypath, 'Only admins can tweet.')
try:
if self.twit.PostUpdates(' '.join(whats[2:]), continuation=u'\u2026') is not None:
return self.reply(connection, replypath, 'Tweet(s) sent.')
else:
return self.reply(connection, replypath, 'Unknown error sending tweet(s).')
except twitter.TwitterError as e:
return self.reply(connection, replypath, 'Couldn\'t tweet: ' + str(e))
elif whats[1] == 'gettoken':
# get request token
resp, content = self.client.request(self.request_token_url, "GET")