Some fixes. Not working yet, but...

This commit is contained in:
Klaus-Uwe Mitterer 2017-03-23 14:27:38 +01:00
parent 3af38cc3d9
commit 7caf67413c
3 changed files with 4 additions and 2 deletions

View file

@ -1,4 +1,4 @@
import ast, dbtools, html, io, logging, moviepy.editor, os, PIL.Image, random, setuptools, string, bottools.strings, sys, telegram.ext, telegram, time, twitools, urllib.request, tweepy
import ast, dbtools, html, io, logging, moviepy.editor, os, PIL.Image, random, setuptools, string, bottools.strings, sys, telegram.ext, telegram, time, twitools, twitools.streaming, urllib.request, tweepy
def getTwo(message):
try:
@ -228,7 +228,7 @@ def mentionstream(bot, update):
mentionstreams.pop(update.message.chat_id).disconnect()
else:
two = getTwo(update.message)
stream = tweepy.Stream(auth = two.auth, listener = twitools.streaming.BotStreamListener())
stream = tweepy.Stream(auth = two.auth, listener = twitools.streaming.BotStreamListener(bot, update.message.chat_id))
stream.filter(track=[two.whoami()], async = True)
mentionstreams[update.message.chat_id] = stream

View file

@ -18,6 +18,7 @@ if __name__ == "__main__":
updater.dispatcher.add_handler(telegram.ext.CommandHandler("like", bottools.methods.like, pass_args=True))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("login", bottools.methods.auth))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("logout", bottools.methods.unauth))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("mentionstream", bottools.methods. mentionstream))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("reply", bottools.methods.reply, pass_args=True))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("restart", bottools.methods.restart))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("retweet", bottools.methods.retweet, pass_args=True))

View file

@ -14,6 +14,7 @@ class BotStreamListener(tweepy.StreamListener):
i = 1
db.executeQuery("INSERT INTO timelines VALUES(%i, %i, %i);" % (self.cid, i, status.id))
db.commit()
self.bot.sendMessage(chat_id=self.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)))