GPTel
Framework to ease the writing of Telegram bots, using advance features like speach to text.
Example
from gptel import GPTelBot, BotContext, ReplyTyping, ReplyImage
bot = GPTelBot(
name="TestBot",
description="A bot to test GPTel framework",
data_default={"flag": False},
)
@bot.command("start", "Starts the bot")
async def command_start(context: BotContext):
yield rf"Hello {context.user_html}!"
@bot.command("help", "Print some help")
async def command_help(context: BotContext):
yield r"Help!"
@bot.command("switch", "Switch flag")
async def command_switch(context: BotContext):
# context.data is specific for current chat.
context.data["flag"] = not context.data["flag"]
yield r"Switch on!" if context.data["flag"] else r"Switch off!"
@bot.command("image", "Show an image")
async def command_image(context: BotContext):
yield ReplyTyping()
# ReplyImage only supports URL at the moment.
yield ReplyImage("https://picsum.photos/300/300.jpg")
# This will handle both text chat and voice messages, that will be converted automatically
# to text using OpenAI's Whisper.
@bot.chat()
async def echo(context: BotContext, message: str):
yield ReplyTyping()
yield r"You said:"
yield message
bot.run()
To run it:
# Set up name, description and button menu of the bot:
python main.py --setup
# Run the bot:
python main.py
Install
pip install gptel
Setup
You need to setup two environment variables:
TELEGRAM_TOKENOPENAI_API_KEY: for the speech to text service.
To get a new Telegram token for your bot:
- Open Telegram: Search for
@BotFather. - Start a Chat: Click "Start" to begin a conversation with BotFather.
- Create Bot: Send
/newbotto BotFather. - Choose Name: Enter a name for your bot when prompted.
- Set Username: Provide a unique username ending in "bot".
- Receive Token: BotFather will give you the bot's token. Keep it secure.
Authors
- Cristobal Carnero Linan - ccarnerolinan@gmail.com
Metadata
Release files for gptel 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 | Provenance | Actions |
|---|---|---|---|---|
| gptel-0.3.0.tar.gz | 4.8 kB | Without provenance | Details for gptel-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gptel-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for gptel-0.3.0-py3-none-any.whl |
Total release size: 10.8 kB
Release files / gptel-0.3.0.tar.gz
| Download URL | gptel-0.3.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53ecb48d90174f62b51e9f6bdd62ea292c8573b0eba236de3eeed1202ec4a8a6
|
|
BLAKE2b-256 checksum How to use checksums |
25d6684c6311c5cfea06bea5a8fd429c99dc812050dec850da53e200f0638908
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.11.8 Linux/6.5.0-1015-azure
|
Release files / gptel-0.3.0-py3-none-any.whl
| Download URL | gptel-0.3.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac8b8200da028a0d9d5645a218c612603572f119735e04a7d3384697076a2d19
|
|
BLAKE2b-256 checksum How to use checksums |
6694b1ac10009c4f04b06c9a19b0e4f247a72c243de6aa6c1b7156e528cdf842
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.11.8 Linux/6.5.0-1015-azure
|
Security for gptel 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.