{ "info": { "author": "Arslan 'Ars2014' Sakhapov", "author_email": "ars2014@etlgr.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Natural Language :: English", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", "Operating System :: Unix", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development" ], "description": "# FSMTelegramBotAPI\nA finite-state machine wrapper for [pyTelegramBotAPI](https://github.com/eternnoir/pyTelegramBotAPI)\n\n[![Travis](https://img.shields.io/travis/Ars2014/FSMTelegramBotAPI.svg?style=flat-square)](https://travis-ci.org/Ars2014/FSMTelegramBotAPI) [![PyPI](https://img.shields.io/pypi/v/FSMTelegramBotAPI.svg?style=flat-square)](https://pypi.python.org/pypi/FSMTelegramBotAPI)\n## Install\n1. From PyPI using `pip`:\n ```\n $ pip install -U FSMTelegramBotAPI\n ```\n2. From Github using `git`:\n ```\n $ git clone http://github.com/Ars2014/FSMTelegramBotAPI.git\n $ cd FSMTelegramBotAPI\n $ python setup.py install\n ```\n\n## Instructions\nAll instructions you can find at [original pyTelegramBotAPI](https://github.com/eternnoir/pyTelegramBotAPI). There are only additions and differences.\n\n### Storages\nTo store states and data you can use module `fsm_telebot.storage`:\n```python\nfrom fsm_telebot.storage.base import BaseStorage # Abstract class\nfrom fsm_telebot.storage.base import DisabledStorage # Use it, if you don't want to store anything\nfrom fsm_telebot.storage.memory import MemoryStorage # In-memory storage\nfrom fsm_telebot.storage.rethinkdb import RethinkDBStorage # RethinkDB based storage\n```\nEvery storage must be a subclass of BaseStorage and implement methods: `set_state`, `set_data`, `get_state`, `get_data`, `update_data`, `finish` and `close`:\n```python\nfrom fsm_telebot.storage.memory import MemoryStorage # you can use any storage\n\nstorage = MemoryStorage()\n\nstorage.set_state(1, state='Test') \nstorage.set_data(1, data={2: 3})\n\nstorage.get_state(1) # -> 'Test'\nstorage.get_data(1) # -> {2: 3}\n\nstorage.update_data(1, data={4: 5})\nstorage.get_data(1) # -> {2: 3, 4: 5}\n\nstorage.reset_state(1)\nstorage.get_state(1) # -> None\nstorage.reset_data(1)\nstorage.get_data(1) # -> {}\n\nstorage.finish(1) # Same as reset_state with reset_data\nstorage.get_state(1) # -> None\nstorage.get_data(1) # -> {}\n\nstorage.get_data(1) # -> {}\n\nstorage.close() # -> closes or clears storage.\n```\n\n### Telebot class\nTelebot class got 8 new methods: `set_state`, `set_data`, `get_state`, `get_data`, `reset_state`, `reset_data`, `update_data`, `finish_user`:\n```python\nfrom fsm_telebot.storage.memory import MemoryStorage\nimport fsm_telebot\n\nstorage = MemoryStorage()\nbot = fsm_telebot.Telebot('TOKEN', storage=storage)\n\nbot.set_state(1, state='Test') # storage.set_state\nbot.set_data(1, data={2: 3}) # storage.set_data\n\nbot.get_state(1) # storage.get_state\nbot.get_data(1) # storage.get_data\n\nbot.update_data(1, data={4: 5}) # storage.update_data\nbot.get_data(1) \n\nbot.reset_state(1) # storage.reset_state\nbot.get_state(1) \nbot.reset_data(1) # storage.reset_data\nbot.get_data(1) \n\nbot.finish_user(1) # storage.finish\nbot.get_state(1) \nbot.get_data(1) \n```\n\n### Message handlers\nAll handlers (i.e message, callback, etc.) have new optional parameter `state`, which checks if user got this state.\nHere an example: \n```python\nimport fsm_telebot\nfrom fsm_telebot.storage.memory import MemoryStorage\n\nstorage = MemoryStorage()\nbot = fsm_telebot.Telebot('TOKEN', storage=storage)\n\n@bot.message_handler(commands=['start'])\ndef start(msg):\n bot.set_state('Test', msg.chat.id)\n bot.send_message('Your state is now \"Test\"', msg.chat.id)\n\n@bot.message_handler(state='Test')\ndef test(msg):\n bot.send_message('Your state is still \"Test\"', msg.chat.id)\n```\n\n\n## Bot using this framework\nContact [@Ars2013](https://t.me/Ars2013) to add your bot here.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Ars2014/FSMTelegramBotAPI", "keywords": "telegram bot api tools wrapper", "license": "GNU GPLv2", "maintainer": "", "maintainer_email": "", "name": "FSMTelegramBotAPI", "package_url": "https://pypi.org/project/FSMTelegramBotAPI/", "platform": "", "project_url": "https://pypi.org/project/FSMTelegramBotAPI/", "project_urls": { "Homepage": "https://github.com/Ars2014/FSMTelegramBotAPI" }, "release_url": "https://pypi.org/project/FSMTelegramBotAPI/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "Final-state machine wrapper for pyTelegramBotAPI", "version": "0.0.3" }, "last_serial": 3374013, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "0065cb97b974db74561f9ce02c5ebf17", "sha256": "afda66bc1121bc5858373378abfda3dc4e7a5d76682682ea39b6a61e0b0cc6fe" }, "downloads": -1, "filename": "FSMTelegramBotAPI-0.0.2.tar.gz", "has_sig": false, "md5_digest": "0065cb97b974db74561f9ce02c5ebf17", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13340, "upload_time": "2017-11-05T09:39:29", "url": "https://files.pythonhosted.org/packages/2f/53/0cab5a2fcf4b9b596cf4114548c38f8c64a61de5dcbd89f3bf6a84657958/FSMTelegramBotAPI-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "44dc36d449a565f26052fb17faa595e9", "sha256": "8fc4f421fd67efa96f320b5aa533ca1ebda3eef819e5f7ea54dd0d01f2ddc300" }, "downloads": -1, "filename": "FSMTelegramBotAPI-0.0.3.tar.gz", "has_sig": false, "md5_digest": "44dc36d449a565f26052fb17faa595e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12857, "upload_time": "2017-11-29T12:33:05", "url": "https://files.pythonhosted.org/packages/30/7f/1d6193ca5dd9a16d497d6f449b65600720a36fd666a6dd6b4aceaba0fec5/FSMTelegramBotAPI-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "44dc36d449a565f26052fb17faa595e9", "sha256": "8fc4f421fd67efa96f320b5aa533ca1ebda3eef819e5f7ea54dd0d01f2ddc300" }, "downloads": -1, "filename": "FSMTelegramBotAPI-0.0.3.tar.gz", "has_sig": false, "md5_digest": "44dc36d449a565f26052fb17faa595e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12857, "upload_time": "2017-11-29T12:33:05", "url": "https://files.pythonhosted.org/packages/30/7f/1d6193ca5dd9a16d497d6f449b65600720a36fd666a6dd6b4aceaba0fec5/FSMTelegramBotAPI-0.0.3.tar.gz" } ] }