{"id":37078039,"url":"https://github.com/lxxr/bitrixogram","last_synced_at":"2026-01-14T09:03:15.123Z","repository":{"id":244020603,"uuid":"814075425","full_name":"lxxr/bitrixogram","owner":"lxxr","description":"simple async bitrix chat bot framework in \"aiogram\"-style","archived":false,"fork":false,"pushed_at":"2024-10-20T12:56:04.000Z","size":38,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-03T17:13:16.210Z","etag":null,"topics":["asynchronous","bitrix","bitrix24","bot","chatbot","framework","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/bitrixogram/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lxxr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-06-12T09:40:55.000Z","updated_at":"2025-07-25T10:07:20.000Z","dependencies_parsed_at":"2024-06-16T20:32:24.182Z","dependency_job_id":"9469f660-4c64-4b81-92d0-f90bd84b250c","html_url":"https://github.com/lxxr/bitrixogram","commit_stats":null,"previous_names":["lxxr/bitrixogram"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lxxr/bitrixogram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxxr%2Fbitrixogram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxxr%2Fbitrixogram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxxr%2Fbitrixogram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxxr%2Fbitrixogram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lxxr","download_url":"https://codeload.github.com/lxxr/bitrixogram/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxxr%2Fbitrixogram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28414732,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["asynchronous","bitrix","bitrix24","bot","chatbot","framework","python"],"created_at":"2026-01-14T09:03:14.486Z","updated_at":"2026-01-14T09:03:15.114Z","avatar_url":"https://github.com/lxxr.png","language":"Python","readme":"# bitrixogram\nA simple async framework for creating bitrix chat bot in 'aiogram'-like style over Bitrix24 REST API  \n\nSupports Bitrix REST API and webhooks, requires JSON format support from the service  \nShould work on Python 3.x  \n\n## Documentation\nAvailable on https://github.com/lxxr/bitrixogram\n\n## Bitrix24 chatbot api documentation\nhttps://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=93\u0026INDEX=Y\n\nhttps://dev.1c-bitrix.ru/rest_help/index.php\n\n## Dependencies\n- aiohttp\n- asyncio\n- logging\n\n## Install \npip install bitrixogram\n\nor \n\ntar.gz and whl - https://pypi.org/project/bitrixogram/\n\n## Example:\n\n### Project sample structure\n```\n├── bot.py\n├── handlers\n│   ├── any_handler.py\n│   └── message_handler.py\n├── keyboards\n│   └── main_keyboard.py\n├── commands\n│   └── commands.py\n├── config\n│   └── config.py\n```\n\n### Create Bot and add routers for handle messages.\n\n```python\nimport asyncio\nfrom aiohttp import ClientSession\nimport logging\n\nfrom bitrixogram.core import BitrixBot,WebhookListener,Dispatcher\nfrom handlers import messages_handler, any_handler\n\nimport config.settings as config\nimport commands.commands as reg_commands\n\n\nasync def main():\n    logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',\n                         level=logging.INFO)\n    logger = logging.getLogger(__name__)\n    async with ClientSession() as session:\n        bx= BitrixBot(config.bitrix_bot_endpoint,config.bitrix_bot_auth,config.bitrix_bot_id, session) \n        await bx.register_commands(reg_commands.commands, config.ip_whook_endpoint)\n        dp = Dispatcher()\n                \n        dp.add_router(messages_handler.message_router(bx)) \t            #first router\n        #.....................................................              ....\n        dp.add_router(any_handler.any_router(bx))                           #last router \n        \n        webhooks = WebhookListener(host=config.server_whook_addr_ip, port=config.server_whook_port, dispatcher=dp)\n        await webhooks.start()\n        logger.info(\"Bitrix bot webhook listener started\")\n        \n    \n        while True:\n            await asyncio.sleep(3600)\n            logging.info(\"[Bot] Still active...\")\n \nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### Handler example\n\n```python\nfrom bitrixogram.core import Router,FSMContext,MagicFilter,Message,Command,State,StatesGroup\nfrom bitrixogram.attach import ReplyAttachMarkup, ReplyAttachBuilder, GridLayout\nfrom keyboards.main_keyboard import get_main_kb\n\nF = MagicFilter()\nrouter = Router()\n\n\nclass TestState(StatesGroup):\n    test1_state = State()\n    test2_state = State()\n\ndef any_router(bx):\n    @router.message(TestState.test1_state,((F.text()==\"test2\") | (F.text()==\"test3\")))\n    async def handle_message_add_event_test_state1(message: Message, fsm: FSMContext):        \n        chat_id = message.get_chat_id()\n        state= await fsm.get_state()\n        print(f\"get state test1: {state}\")\n        await bx.send_message(\n            chat_id=chat_id,\n            text=\"any router test - state1\"\n        )\n        await fsm.set_state(TestState.test2_state)\n        \n    @router.message(TestState.test2_state,(F.text()))        \n    async def handle_message_add_event_test_state2(message: Message, fsm: FSMContext):        \n        chat_id = message.get_chat_id()\n        state= await fsm.get_state()\n        print(f\"get state test2: {state}\")\n        await bx.send_message(\n            chat_id=chat_id,\n            text=\"any router test - state2\"\n        )        \n        await fsm.clear_state()\n        \n    @router.message(F.text()==\"test\")\n    async def handle_message_add_event_test(message: Message, fsm: FSMContext):        \n        chat_id = message.get_chat_id()\n        await fsm.set_state(TestState.test1_state)\n        state= await fsm.get_state()\n        print(f\"set state: {state}\")\n        await bx.send_message(\n            chat_id=chat_id,\n            text=\"any router test\"\n        \n        )\n        \n    @router.message(F.text())\n    async def handle_message_add_event_other_text(message: Message, fsm: FSMContext):        \n        chat_id = message.get_chat_id()\n        await bx.send_message(chat_id, \"Any text handler\")\n        \n    @router.callback_query(F.command())\n    async def handle_message_add_event_other_command(command:Command, fsm:FSMContext):\n        message_id = command.get_message_id()\n\tbuilder = ReplyAttachBuilder()\n\n\tcolumn_layout = builder.grid_column_layout().add_item(name=\"priority\", value=\"High\").add_item(name=\"Category\", value=\"Task\")\n\tblock_layout = builder.grid_block_layout().add_item(name=\"Description\", value=\"new version of API\", width=250).add_item(name=\"Category\", value=\"Task\", width=100)\n\tline_layout = builder.grid_line_layout().add_item(name=\"Priority\", value=\"High\", color=\"#ff0000\", width=250).add_item(name=\"Category\", value=\"Task\")\n\t#attach example\n\tattach = (builder\n\t    .user(name=\"John Smith\", avatar=\"{image_link}\", link=\"https://api.bitrix24.com/\")\n\t    .link(name=\"Issue #12345: new API \\\"Webhook listener\\\"\", link=\"https://api.bitrix24.com/\", desc=\"release notes\", preview=\"{image_link}\", width=1000, height=638)\n\t    .message(\"API version [B]im 1.1.0[/B]\")\n\t    .delimiter(size=200, color=\"#c6c6c6\")\n\t    .grid(column_layout)\n\t    .grid(block_layout)\n\t    .grid(line_layout)\n\t    .image(link=\"{image_link}\", name=\"img name\", preview=\"{image_preview_link}\", width=1000, height=638)\n\t    .file(link=\"{file_link}\", name=\"image.jpg\", size=1500000)\n\t    .build()).to_dict()\n\n\tkeyboard=get_main_kb()\n        await bx.command_answer(command=command,text=f\"This is command - {command.get_command_name()}\", attach=attach ,keyboard=keyboard)\n\n    return router\n```\n### Keyboard example\n\n```python\nfrom bitrixogram.keyboard import ReplyKeyboardMarkup, ReplyKeyboardBuilder\n\ndef get_main_kb() -\u003e ReplyKeyboardMarkup:\n    kb = ReplyKeyboardBuilder()\n    kb.button(text=\"-\",command=\"dec\")\n    kb.button(text=\"+\",command =\"inc\", bg_color_token=\"alarm\")\n    kb.button(text=\"=\",command = \"sum\", bg_color=\"#336633\", bg_color_token=\"primary\")\n    kb.button(text=\"5\",command = \"info\", bg_color=\"#336633\", bg_color_token=\"secondary\")\n    kb.adjust(4)\n    return kb.as_markup(resize_keyboard=True)\n```\n\n### Commands example\n```python\n\ncommands = [\n              {'COMMAND': 'inc',  'TITLE': '+','PARAMS': 'text' },\n              {'COMMAND': 'dec',  'TITLE': '-','PARAMS': 'text' },\n\t      {'COMMAND': 'info', 'TITLE': '?','PARAMS': 'text' },\n              {'COMMAND': 'sum',  'TITLE': '=','PARAMS': 'text' } ]\n\n```\n\n### Config example\n```python\n#endpoints  \nbitrix_bot_endpoint=\" https://xxx.xxx.xxx/rest/xx/xxx/\" #Webhook for REST API\nip_whook_endpoint='http://WEBHOOK_IP_ADDRESS:WEBHOOK_PORT/' #External webhook server\n\n#webhook server \nserver_whook_addr_ip = \"LOCAL_SERVER_IP\" # Check route from ext interface\nserver_whook_port = LOCAL_SERVER_PORT\n\n#bitrix bot auth and id\nbitrix_bot_auth = \"YOUR_BOT_AUTH_TOKEN\" #Check in bitrix bot settings\nbitrix_bot_id=BITRIX_BOT_CLIENT_ID #Check in bitrix bot settings\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flxxr%2Fbitrixogram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flxxr%2Fbitrixogram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flxxr%2Fbitrixogram/lists"}