def create_dialog(config): add_command(config['command'], config['description']) entry = _fname(config['entrypoint']) __dialogs.append((entry, config['command'])) subscibe(entry, DialogHandler(config['entrypoint']), _run=False) for handler in config['handlers']: subscibe(_fname(handler), DialogHandler(handler), _run=False)
# coding: utf-8 from ybot.events import listener from ybot.modules import add_command from ybot.modules.telegram import bot @listener('ybot.telegram.command') def pong(event_name, value): if value.text and value.text.startswith('/ping'): bot.sendMessage(chat_id=value.chat_id, text='pong') add_command('/ping', 'Checks that bot is still here')