Telegram chat bot for DALL·E 2
- Responds to a text prompt with an image
- Responds to an image with four variations
- Auto convert, crop, and resize uploaded images to meet OpenAI requirements
- Optionally archive OpenAI results to local storage
- For speed and cost benefits, OpenAI image data does not pass through the bot. Only the URL does (unless you enable archiving)
- Runs stand-alone or serverless
- Minimal dependencies outside the Python Standard Library. There are none if you run it serverless and only use the text prompt feature.
- The prompt must be three or more words
- The prompt must begin with
/dream
. Alternatively, @mention the bot if it has admin access in the group. - The bot only responds in group chats, unless you set
telegramAllowedUserIDs
in dalibot.ini
- A Telegram bot token from BotFather
- An OpenAI API key
- Python 3.8.10+
- For stand-alone mode:
- A web server with a valid domain and certificate
- Python gevent module
- If using the image variations feature:
- Python pillow module
- Python requests module
- If managing your own web server, see WSGI setup
- If running serverless, see cloud function setup
chmod 600 dalibot.ini
- Because Telegram bots are discoverable by anyone, the bot ignores private messages by default. You can whitelist users in dalibot.ini. User IDs can be obtained from the URL bar when messaging a user on https://web.telegram.org/, or from the bots console output when someone messages it. Example config:
telegramAllowedUserIDs = 123456789 987654321
- It is recommended to message
/setjoingroups
to BotFather to set your bot group join toDisabled
after you have added your bot to any desired groups.
- Only allow connections from Telegram's subnets as per the example Nginx config or the Amazon API Gateway Resource Policy
- Set
telegramOutgoingToken
to a strong value.