{"id":20948951,"url":"https://github.com/crypto-artisan/simple-tg-bot-gpt","last_synced_at":"2025-09-17T23:43:39.782Z","repository":{"id":257787977,"uuid":"754914603","full_name":"crypto-artisan/simple-tg-bot-gpt","owner":"crypto-artisan","description":"telegram bot - chatgpt","archived":false,"fork":false,"pushed_at":"2024-02-09T02:25:30.000Z","size":41,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T05:14:42.630Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crypto-artisan.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-02-09T02:23:45.000Z","updated_at":"2024-09-16T03:32:13.000Z","dependencies_parsed_at":"2024-09-21T00:17:30.466Z","dependency_job_id":null,"html_url":"https://github.com/crypto-artisan/simple-tg-bot-gpt","commit_stats":null,"previous_names":["crypto-artisan/simple-tg-bot-gpt"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/crypto-artisan/simple-tg-bot-gpt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crypto-artisan%2Fsimple-tg-bot-gpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crypto-artisan%2Fsimple-tg-bot-gpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crypto-artisan%2Fsimple-tg-bot-gpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crypto-artisan%2Fsimple-tg-bot-gpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crypto-artisan","download_url":"https://codeload.github.com/crypto-artisan/simple-tg-bot-gpt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crypto-artisan%2Fsimple-tg-bot-gpt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275685229,"owners_count":25509528,"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":[],"created_at":"2024-11-19T00:27:35.081Z","updated_at":"2025-09-17T23:43:39.748Z","avatar_url":"https://github.com/crypto-artisan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChatGPT Telegram Bot\n![python-version](https://img.shields.io/badge/python-3.9-blue.svg)\n[![openai-version](https://img.shields.io/badge/openai-0.27.4-orange.svg)](https://openai.com/)\n[![license](https://img.shields.io/badge/License-GPL%202.0-brightgreen.svg)](LICENSE)\n\nA [Telegram bot](https://core.telegram.org/bots/api) that integrates with OpenAI's _official_ [ChatGPT](https://openai.com/blog/chatgpt/), [DALL·E](https://openai.com/product/dall-e-2) and [Whisper](https://openai.com/research/whisper) APIs to provide answers. Ready to use with minimal configuration required.\n\n## Features\n- [x] Support markdown in answers\n- [x] Reset conversation with the `/reset` command\n- [x] Typing indicator while generating a response\n- [x] Access can be restricted by specifying a list of allowed users\n- [x] Docker and Proxy support\n- [x] (NEW!) Image generation using DALL·E via the `/image` command\n- [x] (NEW!) Transcribe audio and video messages using Whisper (may require [ffmpeg](https://ffmpeg.org))\n- [x] (NEW!) Automatic conversation summary to avoid excessive token usage\n- [x] (NEW!) Track token usage per user - by [@AlexHTW](https://github.com/AlexHTW)\n- [x] (NEW!) Get personal token usage statistics and cost per day/month via the `/stats` command - by [@AlexHTW](https://github.com/AlexHTW)\n- [x] (NEW!) User budgets and guest budgets - by [@AlexHTW](https://github.com/AlexHTW)\n- [x] (NEW!) Stream support\n- [x] (NEW!) GPT-4 support\n  - If you have access to the GPT-4 API, simply change the `OPENAI_MODEL` parameter to `gpt-4`\n- [x] (NEW!) Localized bot language\n  - Available languages :gb: :de: :ru: :tr: :it: :finland: :es: :indonesia: :netherlands: :cn: :taiwan: :vietnam: :iran: :brazil: :ukraine:\n- [x] (NEW!) Improved inline queries support for group and private chats - by [@bugfloyd](https://github.com/bugfloyd)\n  - To use this feature, enable inline queries for your bot in BotFather via the `/setinline` [command](https://core.telegram.org/bots/inline)\n\n\nPRs are always welcome!\n\n## Prerequisites\n- Python 3.9+\n- A [Telegram bot](https://core.telegram.org/bots#6-botfather) and its token (see [tutorial](https://core.telegram.org/bots/tutorial#obtain-your-bot-token))\n- An [OpenAI](https://openai.com) account (see [configuration](#configuration) section)\n\n## Getting started\n\n### Configuration\nCustomize the configuration by copying `.env.example` and renaming it to `.env`, then editing the required parameters as desired:\n\n| Parameter                   | Description                                                                                                                                                                                                                   |\n|-----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `OPENAI_API_KEY`            | Your OpenAI API key, you can get it from [here](https://platform.openai.com/account/api-keys)                                                                                                                                 |\n| `TELEGRAM_BOT_TOKEN`        | Your Telegram bot's token, obtained using [BotFather](http://t.me/botfather) (see [tutorial](https://core.telegram.org/bots/tutorial#obtain-your-bot-token))                                                                  |\n| `ADMIN_USER_IDS`            | Telegram user IDs of admins. These users have access to special admin commands, information and no budget restrictions. Admin IDs don't have to be added to `ALLOWED_TELEGRAM_USER_IDS`. **Note**: by default, no admin (`-`) |\n| `ALLOWED_TELEGRAM_USER_IDS` | A comma-separated list of Telegram user IDs that are allowed to interact with the bot (use [getidsbot](https://t.me/getidsbot) to find your user ID). **Note**: by default, *everyone* is allowed (`*`)                       |\n\n### Optional configuration\nThe following parameters are optional and can be set in the `.env` file:\n\n#### Budgets\n| Parameter             | Description                                                                                                                                                                                                                                                                                                                                                                               | Default value      |\n|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|\n| `BUDGET_PERIOD`       | Determines the time frame all budgets are applied to. Available periods: `daily` *(resets budget every day)*, `monthly` *(resets budgets on the first of each month)*, `all-time` *(never resets budget)*. information                                                                  | `monthly`          |\n| `USER_BUDGETS`        | A comma-separated list of $-amounts per user from list `ALLOWED_TELEGRAM_USER_IDS` to set custom usage limit of OpenAI API costs for each. For `*`- user lists the first `USER_BUDGETS` value is given to every user. **Note**: by default, *no limits* for any user (`*`).               |\n| `GUEST_BUDGET`        | $-amount as usage limit for all guest users. Guest users are users in group chats that are not in the `ALLOWED_TELEGRAM_USER_IDS` list. Value is ignored if no usage limits are set in user budgets (`USER_BUDGETS`=`*`).                                              | `100.0`            |\n| `TOKEN_PRICE`         | $-price per 1000 tokens used to compute cost information in usage statistics. Source: https://openai.com/pricing                                                                                                                                                                                                                                                                          | `0.002`            |\n| `IMAGE_PRICES`        | A comma-separated list with 3 elements of prices for the different image sizes: `256x256`, `512x512` and `1024x1024`. Source: https://openai.com/pricing                                                                                                                                                                                                                                  | `0.016,0.018,0.02` |\n| `TRANSCRIPTION_PRICE` | USD-price for one minute of audio transcription. Source: https://openai.com/pricing                                                                                                                                                                                                                                                                                                       | `0.006`            |\n\n#### Additional optional configuration options\n| Parameter                          | Description                                                                                                                                                                                                                                            | Default value                      |\n|------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|\n| `ENABLE_QUOTING`                   | Whether to enable message quoting in private chats                                                                                                                                                                                                     | `true`                             |\n| `ENABLE_IMAGE_GENERATION`          | Whether to enable image generation via the `/image` command                                                                                                                                                                                            | `true`                             |\n| `ENABLE_TRANSCRIPTION`             | Whether to enable transcriptions of audio and video messages                                                                                                                                                                                           | `true`                             |\n| `PROXY`                            | Proxy to be used for OpenAI and Telegram bot (e.g. `http://localhost:8080`)                                                                                                                                                                            | -                                  |\n| `OPENAI_MODEL`                     | The OpenAI model to use for generating responses                                                                                                                                                                                                       | `gpt-3.5-turbo`                    |\n| `ASSISTANT_PROMPT`                 | A system message that sets the tone and controls the behavior of the assistant                                                                                                                                                                         | `You are a helpful assistant.`     |\n| `SHOW_USAGE`                       | Whether to show OpenAI token usage information after each response                                                                                                                                                                                     | `false`                            |\n| `STREAM`                           | Whether to stream responses. **Note**: incompatible, if enabled, with `N_CHOICES` higher than 1                                                                                                                                                        | `true`                             |\n| `MAX_TOKENS`                       | Upper bound on how many tokens the ChatGPT API will return                                                                                                                                                                                             | `1200` for GPT-3, `2400` for GPT-4 |\n| `MAX_HISTORY_SIZE`                 | Max number of messages to keep in memory, after which the conversation will be summarised to avoid excessive token usage                                                                                                                               | `15`                               |\n| `MAX_CONVERSATION_AGE_MINUTES`     | Maximum number of minutes a conversation should live since the last message, after which the conversation will be reset                                                                                                                                | `180`                              |\n| `VOICE_REPLY_WITH_TRANSCRIPT_ONLY` | Whether to answer to voice messages with the transcript only or with a ChatGPT response of the transcript                                                                                                                                              | `false`                            |\n| `VOICE_REPLY_PROMPTS`              | A semicolon separated list of phrases (i.e. `Hi bot;Hello chat`). If the transcript starts with any of them, it will be treated as a prompt even if `VOICE_REPLY_WITH_TRANSCRIPT_ONLY` is set to `true`                                                | -                                  |\n| `N_CHOICES`                        | Number of answers to generate for each input message. **Note**: setting this to a number higher than 1 will not work properly if `STREAM` is enabled                                                                                                   | `1`                                |\n| `TEMPERATURE`                      | Number between 0 and 2. Higher values will make the output more random                                                                                                                                                                                 | `1.0`                              |\n| `PRESENCE_PENALTY`                 | Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far                                                                                                                                       | `0.0`                              |\n| `FREQUENCY_PENALTY`                | Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far                                                                                                                                  | `0.0`                              |\n| `IMAGE_SIZE`                       | The DALL·E generated image size. Allowed values: `256x256`, `512x512` or `1024x1024`                                                                                                                                                                   | `512x512`                          |\n| `GROUP_TRIGGER_KEYWORD`            | If set, the bot in group chats will only respond to messages that start with this keyword                                                                                                                                                              | -                                  |\n| `IGNORE_GROUP_TRANSCRIPTIONS`      | If set to true, the bot will not process transcriptions in group chats                                                                                                                                                                                 | `true`                             |\n| `BOT_LANGUAGE`                     | Language of general bot messages. Currently available: `en`, `de`, `ru`, `tr`, `it`, `fi`, `es`, `id`, `nl`, `zh-cn`, `zh-tw`, `vi`, `fa`, `pt-br`, `uk`. | `en`                               |\n\nCheck out the [official API reference](https://platform.openai.com/docs/api-reference/chat) for more details.\n\n### Installing\nClone the repository and navigate to the project directory:\n\n#### From Source\n1. Create a virtual environment:\n```shell\npython -m venv venv\n```\n\n2. Activate the virtual environment:\n```shell\n# For Linux or macOS:\nsource venv/bin/activate\n\n# For Windows:\nvenv\\Scripts\\activate\n```\n\n3. Install the dependencies using `requirements.txt` file:\n```shell\npip install -r requirements.txt\n```\n\n4. Use the following command to start the bot:\n```\npython bot/main.py\n```\n\n#### Using Docker Compose\n\nRun the following command to build and run the Docker image:\n```shell\ndocker compose up\n```\n\n```shell\ndocker pull ghcr.io/n3d1117/chatgpt-telegram-bot:latest\ndocker run -it --env-file .env ghcr.io/n3d1117/chatgpt-telegram-bot\n```\n\n#### Docker manual build\n```shell\ndocker build -t chatgpt-telegram-bot .\ndocker run -it --env-file .env chatgpt-telegram-bot\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrypto-artisan%2Fsimple-tg-bot-gpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrypto-artisan%2Fsimple-tg-bot-gpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrypto-artisan%2Fsimple-tg-bot-gpt/lists"}