{"id":16916870,"url":"https://github.com/bibo-joshi/ptbstats","last_synced_at":"2025-04-11T16:24:43.240Z","repository":{"id":38316988,"uuid":"494819872","full_name":"Bibo-Joshi/ptbstats","owner":"Bibo-Joshi","description":"A simple statistics plugin for Telegram bots build with the python-telegram-bot library","archived":false,"fork":false,"pushed_at":"2024-08-30T05:23:59.000Z","size":18910,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T16:24:35.030Z","etag":null,"topics":["python-telegram-bot","statistics","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bibo-Joshi.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-21T15:21:24.000Z","updated_at":"2024-08-30T05:23:30.000Z","dependencies_parsed_at":"2023-02-06T05:30:52.612Z","dependency_job_id":"51540ebb-6e6e-4f81-b8df-9a5b2a0346a3","html_url":"https://github.com/Bibo-Joshi/ptbstats","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bibo-Joshi%2Fptbstats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bibo-Joshi%2Fptbstats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bibo-Joshi%2Fptbstats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bibo-Joshi%2Fptbstats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bibo-Joshi","download_url":"https://codeload.github.com/Bibo-Joshi/ptbstats/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248439027,"owners_count":21103523,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python-telegram-bot","statistics","telegram-bot"],"created_at":"2024-10-13T19:30:38.353Z","updated_at":"2025-04-11T16:24:43.218Z","avatar_url":"https://github.com/Bibo-Joshi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"PTB Stats\n=========\n\n.. image:: https://img.shields.io/badge/python-3.7+-blue\n   :target: https://www.python.org/doc/versions/\n   :alt: Supported Python versions\n\n.. image:: https://img.shields.io/badge/python--telegram--bot-20.0-blue\n   :target: https://python-telegram-bot.org/\n   :alt: Supported PTB versions\n\n.. image:: https://img.shields.io/badge/documentation-is%20here-orange\n   :target: https://Bibo-Joshi.github.io/ptbstats/\n   :alt: Documentation\n\n.. image:: https://results.pre-commit.ci/badge/github/Bibo-Joshi/ptbstats/master.svg\n   :target: https://results.pre-commit.ci/latest/github/Bibo-Joshi/ptbstats/master\n   :alt: pre-commit.ci status\n\nA simple statistics plugin for Telegram bots build with the python-telegram-bot library\n\nInstallation\n------------\n\nInstall via::\n\n    pip install git+https://github.com/Bibo-Joshi/ptbstats.git@v2.2\n\n``ptbstats`` does not have a proper package (yet), because the author is too lazy for unittests and stuff …\n\nQuickstart\n----------\n\nHere is an example setup using the very basic `SimpleStats \u003chttps://Bibo-Joshi.github.io/ptbstats/ptbstats.simplestats.html\u003e`_ statistics instance delivered along with ``ptbstats``.\n\n.. code-block:: python\n\n    from telegram.ext import Application, PicklePersistence, filters, MessageHandler\n    from ptbstats import set_application, register_stats, SimpleStats\n\n\n    def main():\n        \"\"\"Start the bot.\"\"\"\n\n        async def post_init(app):\n            # Set up stats\n            set_application(application)\n            # Count number of text messages\n            register_stats(\n                SimpleStats(\n                    \"text\", lambda u: bool(u.message and (filters.TEXT \u0026 ~filters.COMMAND).check_update(u))\n                )\n            )\n            # Count number of inline queries\n            register_stats(SimpleStats(\"ilq\", lambda u: bool(u.inline_query and u.inline_query.query)))\n\n        persistence = PicklePersistence(\"persistence.pickle\")\n        application = Application.builder().token(\"TOKEN\").persistence(persistence).post_init(post_init).build()\n\n        # Register handlers\n        async def callback(u, c):\n            await u.message.reply_text(u.message.text)\n\n        application.add_handler(MessageHandler(filters.TEXT, callback))\n\n        # Start the Bot\n        application.run_polling()\n\n\nif __name__ == \"__main__\":\n    main()\n\nAdvanced Usage\n--------------\n\nTo create your own, customized statistics, subclass `BaseStats \u003chttps://Bibo-Joshi.github.io/ptbstats/ptbstats.basestats.html\u003e`_.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbibo-joshi%2Fptbstats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbibo-joshi%2Fptbstats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbibo-joshi%2Fptbstats/lists"}