Language: English | 简体中文
Forward messages from selected Discord channels to Lark / Feishu, Gmail, or DingTalk.
The project includes a local web console for editing configuration, starting or stopping the bridge, sending a test notification, viewing logs, and reviewing recently captured messages.
- Monitor one or more Discord channel URLs or channel IDs.
- Parse channel, author, message content, attachments, and embeds.
- Forward to Lark / Feishu with an interactive card layout.
- Forward to Gmail through SMTP.
- Forward to DingTalk through a custom robot webhook.
- Local admin console at
http://127.0.0.1:8765. - Optional admin login for the local console.
- Test notification button for validating Lark / Gmail / DingTalk without starting Discord monitoring.
- Runtime log, per-session log view, clear-log action, and recent-message storage.
This project currently reads Discord credentials from DISCORD_USER_TOKEN. Automating a personal Discord account may violate Discord's terms and can put the account at risk. Use only in environments where you have authorization and understand the risk. Do not commit tokens, webhook URLs, email passwords, logs, or message history.
The steps below use Chrome / Edge DevTools to read the token from network requests. Firefox and Safari follow the same idea.
- Open https://discord.com/app
- Sign in with the account you want to monitor
- Press
F12, or right-click the page and choose Inspect - Open the Network tab
- Enable Preserve log so requests are not cleared when you navigate
- Filter by
apito show Discord API calls only
Any of these works:
- Refresh the page (
Cmd+R/Ctrl+R) - Click a server or channel in the sidebar
- Send a test message in any channel
You should see requests to discord.com/api/... appear in the list.
- Click any
discord.com/apirequest - Open Headers → Request Headers
- Find the
authorizationfield - Copy the full value into
.envasDISCORD_USER_TOKEN, or paste it into the User Token field in the web console
Example:
DISCORD_USER_TOKEN=your_long_token_stringIf the copied value includes a Bearer prefix, that is fine. This project strips it automatically.
| Valid | Invalid |
|---|---|
A long alphanumeric string from the authorization header |
Starts with Bot (that is a bot token) |
Stored only in your local .env |
A full browser cookie string (__dcfduid=...) |
| Used for your own local testing | Shared in chat, screenshots, or committed to Git |
After saving, use Test notification or Start monitoring in the web console. If the token is invalid, the log will show an auth failure. Sign out and back in to Discord, then extract a fresh token.
- A user token is effectively your Discord login credential. Anyone with it can act as your account.
- Close DevTools after extraction and never share the token.
- If a token may have leaked, change your Discord password immediately to invalidate it, then extract a new one.
git clone https://github.com/TokenScience01/discord-alert-bridge.git
cd discord-alert-bridge
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .envIf you use Conda:
git clone https://github.com/TokenScience01/discord-alert-bridge.git
cd discord-alert-bridge
conda activate discord-alert-bridge # or create first: conda create -n discord-alert-bridge python=3.11 -y
pip install -r requirements.txt
cp .env.example .envEdit .env, or use the web console.
Minimum fields:
ADMIN_USERNAME=admin
ADMIN_PASSWORD=change_this_password
DISCORD_USER_TOKEN=replace_with_authorized_token
DISCORD_CHANNEL_URLS=https://discord.com/channels/YOUR_GUILD_ID/YOUR_CHANNEL_ID
LARK_ENABLED=true
LARK_WEBHOOK_URL=https://open.larksuite.com/open-apis/bot/v2/hook/replace_meGmail and DingTalk can be enabled at the same time. See .env.example for all variables.
cd discord-alert-bridge
source .venv/bin/activate # if using venv
python3 admin.pyOr with Conda:
cd discord-alert-bridge
conda activate discord-alert-bridge
python admin.pyOpen:
http://127.0.0.1:8765
On macOS, you can also double-click:
start_admin.command
In the web console, save the configuration and click Start Listening.
You can also run the bridge directly:
python3 main.pyOr install the package in editable mode:
pip install -e .
discord-alert-bridge
discord-alert-bridge-adminThe local console supports:
- Login and logout.
- Saving
.envconfiguration. - Auto-filling guild ID and channel ID from Discord channel URLs.
- Starting, stopping, and toggling the bridge process.
- Sending a test notification without Discord monitoring.
- Viewing the current session log.
- Clearing the log.
- Viewing recently recorded messages grouped by channel.
Default console credentials come from .env.example:
ADMIN_USERNAME=admin
ADMIN_PASSWORD=changemeChange ADMIN_PASSWORD before keeping the console running.
| Variable | Description |
|---|---|
ADMIN_USERNAME |
Local web console username. |
ADMIN_PASSWORD |
Local web console password. |
| Variable | Description |
|---|---|
DISCORD_USER_TOKEN |
Authorized Discord user token used by the gateway client. Keep it private. |
DISCORD_CHANNEL_URLS |
One or more Discord channel URLs, comma-separated. |
DISCORD_CHANNEL_IDS |
Optional explicit channel IDs. |
DISCORD_ALLOWED_GUILD_IDS |
Optional guild allow-list. |
DISCORD_GATEWAY_PROXY |
Empty = library/system default; none = direct connection; or an explicit proxy such as socks5://127.0.0.1:7890. |
ALERT_PREFIX |
Prefix used in forwarded notifications. |
LOG_LEVEL |
DEBUG, INFO, WARNING, or ERROR. |
Channel URL format:
https://discord.com/channels/GUILD_ID/CHANNEL_ID
| Variable | Description |
|---|---|
LARK_ENABLED |
Set to true to enable Lark forwarding. |
LARK_WEBHOOK_URL |
Custom bot webhook URL. |
LARK_SECRET |
Optional signing secret. |
| Variable | Description |
|---|---|
GMAIL_ENABLED |
Set to true to enable Gmail forwarding. |
SMTP_HOST |
SMTP server, defaults to smtp.gmail.com. |
SMTP_PORT |
SMTP port, defaults to 587. |
SMTP_STARTTLS |
Set to true for STARTTLS. |
SMTP_USERNAME |
SMTP username. |
SMTP_PASSWORD |
SMTP password or Gmail App Password. |
SMTP_FROM |
Sender address. |
SMTP_TO |
Recipient addresses, comma-separated. |
For Gmail, an App Password is usually required when two-step verification is enabled.
| Variable | Description |
|---|---|
DINGTALK_ENABLED |
Set to true to enable DingTalk forwarding. |
DINGTALK_WEBHOOK_URL |
Custom robot webhook URL. |
DINGTALK_SECRET |
Optional signing secret. |
The app may create these local files:
| File | Purpose |
|---|---|
.env |
Local secrets and configuration. |
admin.log |
Admin console log. |
bridge.log |
Bridge runtime log. |
.bridge.pid |
Running bridge process ID. |
.admin.pid |
Admin process ID when started manually. |
messages.json |
Recently recorded forwarded messages. |
These files are ignored by Git because they may contain tokens, webhook URLs, or message content.
pip install -e ".[test]"
python3 -m unittest discover -s tests -vdiscord-alert-bridge/
├── discord_alert_bridge/
│ ├── admin.py # Admin API and process control
│ ├── admin_auth.py # Local console authentication
│ ├── admin_ui.py # Web console HTML/CSS/JS
│ ├── config.py # Environment configuration
│ ├── discord_gateway.py # Discord Gateway listener
│ ├── formatting.py # Notification formatting
│ ├── forwarders.py # Lark / Gmail / DingTalk forwarding
│ ├── message_store.py # Recent-message storage
│ ├── models.py # Shared data models
│ └── paths.py # Project paths
├── admin.py # Admin console entrypoint
├── main.py # Bridge entrypoint
├── .env.example # Configuration template
├── requirements.txt
└── tests/
Before sharing or publishing this repository:
git status
git check-ignore -v .env bridge.log messages.jsonMake sure you did not commit:
.env- Any token or webhook URL
- Gmail passwords or App Passwords
bridge.log,admin.log, or archived logsmessages.json- Real guild, channel, or message history data
Rotate any token, webhook, or password that may have been exposed.
This project currently uses a Discord user token + Gateway approach for local testing, without requiring a bot invitation.
Warning: Automating a normal user account may violate the Discord Terms of Service and can lead to account action. Use it only for personal local testing and at your own risk.
If a token or webhook may have leaked, rotate it immediately.
MIT License. See LICENSE.