twitools/telegrambot.py
2017-03-23 14:27:38 +01:00

43 lines
3 KiB
Python
Executable file

#!/usr/bin/env python3
import bottools.methods, logging, setuptools, telegram.ext
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger(__name__)
def log(bot, update, error):
logger.warn("Error %s caused by '%s'" % (error, update))
if __name__ == "__main__":
updater = telegram.ext.Updater(token=setuptools.token())
updater.dispatcher.add_handler(telegram.ext.CommandHandler("auth", bottools.methods.auth))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("fish", bottools.methods.fish))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("follow", bottools.methods.follow, pass_args=True))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("help", bottools.methods.start))
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))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("start", bottools.methods.start))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("timeline", bottools.methods.timeline, pass_args=True))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("toggletweet", bottools.methods.toggleTweet))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("tweet", bottools.methods.explicitTweet, pass_args=True))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("unauth", bottools.methods.unauth))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("unfollow", bottools.methods.unfollow, pass_args=True))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("verify", bottools.methods.verify, pass_args=True))
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.text, bottools.methods.tweet))
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.photo, bottools.methods.tweet))
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.sticker, bottools.methods.tweet))
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.video, bottools.methods.tweet))
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.command, bottools.methods.unknown))
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.document, bottools.methods.tweet))
updater.dispatcher.add_error_handler(log)
updater.start_polling()
updater.idle()