智能对话机器人程序包
smartbotsol的Python项目详细描述
pythonsmartbots
智能对话机器人程序包
- 自由软件:麻省理工学院许可证
- 文档:https://smartbotsol.readthedocs.io。
开始
描述您的状态
创建server.py
fromtelegram.extimportUpdaterfromsmartbotsolimportStateMachinefromsmartbotsol.telegramimportFsmTelegramHandlerimportlogginglogging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',level=logging.DEBUG)log=logging.getLogger(__name__)fromstatesimportBootStrapStatehandler=FsmTelegramHandler(StateMachine(BootStrapState(),filters=[]))defcreate_bot():token=os.environ.get('TELEGRAM_TOKEN')port=int(os.environ.get('PORT','5000'))updater=Updater(token)updater.dispatcher.add_handler(handler)returnupdaterdefstart_polling_bot():bot=create_bot()bot.start_polling(read_latency=50.0)returnbotif__name__=='__main__':start_polling_bot()
对于异步运行,传递async=true
handler=FsmTelegramHandler(StateMachine(BootStrapState(),filters=[]),async=True)
学分
这个包是用Cookiecutter和audreyr/cookiecutter-pypackage项目模板创建的。
历史记录
1.0.0(2017-11-02)
- pypi上的第一个版本。
1.0.1(2017-11-05)
- 修复带有回复标记的错误