Add functions to get own tweets and tweets by other users
This commit is contained in:
parent
9354a33589
commit
09d2d75443
|
@ -178,11 +178,13 @@ def explicitTweet(bot, update, args, reply = None):
|
|||
else:
|
||||
out = mobj
|
||||
|
||||
two.api.update_with_media(filename, update.message.caption, reply, file=out)
|
||||
status = two.api.update_with_media(filename, update.message.caption, reply, file=out)
|
||||
out.close()
|
||||
|
||||
else:
|
||||
two.tweet(' '.join(args), reply)
|
||||
status = two.tweet(' '.join(args), reply)
|
||||
|
||||
bottools.methods.tweetMessage(status, update.message.chat_id, bot)
|
||||
|
||||
except tweepy.error.TweepError as e:
|
||||
bottools.methods.twoExceptions(e, update.message)
|
||||
|
@ -325,6 +327,28 @@ def tweetMessage(status, cid, bot):
|
|||
|
||||
bot.sendMessage(chat_id = cid, text = "Tweet %i:\n%s (@%s) at %s:\n%s" % (i, status.author.name, status.author.screen_name, status.created_at, html.unescape(status.text)), reply_markup=rmu)
|
||||
|
||||
def user(bot, update, args):
|
||||
try:
|
||||
count = int(args[1])
|
||||
except:
|
||||
count = 5
|
||||
|
||||
try:
|
||||
two = bottools.methods.getTwo(update.message)
|
||||
|
||||
for status in two.api.user_timeline(args[0], count = args[1]):
|
||||
tweetMessage(status, update.message.chat_id, bot)
|
||||
|
||||
except tweepy.error.TweepError as e:
|
||||
bottools.methods.twoExceptions(e, update.message)
|
||||
|
||||
def selfTweets(bot, update, args):
|
||||
try:
|
||||
count = int(args[0])
|
||||
except:
|
||||
count = 5
|
||||
|
||||
bottools.methods.user(bot, update, [bottools.methods.getTwo(update.message).whoami(), count])
|
||||
|
||||
def timeline(bot, update, args = [10]):
|
||||
try:
|
||||
|
@ -337,7 +361,6 @@ def timeline(bot, update, args = [10]):
|
|||
db.commit()
|
||||
|
||||
try:
|
||||
i = 1
|
||||
two = bottools.methods.getTwo(update.message)
|
||||
|
||||
for status in two.api.home_timeline(count=count):
|
||||
|
@ -438,6 +461,7 @@ commands = {
|
|||
"reply": reply,
|
||||
"restart": restart,
|
||||
"retweet": retweet,
|
||||
"self": selfTweets,
|
||||
"start": start,
|
||||
"thread": thread,
|
||||
"timeline": timeline,
|
||||
|
@ -446,6 +470,7 @@ commands = {
|
|||
"tweet": explicitTweet,
|
||||
"unauth": unauth,
|
||||
"unfollow": unfollow,
|
||||
"user": user,
|
||||
"verify": verify
|
||||
}
|
||||
|
||||
|
@ -457,9 +482,11 @@ pargs = [
|
|||
quote,
|
||||
reply,
|
||||
retweet,
|
||||
selfTweets,
|
||||
thread,
|
||||
timeline,
|
||||
toggleTweet,
|
||||
user,
|
||||
explicitTweet,
|
||||
unfollow,
|
||||
verify
|
||||
|
|
Loading…
Reference in a new issue