Skip to content

FunPay seller Telegram bot (MVP): chats, lot creation, proxies, AI - #1

Open
devin-ai-integration[bot] wants to merge 3 commits into
circleci-project-setupfrom
devin/1778313817-funpay-tg-bot
Open

FunPay seller Telegram bot (MVP): chats, lot creation, proxies, AI#1
devin-ai-integration[bot] wants to merge 3 commits into
circleci-project-setupfrom
devin/1778313817-funpay-tg-bot

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented May 9, 2026

Copy link
Copy Markdown

Summary

First MVP of a personal Telegram bot for managing a FunPay seller account, scaffolded from scratch in this previously-empty repo. Built per the spec from chat: proxies, chats, search-driven lot creation, AI-assisted descriptions.

Stack: Python 3.11+ • aiogram 3.x • httpx + httpx-socks • lxml/BeautifulSoup • aiosqlite • OpenAI • Pydantic-Settings.

What's in the PR

  • Project scaffolding: pyproject.toml (with funpay-tg-bot console script), src/ layout, .env.example, .gitignore, README.md.
  • FunPay async client (src/funpay_tg/funpay/): client.py (golden_key auth, CSRF handling, runner endpoint, image upload for chats and offers, lot save / raise), parsers.py (lxml/bs4 parsers for home, chat list, chat history, my-lots, offer-edit form), proxies.py (round-robin pool, scheme normalisation, HTTP/HTTPS/SOCKS5), types.py, exceptions.py.
  • Telegram bot (src/funpay_tg/bot/): aiogram 3.x dispatcher, admin-only ACL middleware, FSM states, inline keyboards, handlers split by feature — start, chats, sell, lots, proxies, settings.
  • Storage (src/funpay_tg/db.py): aiosqlite — proxies, settings, lot drafts.
  • AI helper (src/funpay_tg/ai.py): OpenAI wrapper for description rewriting and chat-reply suggestions.
  • Entry point (src/funpay_tg/main.py) wires it all together.
  • Tests (tests/): unit tests for parsers (synthetic HTML fixtures) and the proxy pool. 12 tests, all green locally.
  • CI: added a GitHub Actions workflow (.github/workflows/ci.yml) running ruff check src/ tests/ and pytest -q on Python 3.11. Also rewrote the welcome-orb stub .circleci/config.yml to do the same — but this repo isn't connected to CircleCI in practice, so GitHub Actions is the gate that actually runs.

ruff check src/ tests/ is clean and pytest -q is green both locally and in GitHub Actions on the PR.

Updates since last revision

  • Added .github/workflows/ci.yml — initial CircleCI config never executed (no project linked there), so CI was effectively missing.
  • Fixed import ordering in tests/test_parsers.py after ruff (running on src/ tests/) flagged it in CI.

Review & Testing Checklist for Human

This PR is yellow-to-red risk — large new surface area, no end-to-end test against the real FunPay site, and no smoke-test against the real Telegram API. The unit tests only validate parsers against fixtures I wrote myself, which is not the same as validating them against FunPay's actual HTML.

  • Real FunPay smoke test. Put a valid FUNPAY_GOLDEN_KEY in .env, run the bot, and try /start → Status. The home-page parser (parse_account / category extraction in parsers.py) is the riskiest piece — FunPay's real markup may differ from the fixture and break category enumeration. Watch for empty category lists or wrong balance / username.
  • Sell flow end-to-end. This is the most fragile path: client.get_lot_form_apply_draft (in bot/handlers/sell.py) → client.save_lot. I'm guessing the form field names (fields[summary][ru], fields[desc][ru], price, amount, active); real FunPay subcategories may use different locale-prefixed names and the save will silently fail. Try creating one cheap test lot and confirm it actually appears in your offer list.
  • Chat reply / photo upload. Verify text reply lands in a real chat, and that photo upload via client.upload_image (chat endpoint) actually attaches. The two upload endpoints (/file/addChatImage vs /file/addOfferImage) are easy to swap by mistake — check both.
  • Admin ACL. With TELEGRAM_ADMIN_IDS set, confirm that a different Telegram account is blocked by AdminOnlyMiddleware. Security-critical.
  • Proxy rotation. ProxyPool rotates per-request. If FunPay binds the session to IP, mid-session rotation could log you out — try with one proxy first, then a pool, and watch for LoginRequired errors.
  • CI surface. GitHub Actions is the only check that actually runs (CircleCI is config-only). Decide whether to delete .circleci/config.yml or wire the repo into CircleCI.

Suggested test plan

  1. Clone, python3.11 -m venv .venv && source .venv/bin/activate && pip install -e .[dev].
  2. Copy .env.example.env, fill in TELEGRAM_BOT_TOKEN, TELEGRAM_ADMIN_IDS (your numeric Telegram ID), FUNPAY_GOLDEN_KEY. Optionally OPENAI_API_KEY.
  3. funpay-tg-bot → DM the bot /start.
  4. Status → expect your username + balance.
  5. Chats → open a real conversation, send a text reply, then a photo.
  6. Sell → search for a game you sell, pick a subcategory, fill description, optionally hit "AI improve", set price/amount, submit. Verify on funpay.com that the lot appeared.
  7. Proxies → add a proxy, toggle it, verify subsequent FunPay requests use it (e.g. via a logging proxy or by IP-binding a key).

Notes

  • v2 (auto-delivery, auto-bump scheduler, autoresponders, TG-promotion / reseller integrations) is intentionally out of scope here — said so in chat. Hooks are in place to add them without restructuring.
  • No secrets are committed; .env is gitignored, only .env.example is shipped.
  • main is empty before this PR, so this lands as the entire codebase rather than an incremental change.

Link to Devin session: https://app.devin.ai/sessions/4050ba6a349a47cfb97fec100638bc1d
Requested by: @promi1

- aiogram 3.x bot with admin-only ACL middleware
- Async FunPay client (httpx + lxml) with golden_key auth and CSRF handling
- Chat module: list, view history, reply with text/photo, AI-suggested replies
- Sell flow: search game/category, fill description, AI improve, photos, submit
- Proxy management (HTTP/HTTPS/SOCKS5) with round-robin pool
- AI helper (OpenAI) for description writing and chat replies
- SQLite storage for proxies, settings, lot drafts
- Pydantic-settings config loaded from .env
- Unit tests for parsers and proxy pool
- CircleCI workflow for ruff + pytest
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant