{"id":25803540,"url":"https://github.com/lixelv/tgpt","last_synced_at":"2025-09-18T00:53:11.635Z","repository":{"id":167565356,"uuid":"640670011","full_name":"lixelv/tgpt","owner":"lixelv","description":"ChatGPT in telegram","archived":false,"fork":false,"pushed_at":"2023-10-22T20:11:54.000Z","size":8806,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-09T11:35:02.560Z","etag":null,"topics":["aiogram","chatgpt","chatgpt-api","chatgpt-bot","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/lixelv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"zenodo":null}},"created_at":"2023-05-14T20:57:13.000Z","updated_at":"2023-10-30T17:45:55.000Z","dependencies_parsed_at":"2025-07-22T19:19:57.901Z","dependency_job_id":"1283ecb3-5d36-46da-a25a-e64367bf57c1","html_url":"https://github.com/lixelv/tgpt","commit_stats":null,"previous_names":["lixelv/chatgpt_telegrambot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lixelv/tgpt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixelv%2Ftgpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixelv%2Ftgpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixelv%2Ftgpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixelv%2Ftgpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lixelv","download_url":"https://codeload.github.com/lixelv/tgpt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixelv%2Ftgpt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275691195,"owners_count":25510501,"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","status":"online","status_checked_at":"2025-09-17T02:00:09.119Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["aiogram","chatgpt","chatgpt-api","chatgpt-bot","telegram-bot"],"created_at":"2025-02-27T17:56:18.170Z","updated_at":"2025-09-18T00:53:11.612Z","avatar_url":"https://github.com/lixelv.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"parse_weather.py:\n```py\nimport requests\nfrom url import weather\nimport datetime\n\n\ndef get_weather(lat: float, lon: float):\n    try:\n        r = requests.get(f'https://api.openweathermap.org/data/2.5/weather?lat={lat}\u0026lon={lon}\u0026units=metric\u0026lang=RU\u0026appid={weather}')\n        data = r.json()\n        return f'Погода: {data[\"weather\"][0][\"description\"]}\\n' \\\n               f'Сейчас температура: {data[\"main\"][\"temp\"]}C°\\n' \\\n               f'Скорость ветра: {data[\"wind\"][\"speed\"]} м/с\\n' \\\n               f'Влажность: {data[\"main\"][\"humidity\"]}%\\n' \\\n               f'Давление: {data[\"main\"][\"pressure\"]} мм\\n' \\\n               f'Восход: {datetime.datetime.fromtimestamp(data[\"sys\"][\"sunrise\"]).strftime(\"%H:%M:%S\")}\\n' \\\n               f'Закат: {datetime.datetime.fromtimestamp(data[\"sys\"][\"sunset\"]).strftime(\"%H:%M:%S\")}'\n    except Exception as err:\n        return f'Ошибка: {err}'\n\n```\nurl.py:\n```py\nfrom aiogram import Bot, Dispatcher\nfrom aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup\nfrom envparse import env\nfrom asyncio import get_event_loop\nimport random\n# import textwrap\n\nhello = \"\"\"\nПривет я \u003cstrong\u003eChatGPT_3.5\u003c/strong\u003e был разработан @simeonlimon\nпри возникновении проблем обращайся к нему\n\nЧтобы узнать о командах напишите \u003cstrong\u003e/help\u003c/strong\u003e\n        \"\"\"\n\nhelp_ = \"\"\"\nСоздайте новый чат командой \u003cstrong\u003e/new (название чата)\nВарианты: /n /nc /n_c /new /newchat /new_chat \u003c/strong\u003e\n\nПереименуйте активный чат командой \u003cstrong\u003e/rename (новое имя)\nВарианты: /r /rc /r_c /rename /renamechat /rename_chat \u003c/strong\u003e\n\nУзнайте название активного чата командой \u003cstrong\u003e/active\nВарианты: /a /ac /a_c /activechat /active_chat \u003c/strong\u003e \n\nУзнайте историю чата командой \u003cstrong\u003e/history\nВарианты: /h /ch /c_h /history /chat_history \u003c/strong\u003e\n\nВыберете чат с помощью команды \u003cstrong\u003e/select\nВарианты: /s /sc /s_c /select /selectchat /select_chat \u003c/strong\u003e\n\nУдалите активный чат с командой \u003cstrong\u003e/delete\nВарианты: /d /dc /d_c /del /delete /delchat /del_chat /deletechat /delete_chat \u003c/strong\u003e\n\nЧтобы очистить чат введите команду \u003cstrong\u003e/clear\nВарианты: /c /cc /c_c /clear /clearchat /clear_chat \u003c/strong\u003e\n\nЧтобы изменить описание бота напишите \u003cstrong\u003e/description (описание бота)\nВарианты: /cd /c_d /desc /description /chatdescripion /chat_description \u003c/strong\u003e\n\nУзнайте количество потраченных токенов введя \u003cstrong\u003e/token\nВарианты: /t /tok /token \u003c/strong\u003e\n\n\n\nЧтобы использовать ChatGPT 3.5 просто напишите текстовый\nзапрос боту например '\u003cstrong\u003eРасскажи интересный факт о космосе\u003c/strong\u003e'\n        \"\"\"\n\nhistor = [{'role': 'user', 'content': 'What we was talking about? Please answer me on russian language, your answer need to be short'}]\n\nsticker_s = {\n    'Hi': 'CAACAgIAAxkBAAIGsmRk5s_MYBOcUS6ItUTHXF417syzAAJxKwACQo3ASjypfvfFuI3SLwQ',\n    'Loading': 'CAACAgIAAxkBAAIGuGRk5tAuE9s_TyADgQvd2rJioqIVAAItMAAC-cm5SlL0u9sCgWBtLwQ',\n    'Error': 'CAACAgIAAxkBAAIGu2Rk55a7GlI9CY4yHDerKIpwwhWSAAKsKgAClR64SlmLYAGBoLH7LwQ'\n}\n\nphrases = [\n    \"Ничего себе! Я не ожидал такого!\",\n    \"Удивительно, что такое произошло.\",\n    \"Вот это поворот! Я не знал, что это возможно.\",\n    \"Произошла ошибка... Я должен узнать, что произошло.\",\n    \"Я ошеломлен! Я никогда не встречал такую ошибку.\",\n    \"Йой! Я не знал, что это может произойти.\",\n    \"Вот это сюрприз! Я не ожидал таких проблем.\",\n    \"Как же так? Я не могу понять, в чем проблема.\",\n    \"Невероятно! Я должен изучить этот случай детальнее.\",\n    \"О-о-очень необычно! Я никогда не знал, что это возможно.\"\n]\n\nslash = '░░░░▒▒▒▒▒▒▓▓▓▓▓▓▓▓████████████████████████████████████████████████████▓▓▓▓▓▓▓▓▒▒▒▒▒▒░░░░\\n'\n\nsla_d = ''\n\nloop = get_event_loop()\n\nenv.read_envfile('.env')\ndb_config = {\n    \"host\": env('HOST_'),\n    \"user\": env('USER_'),\n    \"password\": env('PASSWORD_'),\n    \"database\": env('DB_')\n}\nop = env('OPENAI').split(',')\nn = random.randint(0, len(op))\nop = [n, tuple(op)]\ntoken = env('TELEGRAM')\nmy_id = env('MYID')\nport = env('PORT')\nlink = env('LINK')\nweather = env('WEATHER')\nbot = Bot(token)\nBot.set_current(bot)\ndp = Dispatcher(bot)\n\n\ndef inline(list_keys: list, list_data: list,\n           width: int = 2):\n    kb: InlineKeyboardMarkup = InlineKeyboardMarkup(row_width=width)\n    buttons: list = []\n    for key, data in zip(list_keys, list_data):\n        buttons.append(InlineKeyboardButton(key, callback_data=data))\n    kb.add(*buttons)\n    return kb\n\n\n# def pprint(str):\n#     str_ = textwrap.wrap(str, width=len(slash))\n#     for line in str_:\n#         print(line)\n#\n#\n# def warp(text):\n#     wrapped_text = textwrap.wrap(text, width=len(slash) - 2)\n#     result = ''\n#     for i in wrapped_text:\n#         result += i + '\\n'\n#     return result[:-2]\n\n```\nwebhook.py:\n```py\nfrom aiogram import Dispatcher, types\nfrom aiohttp import web\nfrom asyncio import ProactorEventLoop, get_event_loop\n\ndef webhook_pooling(\n        dp: Dispatcher = None,\n        port: int | str = None,\n        link: str = None,\n        admin_list: list | int | str = None,\n        loop=None,\n        startup_message: str = 'Бот был запущен! ☠️ ❱ 👾 ❱ 🤖',\n        shutdown_message: str = 'Бот был выключен. 🤖 ❱ 👾 ❱ ☠️'\n):\n\n    if not port:\n        port = 8080\n\n    if not loop:\n        loop = get_event_loop()\n\n\n    # Create a bot instance with the provided token\n    token = dp.bot._token\n\n    # Create an aiohttp web application\n    app = web.Application()\n\n    # Construct the webhook path using the provided link and token\n    webhook_path = f'{link}/{token}'\n    print(webhook_path)\n\n    # Add a POST route to handle incoming webhooks\n    app.router.add_post(f'/{token}', lambda request: handle_webhook(request, token, dp))\n\n    # Register the on_startup and on_shutdown handlers\n    app.on_startup.append(lambda _: on_startup(dp, startup_message, admin_list, webhook_path))\n    app.on_shutdown.append(lambda _: on_shutdown(dp, shutdown_message, admin_list))\n\n    # Run the web application\n    web.run_app(\n        app,\n        host='0.0.0.0',\n        port=port,\n        loop=loop\n    )\n\n\nasync def handle_webhook(request, token, dp):\n    # Extract the token from the URL\n    url = str(request.url)\n    index = url.rfind('/')\n    token_ = url[index + 1:]\n\n    # Verify if the extracted token matches the provided token\n    if token_ == token:\n        # Process the incoming update using the Dispatcher\n        update = types.Update(**await request.json())\n        await dp.process_update(update)\n\n        # Return a success response\n        return web.Response()\n    else:\n        # Return a forbidden response if the tokens do not match\n        return web.Response(status=403)\n\n\nasync def start_shutdown(bot, text: str = None, admin_list: tuple | set | list | str | int = None):\n    # Check if the text and admin_list parameters are provided\n    if text is not None and admin_list is not None:\n        # Check the type of admin_list and send a message accordingly\n        if isinstance(admin_list, (tuple, set, list)):\n            for admin_id in admin_list:\n                await bot.send_message(chat_id=admin_id, text=text)\n        elif isinstance(admin_list, (str, int)):\n            await bot.send_message(chat_id=admin_list, text=text)\n\n\nasync def on_startup(dp, startup_message, admin_list, webhook_path):\n    # Set the webhook path for the bot\n    await dp.bot.set_webhook(webhook_path)\n\n    # Send the startup message to the specified admin_list\n    await start_shutdown(dp.bot, startup_message, admin_list)\n\n\nasync def on_shutdown(dp, shutdown_message, admin_list):\n    # Send the shutdown message to the specified admin_list\n    await start_shutdown(dp.bot, shutdown_message, admin_list)\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flixelv%2Ftgpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flixelv%2Ftgpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flixelv%2Ftgpt/lists"}