Skip to main content

smart conversation bots package

Project description

pythonSmartBots

https://img.shields.io/pypi/v/smartbotsol.svg https://img.shields.io/travis/dqunbp/smartbotsol.svg Documentation Status Updates

smart conversation bots package

Getting started

  1. Describe yor states

  2. Create server.py:

    from telegram.ext import Updater
    from smartbotsol import StateMachine
    from smartbotsol.telegram import FsmTelegramHandler
    
    import logging
    logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.DEBUG)
    log = logging.getLogger(__name__)
    
    from states import BootStrapState
    
    handler = FsmTelegramHandler(
        StateMachine(
            BootStrapState(),
            filters=[]
        )
    )
    
    def create_bot():
        token = os.environ.get('TELEGRAM_TOKEN')
        port = int(os.environ.get('PORT', '5000'))
        updater = Updater(token)
        updater.dispatcher.add_handler(handler)
        return updater
    
    def start_polling_bot():
        bot = create_bot()
        bot.start_polling(read_latency=50.0)
        return bot
    
    if __name__ == '__main__':
        start_polling_bot()

For async runs pass async=True:

handler = FsmTelegramHandler(
    StateMachine(
        BootStrapState(),
        filters=[]
    ),
    async=True
)

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

1.0.0 (2017-11-02)

  • First release on PyPI.

1.0.1 (2017-11-05)

  • Bugfix with reply_markup

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smartbotsol-1.0.1.tar.gz (18.5 kB view hashes)

Uploaded Source

Built Distribution

smartbotsol-1.0.1-py2.py3-none-any.whl (14.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page