szastupov / aiotg

Asynchronous Python library for building Telegram bots
MIT License
382 stars 44 forks source link

Added get_handler and handler functions #59

Closed mdbetancourt closed 6 years ago

mdbetancourt commented 6 years ago

package | __init__.py

from . import file # call explicitly others are ignored

package | file.py

from aiotg.utils import handler
def other(): # does not have the decorator then it is ignored
    pass
@handler(r'/game', action='command')
def game(chat, match):
    chat.sent_text('hello world')

main.py

import package
from aiotg import Bot
from aiotg.utils import get_handlers
bot = Bot(api_token=')
for handler in get_handlers(package):
    handler(bot)
bot.run()