Skip to content

Add Telegram bot scaffold with ChatGPT, image, and Sora 2 commands#1

Open
allomenyaslishno wants to merge 1 commit intomainfrom
codex/-api
Open

Add Telegram bot scaffold with ChatGPT, image, and Sora 2 commands#1
allomenyaslishno wants to merge 1 commit intomainfrom
codex/-api

Conversation

@allomenyaslishno
Copy link
Copy Markdown
Owner

Motivation

  • Provide a ready-to-run Telegram bot scaffold that integrates text, image, and video generation via OpenAI models (gpt-4.1, gpt-image-1, sora-2).
  • Make it easy to configure and run with environment variables and a minimal dependency list.
  • Surface clear runtime error reporting when a model or API (especially video/Sora) is unavailable.

Description

  • Added bot.py implementing Telegram commands /start, /chat (uses openai_client.responses.create with model gpt-4.1), /image (uses openai_client.images.generate with gpt-image-1 and decodes result with base64.b64decode), and /sora (attempts openai_client.videos.generations.create with sora-2).
  • Added environment template .env.example and the code reads TELEGRAM_BOT_TOKEN, OPENAI_API_KEY, and optional OPENAI_BASE_URL via load_dotenv().
  • Added requirements.txt with python-telegram-bot, openai, and python-dotenv dependencies.
  • Added README.md (Russian) with setup, configuration, run instructions, and usage examples.

Testing

  • Ran python -m py_compile bot.py successfully with no syntax errors.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread bot.py
"/image <описание> — генерация изображения (gpt-image-1)\n"
"/sora <описание> — создание видео через Sora 2 (демо-запуск)"
)
await update.message.reply_text(text)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant