From 7caf67413c5f482a62e6744c2a23c4bad82f1ea7 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Thu, 23 Mar 2017 14:27:38 +0100 Subject: [PATCH] Some fixes. Not working yet, but... --- bottools/methods.py | 4 ++-- telegrambot.py | 1 + twitools/streaming.py | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bottools/methods.py b/bottools/methods.py index 037434b..a6d2f6a 100644 --- a/bottools/methods.py +++ b/bottools/methods.py @@ -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 diff --git a/telegrambot.py b/telegrambot.py index b68c1a6..148d10b 100755 --- a/telegrambot.py +++ b/telegrambot.py @@ -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)) diff --git a/twitools/streaming.py b/twitools/streaming.py index 645ac36..1d01bbe 100644 --- a/twitools/streaming.py +++ b/twitools/streaming.py @@ -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)))