Telegram bot using bing dalle-3
Live Show: https://t.me/c/1941649644/2798
In any chat with the bot, send your message like prompt: something or /prompt something or @bot_name something.
You can also send your message like /quota or quota? or @bot_name quota? to get the limit.
- Using
/prompt_proorprompt_pro:will make use of GPT to rewrite your prompt. - Using
/prompt_gemorprompt_gem:will make use of gemini to rewrite your prompt. - You can also send image then use startsword,
prompt:orprompt_gemto draw based on the picture
note if you want to use prompt_gem you need:
- visit https://makersuite.google.com/app/apikey get the key
export GOOGLE_GEMINI_KEY=${the_key}or save in config.toml file
How to make your own DALL-E 3 bing tg bot.
Important
This project requires openai-python which does not install on Python 3.12 due to a compatibility issue.
Read this first if you are new to code
-
Make sure your ip can open https://bing.com/create not jump cn.bing (can use GitHub to login)
-
Use https://bing.com/images/create create a new png, F12 in chrome to get cookie string as bing_cookie
Highly recommanded to use Edge or Chrome to get the cookie, and don't use incognito/privacy mode. We encountered errors when using cookie got by Firefox.
- Get tg token, ask Google or ChatGPT, need get it from BotFather
pip install -r requirements.txtpython tg.py '${tg_token}' '${bing_cookie}'- you can also save your cookies to a new
.cookiesfile in this directory, one cookie per line. then runpython tg.py '${tg_token}'
You can provide multiple cookies, to increase the use limit. see:
usage: tg.py [-h] [-c CONFIG_FILE] tg_token bing_cookie [bing_cookie ...]
positional arguments:
tg_token tg token
bing_cookie bing cookie
options:
-h, --help show this help message and exit
-c CONFIG_FILE additional config file
Or you can start with run.sh:
- Save your tg token to a new
.tokenfile in this directory. - Save your cookies to a new
.cookiesfile in this directory, one cookie per line. chmod +x run.sh./run.shor./run.sh -c <config_file>
Or you can use docker to run it:
docker build -t tg_bing_dalle .docker run -d --name tg_bing_dalle -e tg_token='${tg_token}' -e bing_cookie='${bing_cookie}' --network host tg_bing_dalle
If you want to use multiple cookies, you could save to credentials/.cookies with one cookie per line. Then use this command to run it:
docker run -d --name tg_bing_dalle -e tg_token='${tg_token}' --network host --volume ./credentials/:/credentials tg_bing_dalle
You could also save your tg token to credentials/.token to instead of passing it via environment variables.
- Install flyctl
flyctl auth loginflyctl launch[!NOTE] Change the app name to your own name in fly.toml
flyctl secrets set tg_token=your tg_tokenflyctl secrets set bing_cookie=your bing_cookieflyctl deploy
If you want to use multiple cookies, you just need to set the key of secrets to start with bing_cookie. For example:
flyctl secrets set bing_cookie_0=your bing_cookie_0
To enable prompt_pro, copy config.sample.toml to config.toml, and edit the file to setup your OpenAI API.
Then add the option -c config.toml to start the server.
python tg.py '${tg_token}' '${bing_cookie}' -c config.tomlIf you are running it using Method 3 (Run from Docker), you need to rebuild the image and add the option -e config_file='config.toml' to start it.
docker run -d --name tg_bing_dalle -e tg_token='${tg_token}' -e bing_cookie='${bing_cookie}' \
-e config_file='config.toml' --network host tg_bing_dalle
If you are running it using Method 4 (Deploy to Fly.io), you need to add the option -e config_file='config.toml' to deploy.
flyctl deploy -e config_file='config.toml'
To enable prompt_gemini, copy config.sample.toml to config.toml, and edit the file to setup your Gemini API.
To enable @bot_name ${prompts}, you can either disable privacy mode or add the bot as a Group Admin (not recommended for public groups).
Please note that this may decrease the efficiency of the bot since it will have to process all messages in the group, potentially overloading the server running it.
- lark version lark-dalle3-bot
- Any issue reports or PRs are welcome.
- Any other bot type like slack/discord welcome
- Before PR, use
pip install -U blackthenblack .first
- Thank you, that's enough. Just enjoy it.
