Gemini_Telegram_Bot
Interact with the Gemini API via Telegram.
Demo
Click here
How to Install
(1) On Linux
- Install dependencies
pip install -r requirements.txt
- Obtain Telegram Bot API at BotFather
- Get Gemini API keys from Google AI Studio
- Get your Telegram user id to use as the administrator id.
- To run the bot, execute:
export TELEGRAM_BOT_API_KEY={Telegram Bot API}
export GEMINI_API_KEYS={Gemini API keys}
export ADMIN_USER_IDS={Your Telegram user id}
python src/main.py
By default, the bot stores selected models and recent chat history in data/bot.db. You can override this with --db-path.
(2)Deploy Using Docker
Use the built image
docker run -d --restart=always -v $(pwd)/data:/app/data -e TELEGRAM_BOT_API_KEY={Telegram Bot API} -e GEMINI_API_KEYS={Gemini API Key} -e ADMIN_USER_IDS={Your Telegram user id} qwqhthqwq/gemini-telegram-bot:main
build by yourself
- Get Telegram Bot API at BotFather
- Get Gemini API keys on Google AI Studio
- Clone repository
git clone https://github.com/H-T-H/Gemini-Telegram-Bot.git
- Enter repository directory.
cd Gemini-Telegram-Bot
- Build images
docker build -t gemini_tg_bot .
- run
docker run -d --restart=always -v $(pwd)/data:/app/data -e TELEGRAM_BOT_API_KEY={Telegram Bot API} -e GEMINI_API_KEYS={Gemini API Key} -e ADMIN_USER_IDS={Your Telegram user id} gemini_tg_bot
How to Use
- Send your questions directly in a private chat.
- In a group chat, use /gemini + your question. Photo is supported.
- You can use the /clear command to delete the current conversation history.
- You can use the /model command to choose or switch the model.
- Unauthorized users automatically submit an access request on first use. Administrators can approve or reject requests with private chat buttons.
- Administrators can use /access to list approved users, then revoke access with buttons.
- Administrators can use /accessrequest to toggle new access requests.
Reference
- https://github.com/yihong0618/tg_bot_collections
- https://github.com/yym68686/md2tgmd