## Telegram-Bot-GPT
A simple interface for OpenAI ChatGPT ver 3.5 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>")
mybot.run() # currently only polling methode is provided
```
**That's it!!**
---
## What's new?
- Using cipher mechanism for storing memory
- Database is kept in compact form as the default
---
## Dev Functions
- Settings
The variable `bot.DEFAULT_SETTING` contains a dict of the initial values of accessible configurations:
```
{
"memory_length": 3, # the number of previous lines involved
"max_token": 500, # for prompt and response for each line
"ai_temperature": 85, # 0.75 in the API input
"bot_active": 1, # 0 is deactivated
"daily_limit": 50, # usage limit for each day, server time
"admin_limit": 50, # usage limit for each day, server time
"password": "" # will be set automatically by the bot
}
```
There are multiple ways available to access those variables:
1. `mybot.set_max_token(300)` using the provided function
2. `mybot.set("max_token", 300)` save directly to database
3. `mybot.reset_max_token()` reset to default
4. `current_max_token = mybot.get("max_token")` to obtain the value
5. `mybot.reset_settings()` resetting all values to the default
Albeit mostly giving identical effect, the command shown in (1) and (3) are safer than (2) due to an additional checking mechanism.
<br><br>
- Bot name
```
mybot.set_botname("My Bot")
mybot.reset_botname() # default is "Bot-GPT"
```
<br>
- OpenAI key
```
mybot.set_openai_key("<YOUR_OPENAI_KEY>")
mybot.del_openai_key() # AI capabilities will be deactivated
```
<br>
- 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<br>
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.
<br><br>
- Password<br>
New users should enter a randomized code (password) created by the bot which can only be accessed by admin with these commands:
- `/get_password` displays the current password
- `/new_passowrd` changes the password without affecting current users
- `/reset_password` force all users to enter the new password to continue using the bot
<br><br>
- Deactivation<br>
The default setting for bot is **active**, whereas only admin has the right to modify it.
- `/deactivate_bot` bot is off for all users, while **admin still can use it**
- `/activate_bot` reactivates the bot for all users
All users can check the bot status using `/is_bot_active`.
---
## How To Get
**Telegram Bot**<br>
Open Telegram app, chat with [@BotFather](https://t.me/BotFather) and send the command /newbot.
**OpenAI key**<br>
Login to [OpenAI](https://platform.openai.com/account/api-keys) and follow the instructions there.
Raw data
{
"_id": null,
"home_page": "",
"name": "telegram-bot-gpt",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "chatbot,artificial intelligence,gpt transformers,nlp",
"author": "Nugroho Fredivianus",
"author_email": "nuggfr@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d4/73/db197bc4a6a70488c48369c6e89c2cae4043e6952bf6e6b40e0fe9432f13/telegram-bot-gpt-0.2.1.tar.gz",
"platform": null,
"description": "## Telegram-Bot-GPT\r\n\r\nA simple interface for OpenAI ChatGPT ver 3.5 using Telegram bots.\r\n\r\n**DISCLAIMER**\r\n\r\nThis open-source module is only intended to provide an interface between bot and AI on top of the following services:\r\n- Bot provided for free by Telegram FZ-LLC\r\n- GPT AI capabilities as paid services from OpenAI LP\r\n\r\nThe 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.\r\n\r\nUsing this library states that you are agree with this disclaimer.\r\n\r\n---\r\n\r\n**Installation**\r\n```\r\npip install telegram-bot-gpt\r\n```\r\n\r\n**Usage**\r\n```\r\nimport bot_gpt as bot\r\n\r\nmybot = bot.Engine(\"<YOUR_TELEGRAM_TOKEN>\")\r\nmybot.set_openai_key(\"<YOUR_OPENAI_KEY>\")\r\n\r\nmybot.run() # currently only polling methode is provided\r\n```\r\n\r\n**That's it!!**\r\n\r\n---\r\n\r\n## What's new?\r\n\r\n- Using cipher mechanism for storing memory\r\n- Database is kept in compact form as the default\r\n\r\n---\r\n\r\n## Dev Functions\r\n\r\n- Settings\r\n\r\n The variable `bot.DEFAULT_SETTING` contains a dict of the initial values of accessible configurations:\r\n\r\n ```\r\n {\r\n \"memory_length\": 3, # the number of previous lines involved\r\n \"max_token\": 500, # for prompt and response for each line\r\n \"ai_temperature\": 85, # 0.75 in the API input\r\n \"bot_active\": 1, # 0 is deactivated\r\n \"daily_limit\": 50, # usage limit for each day, server time\r\n \"admin_limit\": 50, # usage limit for each day, server time\r\n \"password\": \"\" # will be set automatically by the bot\r\n }\r\n ```\r\n \r\n There are multiple ways available to access those variables:\r\n\r\n 1. `mybot.set_max_token(300)` using the provided function \r\n 2. `mybot.set(\"max_token\", 300)` save directly to database\r\n 3. `mybot.reset_max_token()` reset to default\r\n 4. `current_max_token = mybot.get(\"max_token\")` to obtain the value\r\n 5. `mybot.reset_settings()` resetting all values to the default\r\n\r\n Albeit mostly giving identical effect, the command shown in (1) and (3) are safer than (2) due to an additional checking mechanism.\r\n <br><br>\r\n\r\n\r\n- Bot name\r\n ```\r\n mybot.set_botname(\"My Bot\")\r\n mybot.reset_botname() # default is \"Bot-GPT\"\r\n ```\r\n <br>\r\n\r\n- OpenAI key\r\n ```\r\n mybot.set_openai_key(\"<YOUR_OPENAI_KEY>\")\r\n mybot.del_openai_key() # AI capabilities will be deactivated\r\n ```\r\n <br>\r\n\r\n- Memory length, only used when the input is short\r\n ```\r\n mybot.set_memory_length(5) # more value leads to a more expensive cost\r\n mybot.reset_memory_length() # default is 3\r\n memory_length = mybot.get_memory_length()\r\n ```\r\n\r\n---\r\n\r\n## Bot Usage\r\n\r\n- Admin<br>\r\n 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.\r\n <br><br>\r\n\r\n- Password<br>\r\n New users should enter a randomized code (password) created by the bot which can only be accessed by admin with these commands:\r\n\r\n - `/get_password` displays the current password\r\n - `/new_passowrd` changes the password without affecting current users\r\n - `/reset_password` force all users to enter the new password to continue using the bot\r\n <br><br>\r\n\r\n- Deactivation<br>\r\n The default setting for bot is **active**, whereas only admin has the right to modify it.\r\n - `/deactivate_bot` bot is off for all users, while **admin still can use it**\r\n - `/activate_bot` reactivates the bot for all users\r\n\r\n All users can check the bot status using `/is_bot_active`.\r\n\r\n\r\n---\r\n\r\n## How To Get\r\n\r\n**Telegram Bot**<br>\r\nOpen Telegram app, chat with [@BotFather](https://t.me/BotFather) and send the command /newbot.\r\n\r\n**OpenAI key**<br>\r\nLogin to [OpenAI](https://platform.openai.com/account/api-keys) and follow the instructions there.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A simple interface for OpenAI ChatGPT ver 3.5 using Telegram bots",
"version": "0.2.1",
"split_keywords": [
"chatbot",
"artificial intelligence",
"gpt transformers",
"nlp"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c748bc8c5b420fcb2c4550454ea91feb732e868b4d951b4de679d384bb6bc3d7",
"md5": "2ce046eccf7ec0bc2206bba0f2067039",
"sha256": "62a447dd83022526e1466a0b0c3b60bd876a5490d64b6a9a53b146c4b67091fe"
},
"downloads": -1,
"filename": "telegram_bot_gpt-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2ce046eccf7ec0bc2206bba0f2067039",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 12366,
"upload_time": "2023-03-20T20:05:27",
"upload_time_iso_8601": "2023-03-20T20:05:27.246349Z",
"url": "https://files.pythonhosted.org/packages/c7/48/bc8c5b420fcb2c4550454ea91feb732e868b4d951b4de679d384bb6bc3d7/telegram_bot_gpt-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d473db197bc4a6a70488c48369c6e89c2cae4043e6952bf6e6b40e0fe9432f13",
"md5": "0bb23abae0db85fc27fed8e5a1119eb3",
"sha256": "15e9f64184c09b35e2f5aacad53acdc32be17c0d5a5afa9a45a484699ff7d99b"
},
"downloads": -1,
"filename": "telegram-bot-gpt-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "0bb23abae0db85fc27fed8e5a1119eb3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12367,
"upload_time": "2023-03-20T20:05:29",
"upload_time_iso_8601": "2023-03-20T20:05:29.378750Z",
"url": "https://files.pythonhosted.org/packages/d4/73/db197bc4a6a70488c48369c6e89c2cae4043e6952bf6e6b40e0fe9432f13/telegram-bot-gpt-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-20 20:05:29",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "telegram-bot-gpt"
}