2017-02-07 21:36:31 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2017-03-22 11:18:07 +00:00
|
|
|
import bottools.methods, logging, setuptools, telegram.ext
|
2017-02-07 21:36:31 +00:00
|
|
|
|
2017-02-07 22:11:59 +00:00
|
|
|
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
|
2017-02-08 13:58:09 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
def log(bot, update, error):
|
|
|
|
logger.warn("Error %s caused by '%s'" % (error, update))
|
2017-02-07 22:11:59 +00:00
|
|
|
|
2017-03-18 18:23:38 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
updater = telegram.ext.Updater(token=setuptools.token())
|
|
|
|
|
2017-03-24 00:48:40 +00:00
|
|
|
for k, v in bottools.methods.commands.items():
|
|
|
|
updater.dispatcher.add_handler(telegram.ext.CommandHandler(k, v, pass_args = True if v in bottools.methods.pargs else False))
|
|
|
|
|
|
|
|
updater.dispatcher.add_handler(telegram.ext.RegexHandler("^@TweepBot \/.*", bottools.methods.mentionHelper))
|
2017-03-22 00:53:51 +00:00
|
|
|
|
|
|
|
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))
|
2017-02-08 13:58:09 +00:00
|
|
|
|
2017-03-24 00:48:40 +00:00
|
|
|
updater.dispatcher.add_handler(telegram.ext.CallbackQueryHandler(bottools.methods.callback))
|
|
|
|
|
2017-03-18 18:23:38 +00:00
|
|
|
updater.dispatcher.add_error_handler(log)
|
2017-02-07 21:54:22 +00:00
|
|
|
|
2017-03-18 18:23:38 +00:00
|
|
|
updater.start_polling()
|
|
|
|
updater.idle()
|