32 lines
1.7 KiB
Python
Executable file
32 lines
1.7 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.WARN)
|
|
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())
|
|
|
|
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))
|
|
|
|
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.photo, bottools.methods.captionHelper))
|
|
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.sticker, bottools.methods.captionHelper))
|
|
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.video, bottools.methods.captionHelper))
|
|
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.document, bottools.methods.captionHelper))
|
|
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.location, bottools.methods.storeLocation))
|
|
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.text, bottools.methods.tweet))
|
|
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.command, bottools.methods.unknown))
|
|
|
|
updater.dispatcher.add_handler(telegram.ext.CallbackQueryHandler(bottools.methods.callback))
|
|
|
|
updater.dispatcher.add_error_handler(log)
|
|
|
|
updater.start_polling()
|
|
updater.idle()
|