Add Telegram bot scaffold with ChatGPT, image, and Sora 2 commands#1
Add Telegram bot scaffold with ChatGPT, image, and Sora 2 commands#1allomenyaslishno wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c81a78d2a0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "/image <описание> — генерация изображения (gpt-image-1)\n" | ||
| "/sora <описание> — создание видео через Sora 2 (демо-запуск)" | ||
| ) | ||
| await update.message.reply_text(text) |
There was a problem hiding this comment.
Handle command updates without
update.message
These handlers dereference update.message directly, but CommandHandler can be invoked for command-bearing updates where only effective_message is set (e.g., channel/edited message contexts). In those cases update.message is None, so /start, /chat, /image, and /sora raise AttributeError before they can respond, making commands fail outside the simplest private-chat flow. Use update.effective_message (or guard for None) before replying/sending chat actions.
Useful? React with 👍 / 👎.
Motivation
gpt-4.1,gpt-image-1,sora-2).Description
bot.pyimplementing Telegram commands/start,/chat(usesopenai_client.responses.createwith modelgpt-4.1),/image(usesopenai_client.images.generatewithgpt-image-1and decodes result withbase64.b64decode), and/sora(attemptsopenai_client.videos.generations.createwithsora-2)..env.exampleand the code readsTELEGRAM_BOT_TOKEN,OPENAI_API_KEY, and optionalOPENAI_BASE_URLviaload_dotenv().requirements.txtwithpython-telegram-bot,openai, andpython-dotenvdependencies.README.md(Russian) with setup, configuration, run instructions, and usage examples.Testing
python -m py_compile bot.pysuccessfully with no syntax errors.Codex Task