Telegram-Bot-GPT
A simple interface for OpenAI GPT-3 and GPT-4 using Telegram bots.
DISCLAIMER
This open-source module is only intended to provide an interface between bot and AI on top of the following services:
- Bot provided for free by Telegram FZ-LLC
- GPT AI capabilities as paid services from OpenAI LP
The creator of this library is not in any way responsible for any misuse of the module, including but not limited to any costs that may occur due to calls to the GPT AI.
Using this library states that you are agree with this disclaimer.
Installation
pip install telegram-bot-gpt
Usage
import bot_gpt as bot
mybot = bot.Engine("<YOUR_TELEGRAM_TOKEN>")
mybot.set_openai_key("<YOUR_OPENAI_KEY>") # a filename also accepted
mybot.run() # only polling method is provided
That's it!!
Special Features
- Admin now has access to GPT-4
- Using global OTP, changeable and resetable by admin
- A small number of chats are stored encrypted as bot memory
- Used tokens are recorded along with the model, useful for cost calculation
- Modifiable bot parameters
Dev Functions
-
Settings
The variable
bot.DEFAULT_SETTINGcontains a dict of the initial values of accessible configurations:{ "memory_length": 3, # the number of previous lines involved "ai_temperature": 85, # 0.75 in the API input "bot_active": 1, # 0 is deactivated "daily_limit": 50, # daily usage limit for common users, server time "admin_limit": 999, # daily usage limit for admin, server time "password": "" # will be set automatically at first run }Accessing variables:
mybot.set_daily_limit(100)modify valuemybot.reset_daily_limit()reset to defaultcurrent_daily_limit = mybot.get("daily_limit")obtain the valuemybot.reset_settings()reset all values to default
-
Bot name
mybot.set_botname("My Bot") mybot.reset_botname() # default is "Bot-GPT"
-
OpenAI key
mybot.set_openai_key("<YOUR_OPENAI_KEY_OR_CORRESPONDING_FILENAME>") mybot.del_openai_key() # AI capabilities will be deactivated
-
Memory length, only used when the input is short
mybot.set_memory_length(5) # more value leads to a more expensive cost mybot.reset_memory_length() # default is 3 memory_length = mybot.get_memory_length()
Bot Usage
-
Admin
The first user is automatically set as the bot admin which is equipped with a list of commands such as password regulations and bot activations. -
Password
New users should enter a randomized code (password) created by the bot which can only be accessed by admin with these commands:/get_passworddisplays the current password/new_passowrdchanges the password without affecting current users/reset_passwordforce all users to enter the new password to continue using the bot
-
Deactivation
The default setting for bot is active, whereas only admin has the right to modify it./deactivate_botbot is off for all users, while admin still can use it/activate_botreactivates the bot for all users
All users can check the bot status using
/is_bot_active.
How To Get
Telegram Bot
Open Telegram app, chat with @BotFather and send the command /newbot.
OpenAI key
Login to OpenAI and follow the instructions there.
Metadata
Release files for telegram-bot-gpt 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| telegram-bot-gpt-0.3.0.tar.gz | 13.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| telegram_bot_gpt-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.2 kB
Release files / telegram-bot-gpt-0.3.0.tar.gz
| Download URL | telegram-bot-gpt-0.3.0.tar.gz |
|---|---|
| Size | 13.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1f5fe78b0f4ccc1517368c4462ebfbd229f02651904d8a5bb054455e13d2618
|
|
BLAKE2b-256 checksum How to use checksums |
1bbfb6ccb8e68136f94ba59cdec28e85fb534615356d73b50ea571ad1c7f9494
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / telegram_bot_gpt-0.3.0-py3-none-any.whl
| Download URL | telegram_bot_gpt-0.3.0-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5aa2b9a1a4eaecc1c93022ea09c91a99af9a21830bba7129d43959d91b09d41e
|
|
BLAKE2b-256 checksum How to use checksums |
ef6d39db33505557bae1d4cf6a3d5c48b058ef9c04fa55691fa88cce7db13786
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|