{ "info": { "author": "Artem Kustov", "author_email": "artem.kustov@artcom-net.ru", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Twisted", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: BSD :: FreeBSD", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3 :: Only", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: HTTP Servers", "Topic :: Software Development :: Libraries" ], "description": "=======\nPyTGram\n=======\n\nPyTGram is python library to create Telegram Bot based on Twisted.\n\n----------\nInstalling\n----------\n\n~~~~~~~~~~~~~~\nPrerequisites:\n~~~~~~~~~~~~~~\n\n- Python 3.x\n\nYou may need to install additional packages, depending on your operating system:\n\n- Debian/Ubuntu:\n\n.. code::\n\n $ sudo apt-get install python3-dev libffi-dev libssl-dev\n\n- RHEL/CentOS (for python 3.6):\n\n.. code::\n\n $ sudo yum install python36u-devel openssl-devel\n $ sudo yum group install \"Development Tools\"\n\n- FreeBSD:\n\n.. code::\n\n $ pkg install ca_root_nss\n\n- Windows:\n\n - `VS Build Tools `_\n\n - `Windows Extension for Python `_\n\nYou can install pytgram using pip:\n\n.. code::\n\n $ pip install pytgram\n\n-----\nUsage\n-----\n\n~~~~~~~~~~~~~\nWebhook setup\n~~~~~~~~~~~~~\n\n.. code-block:: python\n\n from pytgram import set_webhook\n\n set_webhook('bot_token', 'https://example.com')\n\nIf you use self-signed certificate - the pass path to it:\n\n.. code-block:: python\n\n from pytgram import set_webhook\n\n set_webhook('bot_token', 'https://example.com', 'path/to/cert.pem')\n\n~~~~~~~~~~~~~~~~~~~~~\nCreating a simple bot\n~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n import sys\n\n from twisted.python import log\n from twisted.internet import reactor, ssl\n from twisted.internet.defer import inlineCallbacks\n\n from pytgram import TelegramBot, MessageHandler, web_hook\n\n bot = TelegramBot('bot_token')\n\n\n @MessageHandler(content=['text'])\n @inlineCallbacks\n def text_handler(message):\n result = yield bot.send_message(chat_id=message.chat.id,\n text=message.text[::-1])\n print(result)\n\n\n @MessageHandler(command=['start'])\n @inlineCallbacks\n def start_handler(message):\n result = yield bot.send_message(chat_id=message.chat.id,\n text='Received command \"start\"')\n print(result)\n\n\n def main():\n log.startLogging(sys.stdout)\n ssl_context = ssl.DefaultOpenSSLContextFactory('ssl/secret.key',\n 'ssl/cert.pem')\n # If want use reverse proxy, then replace listenSSL on listenTCP.\n reactor.listenSSL(443, web_hook(bot.token), ssl_context)\n reactor.run()\n\n\n if __name__ == '__main__':\n main()\n\nIf you want to use polling mode, you can do it like that:\n\n.. code-block:: python\n\n import sys\n\n from twisted.python import log\n from twisted.web.server import Site\n from twisted.web.resource import Resource\n from twisted.internet import reactor\n from twisted.internet.defer import inlineCallbacks\n\n from pytgram import TelegramBot, MessageHandler, polling\n\n bot = TelegramBot('bot_token')\n\n\n @MessageHandler(content=['text'])\n @inlineCallbacks\n def text_handler(message):\n result = yield bot.send_message(chat_id=message.chat.id,\n text=message.text[::-1])\n print(result)\n\n\n @MessageHandler(command=['start'])\n @inlineCallbacks\n def start_handler(message):\n result = yield bot.send_message(chat_id=message.chat.id,\n text='Received command \"start\"')\n print(result)\n\n\n def main():\n log.startLogging(sys.stdout)\n reactor.listenTCP(8080, Site(Resource()))\n polling(bot, interval=10)\n reactor.run()\n\n\n if __name__ == '__main__':\n main()", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/artcom-net/pytgram", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pytgram", "package_url": "https://pypi.org/project/pytgram/", "platform": "", "project_url": "https://pypi.org/project/pytgram/", "project_urls": { "Homepage": "https://github.com/artcom-net/pytgram" }, "release_url": "https://pypi.org/project/pytgram/0.0.7/", "requires_dist": null, "requires_python": "", "summary": "Library to create Telegram Bot based on Twisted", "version": "0.0.7" }, "last_serial": 3542766, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "bc48a5196446ff9a2139586b8fe86a8e", "sha256": "686593d8f9b5073ba064a9cf38a12ad42959830f047743e499e7ff40937d66bc" }, "downloads": -1, "filename": "pytgram-0.0.1.tar.gz", "has_sig": false, "md5_digest": "bc48a5196446ff9a2139586b8fe86a8e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23471911, "upload_time": "2017-04-25T07:04:04", "url": "https://files.pythonhosted.org/packages/18/03/ab033f5f359e4c9eebcabe15b21a573225c1cdfcf016122c5b509357f6dd/pytgram-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "358a63d16f9e25cd52126728837ec47c", "sha256": "294104ba47580b03e432c52029ce7dd70c8f77cd47d7b969f7f64949d7c25ead" }, "downloads": -1, "filename": "pytgram-0.0.2.tar.gz", "has_sig": false, "md5_digest": "358a63d16f9e25cd52126728837ec47c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23473679, "upload_time": "2017-07-11T20:24:53", "url": "https://files.pythonhosted.org/packages/cc/49/742c9578baa8be059789983eaf0ed03f4ab3c6fa941ac81dd735c1a0fa37/pytgram-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "911ccd9c7cc3294464bd2164f5304db6", "sha256": "89a88bf0701c5bcc01262eba909510ef9758492d5ac86aafd87c29f98c4e8c4f" }, "downloads": -1, "filename": "pytgram-0.0.3.tar.gz", "has_sig": false, "md5_digest": "911ccd9c7cc3294464bd2164f5304db6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23476467, "upload_time": "2017-07-12T17:57:44", "url": "https://files.pythonhosted.org/packages/7f/34/1f5a305e53927844c729ae7912e7ace9ac4147a6781065a5b0d570a493ac/pytgram-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "7ed458882764b8d0372b135cf5b44429", "sha256": "86020ce7d86b771974a3d835cf9074453ce8bc60c30e68120686c1a99ee15ced" }, "downloads": -1, "filename": "pytgram-0.0.4.tar.gz", "has_sig": false, "md5_digest": "7ed458882764b8d0372b135cf5b44429", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23475426, "upload_time": "2017-07-16T13:47:04", "url": "https://files.pythonhosted.org/packages/b8/41/64585519b6fdf5e1b43b17e8e987c684cac7da85b10e6202f0b395f27e87/pytgram-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "2c36cbbb1b690fbb64956ac5c74304d4", "sha256": "ae447a44b9ee5596d6af942d5765447e1648d8dbffb7e26273a161c169ba9572" }, "downloads": -1, "filename": "pytgram-0.0.5.tar.gz", "has_sig": false, "md5_digest": "2c36cbbb1b690fbb64956ac5c74304d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23476795, "upload_time": "2017-08-05T14:56:13", "url": "https://files.pythonhosted.org/packages/05/09/6fe265c02c01001c48292d4b133af1c310e0fa01982f92f4ab2603b842a2/pytgram-0.0.5.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "ca8d64ffbb856ac4222a0702fed01a67", "sha256": "efdddd5cdeaf2233459a4a4a3e81c6585bb5e3ef15c977a6c52e34068f91655d" }, "downloads": -1, "filename": "pytgram-0.0.7.tar.gz", "has_sig": false, "md5_digest": "ca8d64ffbb856ac4222a0702fed01a67", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23479817, "upload_time": "2018-02-01T20:07:14", "url": "https://files.pythonhosted.org/packages/39/d1/bac1ee8e3c01b133a179752d5a03bacb2697a2f369aec5e79527b1db2cae/pytgram-0.0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ca8d64ffbb856ac4222a0702fed01a67", "sha256": "efdddd5cdeaf2233459a4a4a3e81c6585bb5e3ef15c977a6c52e34068f91655d" }, "downloads": -1, "filename": "pytgram-0.0.7.tar.gz", "has_sig": false, "md5_digest": "ca8d64ffbb856ac4222a0702fed01a67", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23479817, "upload_time": "2018-02-01T20:07:14", "url": "https://files.pythonhosted.org/packages/39/d1/bac1ee8e3c01b133a179752d5a03bacb2697a2f369aec5e79527b1db2cae/pytgram-0.0.7.tar.gz" } ] }