A robust Telegram bot that integrates with GitHub to send notifications, manage repositories, and interact with issues/PRs directly from your chat.
- Real-time Notifications: Receive instant updates for Pushes, Issues, Pull Requests, Reviews, Forks, Stars, and more.
- Repository Management: Add or remove repositories directly from Telegram (
/addrepo,/removerepo). - Auto-Discovery: Automatically find and link repositories you have access to.
- Interactive Settings: Configure which events to receive for each repository using a user-friendly inline menu (
/settings). - Direct Interaction:
- Reply to Threads: Reply to a notification message in Telegram to post a comment on the corresponding GitHub Issue or PR.
- Commands: Reply to a notification with
/close,/reopen, or/approveto perform the action directly. - Quick Actions: Approve or Close Pull Requests via inline buttons (note: this feature is currently simplified).
- Privacy & Security:
- Private chat only authentication (
/connect). - Encrypted storage of OAuth tokens.
- Role-based access control (Admin-only management commands).
- Strict privacy policy (
/privacy).
- Private chat only authentication (
- Stateless Webhooks: Efficient handling of webhooks without database lookups for routing.
- Code: Push events
- Issues: Open, close, reopen, edit, etc.
- Pull requests: Open, close, review, etc.
- Wikis: Gollum events
- Settings: Repository updates
- Webhooks and services: Meta events
- Deploy keys: Key management
- Collaboration invites: Member changes
- Forks: Fork events
- Stars: Watch events
- Go: v1.23 or higher
- Docker & Docker Compose: For containerized deployment.
- MongoDB: v5.0+ (Provided via Docker Compose).
- Telegram Bot Token: Get one from @BotFather.
- GitHub OAuth App: Create one in Developer Settings.
- Homepage URL: Your bot's URL (e.g.,
https://your-domain.com). - Authorization callback URL:
https://your-domain.com/oauth/callback.
- Homepage URL: Your bot's URL (e.g.,
Copy sample.env to .env and configure the following variables:
# --- Telegram ---
# Your Telegram Bot Token
TELEGRAM_TOKEN=123456:ABC-DEF...
# Public URL where the bot is reachable
TELEGRAM_WEBHOOK_URL=https://your-domain.com
# --- GitHub OAuth ---
# From your GitHub OAuth App
GITHUB_CLIENT_ID=Iv1...
# From your GitHub OAuth App
GITHUB_CLIENT_SECRET=0123...
# --- Webhooks ---
# A strong random string shared between GitHub and the bot to validate payloads. (openssl rand -hex 16)
GITHUB_WEBHOOK_SECRET=your_webhook_secret_here
# --- Database ---
MONGODB_URI=mongodb://mongo:27017
DATABASE_NAME=github_bot
# --- Security ---
# 32-byte (64 hex chars) string for encrypting tokens in the DB.
# Generate with: openssl rand -hex 32
ENCRYPTION_KEY=a1b2c3d4...
# --- Server ---
PORT=8080-
Clone the repository:
git clone https://github.com/AshokShau/GithubBot.git cd GithubBot -
Setup Environment:
cp sample.env .env # Edit .env with your credentials -
Run the application:
docker-compose up -d --build
-
Verify: The bot should be running on
http://localhost:8080. GitHub will send webhooks tohttps://your-domain.com/webhook/....
- Install dependencies:
go mod download - Build the binary:
go build -o bot cmd/bot/main.go - Run:
./bot
- Start the bot: Send
/startto your bot. - Connect GitHub: Send
/connect(in a private chat) to authenticate with GitHub. - Add a Repository:
- Group Chat:
/addrepo owner/repo - Or use
/addrepowithout arguments to browse your repositories interactively.
- Group Chat:
- Configure Notifications:
- Send
/settingsto view linked repositories. - Select a repository to customize events (e.g., enable "Issues" but disable "Stars").
- Send
- Interact:
- When you receive an issue notification, simply reply to that message in Telegram to post a comment on GitHub.
/start- Start the bot and see the welcome message./help- Show available commands and help text./connect- Connect your GitHub account (Private chat only)./addrepo [owner/repo]- Link a repository to the current chat./removerepo [owner/repo]- Unlink a repository./settings- Manage notification settings for linked repositories./repos- List all repositories linked to the current chat./privacy- View the privacy policy./logout- Disconnect your GitHub account./reload- Refresh admin cache (Admin only)./close- Close an issue or PR (reply to notification)./reopen- Reopen an issue or PR (reply to notification)./approve- Approve a PR (reply to notification).
- Bot Framework:
gotgbotfor Telegram Bot API. - GitHub Integration:
go-githubfor API calls and webhook handling. - Database: MongoDB for storing user tokens (encrypted) and chat-repo links.
- Security: AES-GCM encryption for stored OAuth tokens.
- Stateless Webhooks: The webhook URL path contains an encrypted token representing the Chat ID, allowing the bot to route events without database lookups during the webhook request.
Pull requests are welcome! Please ensure you follow the coding standards and update tests as appropriate.
This project is licensed under the MIT License - see the LICENSE file for details.
Maintained by: AshokShau
Telegram: https://t.me/FallenProjects
- Found a bug or unexpected behavior?
- Please open a GitHub Issue with proper logs/details.
- General support & updates are shared on Telegram.
⭐ If this project helps you, consider giving it a star.