Skip to content

Telegram bot that enhances media posts and chats. It rewrites captions with AI, fetches OMDb metadata, appends poster links, and mirrors processed messages to a log channel. Runs as an aiohttp webhook server and serves live logs. Easy to run with Docker or Poetry, with 1‑click deploy to Koyeb.

License

Notifications You must be signed in to change notification settings

JeevabharathiRK/NancyAI-unified

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NancyAI v2.1🤖

A Telegram bot that:

  • 💬 Acts as a chat assistant powered by Llama 3.1
  • ✨ Rewrites media captions with smart hyperlinks
  • 🎬 Fetches movie/series details (OMDb) and appends poster link
  • 📢 Sends a copy of every processed message to a log channel
  • 🌐 Runs as an aiohttp webhook server (port 8000)
  • 📄 Serves live logs at “/” (shows BOT_LOG_FILE)

Requirements ✅

  • Python ≥ 3.9 (for local dev) or Docker
  • Telegram Bot Token
  • OMDb API key
  • GROQ API key

Environment variables 🔐

Set via .env or .env.dev (both auto-loaded; .env.dev overrides):

  • BOT_TOKEN: Telegram bot token
  • GROQ_API_KEY: Your Groq key (optional)
  • OMDB_API_KEY: OMDb API key
  • LOG_CHANNEL_ID: Channel ID (e.g., -1001234567890) or @username to receive log copies
  • BOT_LOG_FILE: Path to log file (default: bot.log)
  • WEBHOOK_HOST: Public HTTPS URL Telegram can reach (e.g., https://your-ngrok-subdomain.ngrok-free.app)

Never commit real secrets. Use placeholders in VCS.

Quick start (Poetry) 📦

  1. Install Poetry 2.1.4:
curl -sSL https://install.python-poetry.org | python3 - --version 2.1.4
  1. Add Poetry to PATH and persist it:
export PATH="/home/user/.local/bin:$PATH"
# You should add this line to your shell's configuration file (e.g., ~/.bashrc)
echo 'export PATH="/home/user/.local/bin:$PATH"' >> ~/.bashrc
  1. Verify installation:
poetry --version
# Expect: Poetry (version 2.1.4)
  1. Install dependencies:
poetry install
  1. Run the bot:
# If a console script “nancy” exists:
poetry run nancy

# Otherwise:
poetry run python -m nancyai.bot

Quick start (Docker) 🐳

Build:

docker build -t nancyai:latest .

Run:

docker run --rm -p 8000:8000 \
  -e BOT_TOKEN=YOUR_BOT_TOKEN \
  -e OMDB_API_KEY=YOUR_OMDB_KEY \
  -e GROQ_API_KEY=YOUR_GROQ_KEY \
  -e LOG_CHANNEL_ID=-1001234567890 \
  -e WEBHOOK_HOST=https://your-public-host.tld \
  -e BOT_LOG_FILE=/app/bot.log \
  nancyai:latest

Notes:

Webhook setup 🌍

  • Set WEBHOOK_HOST to your public HTTPS URL (ngrok, cloud, etc.)
  • The bot registers the webhook on startup at: {WEBHOOK_HOST}/webhook
  • Example (ngrok):
    • ngrok http 8000
    • Use the HTTPS URL from ngrok as WEBHOOK_HOST

Commands 📜

  • /start — greeting and basic usage
  • /help — help
  • /status — health/status
  • /clear — clear pending state
  • /log — link or file for the current log

Troubleshooting 🛠️

  • Root path shows “Error loading log.”:
    • Ensure BOT_LOG_FILE is writable and exists; the bot handles creation/rotation
  • No Telegram updates:
    • Verify WEBHOOK_HOST is correct and publicly reachable over HTTPS
  • OMDb metadata missing:
    • Check OMDB_API_KEY validity and rate limits
  • Log channel copy not delivered:
    • Ensure the bot is in the channel (admin/member)
    • Use a numeric channel ID (-100…) or @channel username

Easy deploy 📨

Deploy to Koyeb

Contributing 🤝

Issues and PRs are welcome. Feel free to collaborate, improve features, and suggest ideas!

Made with ❤️ by JeevabharathiRK

About

Telegram bot that enhances media posts and chats. It rewrites captions with AI, fetches OMDb metadata, appends poster links, and mirrors processed messages to a log channel. Runs as an aiohttp webhook server and serves live logs. Easy to run with Docker or Poetry, with 1‑click deploy to Koyeb.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published