{"id":19816931,"url":"https://github.com/flyingfathead/telegrambot-openai-api","last_synced_at":"2025-05-01T10:33:18.770Z","repository":{"id":214191833,"uuid":"735918946","full_name":"FlyingFathead/TelegramBot-OpenAI-API","owner":"FlyingFathead","description":"A feature-rich Python-based Telegram bot for OpenAI API \u0026 Perplexity API","archived":false,"fork":false,"pushed_at":"2025-04-14T21:12:53.000Z","size":766,"stargazers_count":24,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-22T17:17:53.632Z","etag":null,"topics":["bot","bot-framework","chatbot","gpt-3-5-turbo","gpt-35-turbo","gpt-4","gpt-4-api","gpt-4o-mini","gpt4-api","openai","openai-api","openai-api-chatbot","perplexity-api","telegram","telegram-bot","telegram-bot-api","telegram-bot-app","whisper","whisper-ai","whisper-api"],"latest_commit_sha":null,"homepage":"https://github.com/FlyingFathead/TelegramBot-OpenAI-API","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/FlyingFathead.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}},"created_at":"2023-12-26T13:06:33.000Z","updated_at":"2025-04-14T21:12:56.000Z","dependencies_parsed_at":"2024-02-18T17:40:39.529Z","dependency_job_id":"e329b3a3-c922-4eee-8619-230e1629be7f","html_url":"https://github.com/FlyingFathead/TelegramBot-OpenAI-API","commit_stats":null,"previous_names":["flyingfathead/telegrambot-openai-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlyingFathead%2FTelegramBot-OpenAI-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlyingFathead%2FTelegramBot-OpenAI-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlyingFathead%2FTelegramBot-OpenAI-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlyingFathead%2FTelegramBot-OpenAI-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FlyingFathead","download_url":"https://codeload.github.com/FlyingFathead/TelegramBot-OpenAI-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251860576,"owners_count":21655770,"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":["bot","bot-framework","chatbot","gpt-3-5-turbo","gpt-35-turbo","gpt-4","gpt-4-api","gpt-4o-mini","gpt4-api","openai","openai-api","openai-api-chatbot","perplexity-api","telegram","telegram-bot","telegram-bot-api","telegram-bot-app","whisper","whisper-ai","whisper-api"],"created_at":"2024-11-12T10:11:06.380Z","updated_at":"2025-05-01T10:33:18.758Z","avatar_url":"https://github.com/FlyingFathead.png","language":"Python","readme":"# TelegramBot-OpenAI-API\n\n## 🤖 _Powered by ChatKeke_ 🚀\n\n- **A simple-to-use, quick-to-deploy Python-based Telegram bot for OpenAI API \u0026 Perplexity API**\n- **🎙 Transcribed voice messages over Whisper API**\n  - (auto-transcriptions, translations, and other messages to the bot over TG's voice messages)\n- **☁️ Real-time weather info, weather alerts, and geolocation data via [OpenWeatherMap](https://openweathermap.org/), [WeatherAPI](https://www.weatherapi.com/) and U.S. NWS ([weather.gov](https://weather.gov))**\n- **🗺 Geolocation and map lookups via MapTiler API**\n  - (with weather forecasts around the world in all OpenAI API supported languages)\n- **🧭 Navigation instructions via Openrouteservice API**  \n- **🔔 Timed reminders \u0026 notifications system**\n  - Users can schedule alerts that trigger at specific times. Configurable per-user limits and optional listing of past reminders\n- **📊 Daily token usage tracking \u0026 rate limiting for API usage / cost management**\n- **🔍 Perplexity API models alongside OpenAI models**\n  - Useful for fact-checking and supplementing OpenAI's cutoff dates\n- **📚 Built-in Elasticsearch RAG steps**  \n  - Increase knowledge rate with your own documents\n  - Generate extra insights with the Q\u0026A pair creator\n- **📅 Holiday notifications via Python's `holidays` module**\n  - Localized to supported countries, or add your own special reminders\n- **📈 Fetching stock prices via Alpha Vantage API \u0026 Yahoo! Finance**\n  - Real-time access to financial \u0026 stock market data\n- **📰 RSS feeds from all available sources**\n  - Fetch news and more via RSS\n- **🦆 DuckDuckGo searches as context-augmented function calls**  \n  - New! **Sub-agentic browsing** for enhanced, precise searches!\n- **🌐 Web browsing (page dumps w/ links) as context-augmented function calls**\n  - With optional domain/IP allow/disallow lists for safety\n- **🧮 Calculator function call module for precise calculations**\n  - No more fumbling with AI arithmetic hallucinations!\n- **🔄 Automated \"premium vs. fallback\" model switching**\n  - Seamlessly switches between your “premium” and “mini” model when daily token limits are reached, letting you reduce costs without manually reconfiguring\n- **🐳 Dockerized for safety and ease of deplyoment**\n  - For those who love their Dockers, ready to roll within minutes!\n\n## General minimum requirements:\n\n- **Telegram API bot token** \n  - use the [`@BotFather`](https://t.me/BotFather) bot on Telegram to set up your bot and get a Telegram Bot API token for it\n- **OpenAI API token**\n  - Get one from from: https://platform.openai.com/\n\n---\n\n# 🐧 Installing without Docker on Linux\n\n## Prerequisites\n- Tested \u0026 working on Python `3.10.12` to `3.12.2`\n- Install required Python packages with `pip install -r requirements.txt` (tested and working with the versions listed in [requirements.txt](./requirements.txt)\n- `pydub` usually requires `ffmpeg` to be installed separately. Note that neither `pydub` nor `ffmpeg` are practically not required if you are *not* utilizing the voice message/WhisperAPI functionality, but if you are, suggested install (Debian/Ubuntu Linux): `sudo apt-get install ffmpeg`\n- NOTE: DuckDuckGo searches require `lynx` to be installed on your system; it needs to be run as a subprocess. (Install on Debian/Ubuntu Linux with: `sudo apt-get install lynx`)\n\n1. **Clone the repository with:**\n\n  ```bash\n  git clone https://github.com/FlyingFathead/TelegramBot-OpenAI-API/ \u0026\u0026\n  cd TelegramBot-OpenAI-API/\n  ```\n\n2. **Install the required packages:**\n\n  ```bash\n  pip install -r requirements.txt\n  ```\n\n3. **(Recommended) install the optional packages:**\n\n  - On Ubuntu/Debian tree Linux systems:\n\n  ```bash\n  sudo apt-get install -y ffmpeg lynx\n  ```\n\n3. **Set up your Telegram bot token:**\n\n  - Either set your Telegram Bot API token as `TELEGRAM_BOT_TOKEN` environment variable, or put it into a text file named `bot_token.txt` inside the `config/` directory (= `config/bot_token.txt`)\n\n4. **Set up your OpenAI API token:**\n\n  - Either as `OPENAI_API_KEY` environment variable or put into a text file named `api_token.txt` inside the main program directory\n\n5. **Other modules:**\n\n  - If you wish to use the OpenWeatherMap API and the MapTiler API for i.e. localized weather data retrieval, set the `OPENWEATHERMAP_API_KEY` and the `MAPTILER_API_KEY` environment variables accordingly. You can get the API keys from [OpenWeather](https://openweathermap.org/) and [MapTiler](https://www.maptiler.com/)\n  - Additional weather info (moon phases, weather warnings etc) are fetched from [WeatherAPI](https://weatherapi.com), set the `WEATHERAPI_KEY` environment variable to use it.\n  - If you wish to use the Openrouteservice API for driving instructions, set the `OPENROUTESERVICE_API_KEY` environment variable from [Openrouteservice](https://openrouteservice.org/)\n  - If you wish to use Perplexity API's supplementary fact-checking with their online models, register at [Perplexity.ai](https://perplexity.ai), buy some API credits and set your Perplexity API key to environment variable: `PERPLEXITY_API_KEY`\n\n6. **Further adjustments:**\n\n  - Adjust your configuration and settings by editing `config/config.ini` to your liking\n\n7. **Run:**\n\n- Run the program with: `python src/main.py`\n\n---\n\n# 🐳 **Installing Dockerized**\n\n### **Prerequisites**\n1. **Docker** must be installed on your machine.\n   - If not installed, you can download and install it from [Docker's official site](https://www.docker.com/get-started).\n\n2. **Telegram Bot API Key** and **OpenAI API Key**:\n   - You will need a valid Telegram Bot API key. You can get one by creating a bot with [BotFather](https://core.telegram.org/bots#botfather).\n   - You will also need an OpenAI API key. If you don't have one, you can generate it from the [OpenAI API page](https://beta.openai.com/signup/).\n\n### **Step 1: Clone the Repository**\n\nFirst, clone the repository from GitHub:\n\n  ```bash\n  git clone https://github.com/FlyingFathead/TelegramBot-OpenAI-API.git\n  cd TelegramBot-OpenAI-API\n  ```\n\n### **Step 2: Run the Setup Script**\n\nThis project includes a setup script that will guide you through entering your API keys and generating a `.env` file.\n\nRun the script:\n\n  ```bash\n  ./docker_setup.sh\n  ```\n\nFollow the instructions provided by the script. It will ask for your OpenAI API key and Telegram Bot API key, validate them, and create a `.env` file with your credentials.\n\n### **Step 3: Build the Docker Image**\n\nOnce your `.env` file has been created, you need to build the Docker image.\n\nYou can run the featured `docker_deploy.sh` to build the Docker image:\n\n  ```bash\n  sudo ./docker_deploy.sh\n  ```\n\nOr, you can build it manually:\n\n  ```bash\n  sudo docker build -t telegrambot-openai-api .\n  ```\n\nThis will build the image locally based on the `Dockerfile` in the repository.\n\n### **Step 4: Run the Docker Container**\n\nAfter the image is successfully built, you can start the bot in a Docker container.\n\nRun the container with the following command:\n\n  ```bash\n  sudo docker run --env-file .env --name telegrambot-openai-api -d telegrambot-openai-api\n  ```\n\n- The `-d` flag runs the container in detached mode (in the background).\n- The `--env-file .env` flag injects your API keys into the container.\n\n### **Step 5: Check the Running Container**\n\nYou can check if the container is running by using:\n\n  ```bash\n  sudo docker ps\n  ```\n\nThis will list all running containers. If your bot is running correctly, it should appear in the list.\n\n### **Step 6: Stopping the Container**\n\nIf you need to stop the bot, you can do so by running:\n\n  ```bash\n  sudo docker stop \u003ccontainer_id\u003e\n  ```\n\nReplace `\u003ccontainer_id\u003e` with the actual container ID, which you can obtain from the `docker ps` output.\n\n### **Additional Steps (Optional)**\n\n- **Logs**: If you need to view the bot’s logs to troubleshoot any issues, you can use:\n\n  ```bash\n  sudo docker logs \u003ccontainer_id\u003e\n  ```\n\n- **Restart the Container**: If you stop the container and want to start it again, you can either run the `docker run` command again or restart the existing container with:\n\n  ```bash\n  sudo docker start \u003ccontainer_id\u003e\n  ```\n\n### **Updating the Bot**\n\nIf the repository receives updates and you want to apply them, follow these steps:\n\n1. Pull the latest changes from GitHub:\n   ```bash\n   git pull origin main\n   ```\n\n2. Rebuild the Docker image:\n   ```bash\n   sudo docker build -t telegrambot-openai-api .\n   ```\n\n3. Stop the currently running container:\n   ```bash\n   sudo docker stop \u003ccontainer_id\u003e\n   ```\n\n4. Start a new container using the updated image:\n   ```bash\n   sudo docker run --env-file .env --name telegrambot-openai-api -d telegrambot-openai-api\n   ```\n\nThere is also a `docker_deploy.sh` script included that aims to make the rebuilding and deploying less of a hassle.\n\nYou should now have the TelegramBot-OpenAI-API running in a Docker container, fully connected to both Telegram and OpenAI. Enjoy your bot!\n\nIf you run into any issues, consult the logs or reach out on the repository's [Issues page](https://github.com/FlyingFathead/TelegramBot-OpenAI-API/issues).\n\n---\n\n# Updating your `config.ini`\n\n- Use the `configmerger.py` to update old configuration files into a newer version's `config.ini`. You can do this by saving a copy of your existing config to i.e. a file named `myconfig.txt` and including in it the lines you want to keep for the newer version. \n\n- After that, just run i.e. `python src/configmerger.py myconfig.txt` and all your existing config lines will be migrated to the new one. Works in most cases, but remember to be careful and double-check any migration issues with i.e. `diff`!\n\n**(Example) How to merge and update your existing configuration:**\n\n  ```bash\n  python3 src/configmerger.py myconfig.txt\n  ```\n\n---\n\n# Changelog\n- v0.7615 - Parsing improvements\n  - Improved text formatting \u0026 escaping in complex markdown vs. html cases\n- v0.7614 - Better stock market data fetching from Yahoo Finance \n  - Changes made to `src/api_get_stock_prices_yfinance.py`\n  - =\u003e More accurate ticker symbol searches, fallbacks, multi-day data etc.\n- v0.7613 - Improved timestamps on multiple timezones\n  - Added a separate module to `src/timedate_handler.py` to assist the model\n  - =\u003e Datetime stamps now in separate system messages\n  - =\u003e More TZ-aware dates and times\n- v0.7611 - Parsing hotfix for notifications\n- v0.761 - **Timed notifications / user reminders**\n  - Brand-new feature: users can set timed reminders (alerts) by requesting reminders that the bot stores in an SQLite database. A separate poller picks them up as soon as they are due, and the bot automatically notifies the user on set times.\n  - The custom function calling view action can also list your recently passed or deleted reminders (configurable in `[Reminders]` -\u003e `ShowPastRemindersCount`).\n  - The bot ensures a max limit of pending reminders per user (set with `MaxAlertsPerUser`; set to 0 for unlimited alerts).\n- v0.76 - **Premium mode auto-switching** + usage DB synergy\n  - Added daily usage-based auto-switch logic between “premium” vs. “mini” models (see `[ModelAutoSwitch]` in `config.ini`).\n  - Once you exceed the `PremiumTokenLimit`, the bot seamlessly switches to the fallback model.\n  - If that fallback also goes past `MiniTokenLimit`, the bot can either deny usage or proceed, according to `FallbackLimitAction`.\n  - New param `model_info` for logging function calls, so the “Bot” lines in your chat log can show which model/tier is used (i.e. `model=gpt-4, tier=premium, usage=12345/500000`).\n  - Some small bugfixes for the SQLite usage DB, ensuring we properly update `premium_tokens` or `mini_tokens` after each request based on the `usage` field in OpenAI’s response.\n- 0.75056 - switched to newer Perplexity API models due to new models / old model depreciation\n  - see [Perplexity API guide for supported models](https://docs.perplexity.ai/guides/model-cards)\n- v0.75055 - fixes to the html sanitizer (for Telegram's API; better handling of malformed html), using BeautifulSoup4+lxml for parsing now\n- v0.75054 - small fixes and more error catching in `calc_module.py`\n- v0.75053 - only include eligible territories in U.S. NWS queries\n  - list of queried / eligible territories can be set in `config.ini` under the `NWS` section\n- v0.75052 - include the details from U.S. National Weather Service on alerts\n- v0.75051 - updated `config.ini` for configuring NWS weather forecasts \u0026 alerts\n  - suggested method is to supplement via NWS the additional weather data you need\n  - leaving U.S. NWS's weather alerts on in `config.ini` is highly recommended, even if you have other fetching methods enabled (i.e. OpenWeatherMap), rather be safe than sorry\n- v0.7505 - U.S. NWS (National Weather Service, [weather.gov](https://weather.gov)) added as a weather data source\n  - for additional information; **especially weather alerts**\n  - all data will be combined from OpenWeatherMap and U.S. NWS sources by default\n- v0.7504 - fixed usage logs and charts directory mapping\n- v0.7503 - improved message formatting \u0026 error catching\n- v0.7502 - added `docker_setup.sh` for easier Docker-based deployment\n- v0.7501 - `Dockerfile` and better error catching when receiving `401 Unauthorized`\n- v0.75 **Major refactoring** _(5. Oct 2024)_ 👀💦🌀\n  - entire project has been tidied up and a lot of bugs fixed while at it\n  - `python src/main.py` to start the bot from here on out\n  - massive list of new features, such as:\n    - improved logging\n    - checking for Elasticsearch on startup; multi-step exception catching\n    - Elasticsearch verbosity added for clarity\n    - Elasticsearch can now be configured via `config.ini`\n    - enhanced logging (chat + bot data into separate unified logging)\n    - chatlogs now have a `source` for them whenever called via function calls, so that any external data pulls are now logged more clearly\n    - overall this update makes the bot very much more easily deployable\n- v0.7431 - potential handling of API keys as textfiles moved under `config/` by default\n- v0.743 - config loading changes \u0026 streamlining\n  - tidying up; all configurations are now under `config/`\n  - imported the new logic for bot token reading from my [`whisper-transcriber-telegram-bot`](https://github.com/FlyingFathead/whisper-transcriber-telegram-bot/)\n  - `bot_token.py` changed and updated accordingly\n  - `config_paths.py` now has the project-wide configuration for configuration file paths (`config.ini`, etc...)\n  - move any existing `bot_token.txt` (if used) to `config/`\n  - use `configmerger.py` to update with your custom configs\n  - (more WIP on project restructuring front)\n- v0.742 - Finnish name day RAG step fetch\n- v0.741 - changed to most current Perplexity API model (`llama-3.1-sonar-small-128k-online`) due to deprecations and updates in their models\n- v0.74 - sub-agentic browsing with DuckDuckGo search engine searches is here! \n  - Enabled from `config.ini` via `EnableAgenticBrowsing = True`\n  - It allows the AI helper to follow links for further info and return relevant results\n  - Additional bugfixes to edge cases and their output parsing\n- v0.7373 - small fixes to `api_get_duckduckgo_search.py`; agentic link following WIP\n- v0.7372 - Further parsing logic changes (`markdown_to_html` in `modules.py`)\n- v0.7371 - Improved parsing for markdown/html\n- v0.737 - Changes to Perplexity API inclusion (main model now includes it in the context for better applicability and coherence.)\n- v0.736 - Calculator module `calc_module.py` added for precision in calculation requests. \n- v0.735 - Lynx website browsing with allow/disallow lists for domains allowed/disallowed to be viewed\n- v0.734 - Now hosting over 100 RSS feeds by default (when RAG triggered)\n  - DuckDuckGo searches added as a function call\n- v0.733 - RSS parsing logic streamlined into RAG context\n- v0.7321 - RSS parsing improvements\n- v0.732 - added ElasticSearch RAG function calls to RSS feeds \n  - (for i.e. news sources etc, see `rss_parser.py`)\n- v0.73101 - modularized Perplexity API calls further into a separate handler\n  - (see: `perplexity_handler.py`)\n- v0.731 - added Yahoo! Finance as an API function call for stock price searches (requires the `yfinance` pip package)\n- v0.730 - added Alpha Vantage API function calling to fetch stock prices in real time (requires Alpha Vantage API key)\n- v0.729 - switched to `gpt-4o-mini` in default configurations instead of `gpt-3.5-turbo` (newer, cheaper, better)\n- v0.728 - more edge case handling when fetching multi-API weather data\n- v0.727 - fixed WeatherAPI \u0026 weather fetching edge case API glitches (returning odd values, etc)\n- v0.726 - switched to OpenAI API from `langdetect` when using i.e. Perplexity API for information queries\n  - (`detect_language` function in `api_perplexity_search.py`)\n  - this is for better accuracy in multilingual environments \n  - =\u003e less responses in wrong language when a translation path is needed for the end-user\n  - much more accurate than `langdetect` and can be further leveraged with model selection\n- v0.7251 - small robustness improvements \u0026 fixes to the `api_key.py` module\n- v0.725 - additional Perplexity API call + translation adjustments\n- v0.724 - splitting logic for lengthier Perplexity API responses\n- v0.723 - added jitter, modified retry logic in Perplexity API+translation requests\n- v0.7201 - added Perplexity API model configuration to `config.ini`\n- v0.72 - improved error catching + messaging with Perplexity's API\n- v0.71 - holiday mentions via Python's `holidays` module (can be extended)\n- v0.708 - improved astronomy data combining via WeatherAPI\n- v0.707 - code cleanup + enhancements to Perplexity API handling\n- v0.706 - further weather fetching options; additional country-based data fetching\n- v0.705 - improved weather data combining; small tweaks\n- v0.703 - Language translations and tweaks to WeatherAPI data fetching\n- v0.70 - WeatherAPI support added, to enable, get an API key from weatherapi.com\n- v0.61 - improved handling of weather and time/data data globally\n- v0.60 - url info pre-parsing and additional info fetching for media sources, i.e. with `yt-dlp`\n- v0.59 - custom function calling via Elasticsearch RAG (if enabled)\n- v0.58.4 - more parsing \u0026 formatting fixes\n- v0.58.3 - parsing, formatting \u0026 chunking adjustments\n- v0.58.2 - improved formatting in pplx API calls\n- v0.58.1 - improved markdown parsing in translated Perplexity API calls\n- v0.58 - chunking, parsing and other small fixes\n- v0.57.5 - changes made to Perplexity API handling; new sonar-online models\n- v0.57.1 - improved fallbacks on external API calls like Perplexity API\n- v0.57 - improved error catching \u0026 failsafe fallbacks\n- v0.56 - **Added Elasticsearch support for RAG** - use the `ElasticsearchEnabled` flag in new `config.ini` (set to `True` or `False` to enable or disable)\n- v0.55.4 - API call tracking, extra wait times if needed for external API calls\n- v0.55.3 - reply activity, better chunking logic\n- v0.55 - better reply animation handling\n- v0.52 - more accurate weather data globally via the OpenWeatherMap API \u0026 Maptiler API\n- v0.51 - \"smart\" chunking of external requests to mitigate timeout-related issues\n- v0.50.3 - `langdetect` \u0026 handling fixes\n- v0.50.2 - typing animation on replies, adjustments on processing logic\n- v0.50.1 - `langdetect` on auto-assessing translation requirements\n- v0.50 - Custom function call: Perplexity API fact-checking\n- v0.49.1 - Modularity adjustments\n- v0.48 - Openrouteservice API implementation\n- v0.47 - more token counting \u0026 polling logic fixes\n- v0.46.2 - fixes to token count \u0026 polling logic\n- v0.46 - rewrote the polling logic on daily token count resets\n- v0.45 - `/usagechart` feature added for utilization charts (requires `matplotlib`)\n- v0.44 - API function calling, OpenWeatherMap API weather searches and MapTiler API geolookup\n- v0.43.2 - Fixed a small bug in daily token caps\n- v0.43.1 - Better error catching\n- v0.43 - New admin commands: `/setsystemmessage \u003cmessage\u003e` (valid until bot restart) and `/resetsystemmessage` (reset from `config.ini`)\n- v0.42 - `/reset` command added for bot reset. Set `ResetCommandEnabled` and `AdminOnlyReset` flags in `config.ini` accordingly.\n- v0.41 - modularized text message handling to `text_message_handler.py` and voice message handling to `voice_message_handler.py`\n- v0.40 - session timeout management for compacting chat history (see `config.ini` =\u003e `SessionTimeoutMinutes`, `MaxRetainedMessages`)\n- v0.39.5 - small fixes to OpenAI API payload implementation\n- v0.39.4 - modularized `log_message` \u0026 `rotate_log_file` (log file handling) =\u003e `modules.py`\n- v0.39.3 - modularized `check_global_rate_limit` =\u003e `modules.py`\n- v0.39.2 - text style parsing and WhisperAPI STT pre-processing for the model improved\n- v0.39 - better parsing for codeblocks, html and other markups, modularized more; see `modules.py`\n- v0.38 - keep better record of daily token usage, streamlined (**note**: you will need to clear out your existing `token_usage.json`, the file structure has changed from the previous version)\n- v0.37 - better enforcing of voice msg limits\n- v0.36 - bot command fixes and adjustments\n- v0.35 - modularized bot commands to `bot_commands.py`, fixed `configmerger.py` version\n- v0.34 - added `configmerger.py` to ease updating the bot (merge old configuration flags with new versions)\n- v0.33 - more performance fixes and added+unified async functionalities \n- v0.32 - Daily token counter reset polling \u0026 small bugfixes\n- v0.31 - Context memory token counter adjusted \u0026 fixed to be more precise\n- v0.30 - Whisper API interaction fine adjustments \u0026 small fixes\n- v0.29 - **WhisperAPI transcriptions via voice messages added** \n- WhisperAPI voice messages use the same OpenAI API token as the regular text chat version\n  - see the `config.ini` to turn the option on or off\n  - WIP for additional transcription features\n- v0.28 - customizable `/start` greeting in `config.ini`\n- v0.27 - added `/usage` command to track token usage (for bot owner only, 0 to disable in `config.ini`)\n- v0.26 - added separate chat logging and a global limiter functionality for requests/min (see `config.ini`)\n- v0.25 - daily token usage limit functionality\n  - added a functionality to set daily token usage limits (for bot cost control), see `config.ini`\n  - modularized extra utils (startup msg etc) into `utils.py`\n- v0.24 - bug fixes \u0026 rate limit pre-alpha\n- v0.23 - option to log to file added, see new logging options in `config.ini`\n- v0.22 - `escape_markdown` moved into a separate `.py` file, it was unused anyway\n- v0.21 - Comprehensive Refactoring and Introduction of Object-Oriented Design\n  - Implemented object-oriented programming principles by encapsulating bot functionality within the TelegramBot class.\n  - Refined code structure for improved readability, maintainability, and scalability.\n- v0.20 - modularization, step 1 (key \u0026 token reading: `api_key.py`, `bot_token.py`)\n- v0.19 - timeout error fixes, retry handling; `Timeout` value added to `config.ini`\n- v0.18 - model temperature can now be set in `config.ini`\n- v0.17 - time \u0026 date stamping for better temporal awareness\n- v0.16 - `/help` \u0026 `/about`\n- v0.15 - chat history context memory (trim with MAX_TOKENS)\n- v0.14 - bug fixes\n- v0.13 - parsing/regex for url title+address markdowns\n- v0.12 - more HTML regex parsing from the API markdown\n- v0.11 - switched to HTML parsing\n- v0.10 - MarkdownV2 tryouts (code blocks + bold is _mostly_ working)\n- v0.09 - using MarkdownV2\n- v0.08 - markdown for bot's responses\n- v0.07 - log incoming and outgoing messages\n- v0.06 - API system message fixed\n- v0.05 - retry, max retries, retry delay\n- v0.04 - chat history trimming\n\n# Contribute\n- All contributions appreciated! Feel free to also post any bugs and other issues on the repo's \"Issues\" page.\n- **Don't forget to star it if you like it. :-)**\n\n# About\n- Written by [FlyingFathead](https://github.com/FlyingFathead/)\n- Digital ghost code by ChaosWhisperer\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyingfathead%2Ftelegrambot-openai-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflyingfathead%2Ftelegrambot-openai-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyingfathead%2Ftelegrambot-openai-api/lists"}