直接邀請機器人開始使用 | Invite Bots below to try it out!
📖 繁體中文版README.md 📖
This bot is made to sync all kinds of messages between Discord and Line, using four applications including Line bot, Line Notify, Discord bot and Discord webhook.
Supported messages sync types:
Line -----to----> Discord | Support |
---|---|
Text Message | ☑️ |
Pictures | ☑️ |
Videos | ☑️ |
Audios | ☑️ |
Files | ❌️ |
Sticker | ❌️ |
Location | ❌️ |
Any other types of messages | ❌️ |
Discord -----to----> Line | Support |
---|---|
Text Message | ☑️ |
Pictures (jpg, jpeg, png) | ☑️ |
Videos (mp4) | ☑️ |
Audios (m4a, mp3, wav, aac, flac, ogg, opus) | ☑️ |
Other formats files | ❌ |
GIFs | ❌ |
Sticker | ❌ |
Any other types of messages | ❌ |
You can definitely host this service yourself! and it's free! Find it out by the following tutorial!
- Download the latest release from here
- Unzip the file then open up
config.yml
, Notepad++ is recommended - Fill in the following required information, see here for more details
- Now run
run.bat
to start the bot - Make sure you've invited the bot to your Discord server and added it / Line Notify to your Line group
- In line group, send
!綁定
to stat the whole binding process, simply click the url the bot sent to you and follow the instructions - After you've finished binding with Line Notify, you should receive a binding code, send
/link <binding_code>
to the Discord channel you want to sync with - Done! Enjoy the Discord <> Line messages syncing service!
- ffmpeg - You need to install ffmpeg and add it to your PATH environment variable to use this bot
# ++--------------------------------++
# | Discord-Line-Message-Sync ver. |
# | Made by LD (MIT License) |
# ++--------------------------------++
# Bot Owner
# Fill in your name so others can know who is hosting the bot
# This will be shown when someone types /about
bot_owner: ''
# Paste your endpoint for the webhook here.
# You can use ngrok to get a free static endpoint now!
# Find out more here: https://ngrok.com/
webhook_url: ''
# Bot tokens and secrets
# You will need to fill in the tokens and secrets for your Line, Line Notify and Discord bots
# Line bot: https://developers.line.biz/console/
# Line Notify: https://notify-bot.line.me/my/services/
# Discord bot: https://discord.com/developers/applications/
Line_bot:
channel_access_token: ''
channel_secret: ''
Line_notify:
client_id: ''
client_secret: ''
Discord_bot:
bot_token: ''
# (Optional settings)
# You can fill in your own bot invite link here
# This will be shown when someone types /about
# Noted that if you share your bot invite link, anyone can invite your bot to their server
line_bot_invite_link: ''
discord_bot_invite_link: ''
Basically, a webhook URL is an endpoint that other services can send us messages. In this case, we will use it to
receive messages from Line and Discord, so the value of webhook_url
should be the URL(with HTTPS) of your server.
You can find out an easy way by using ngrok, and here is
a tutorial for it.
- Go to Line Developers and login with your Line account
- If you don't have a Business ID, simply create one by following the instructions
- Then click
Create a new provider
- Fill in the required information and click
Create
- Click
Create a new channel
and selectMessaging API
- Fill in the required information and click
Create
- You can now find your channel secret in Basic settings and channel access token in Message API, click
Issue
to copy it
Notes: Please make sure you've checked Allow bot to join group chats
option and un-checked
Auto-reply messages
in your Line bot settings, which can be found in Messaging API
> LINE Official Account features
section.
- Go to Line Developers and login with your Line account
- Select your channel application
- Select Messaging API, find
Webhook URL
and click edit - Fill in your webhook URL and add
/callback
at the end - Click
Save
and it's pretty done! - Remember to check
Use webhook
under theWebhook URL
section
Notes: Line webhook only works with HTTPS, so you need to use a reverse proxy to make it work. If you don't know how to create a reverse proxy, you can use ngrok to create one easily, find out how to use it here.
- Go to Line Notify and login with your Line account
- Click
Add service
- Fill in the service name with
【Discord訊息】
- Fill in the Callback URL with your webhook URL and add
/notify
at the end - Fill in other required information then click
Agree and continue
- You can now find your client ID and secret at the top of the page
- Go to Discord Developer Portal and login with your Discord account
- Click
New Application
- Fill in the name of application and click
Create
- Click
Bot
on the left side - Click
Add Bot
- Check
Presence Intent
,Server Members Intent
andMessage Content Intent
underPrivileged Gateway Intents
- Now you can find your bot token in
Build-A-Bot
section, clickReset Token
to copy it
- Go to Ngrok sign up for an account and login
- Click
+ New Domain
at the Domains Dashboard, copy the domain name you created, which should be something likesometihng-random-idontknow.ngrok-free.app
- Download the latest version of ngrok from here
- Extract the zip file you downloaded and run
ngrok.exe
- Run
ngrok config edit
, it'll open up a text editor - Replace the whole file with the following content
authtoken: <your_auth_token> version: 2 tunnels: app: proto: http hostname: <domain_name> addr: 127.0.0.1:5000
- Replace
<domain_name>
with the domain name you created at step 3 - Replace
<your_auth_token>
with your auth token, which can be found at here
- Replace
- Now save the config file then run
ngrok start app
at the command line - Copy the URL from
Fowarding
, it should be the same as the domain name you created at step 3 - Done! Now you can use this URL as your webhook URL
- Fork this repository
- Clone your forked repository
- Create a new branch
- Make your changes
- Commit and push your changes
- Create a pull request
- Wait for review
- Flask for webhook server
- LineBotSDK for Line bot
- discord.py for Discord bot
- ZeroMQ for messaging between Line bot and Discord bot
- PyYAML for reading config file
- requests for sending HTTP requests
- moviepy for creating video thumbnail
- pydub for ffmpeg wrapper
- 100 characters per line
- Use
snake_case
for variables and functions - Add a blank line at the end of the file
- Optimize imports, remove the redundant ones
- Google style TODO comments
- Use Sphinx Docstring style for docstrings
- Use these headers for commits
- Update - your commit messages here
- Fix bug - your commit messages here
- Optimize - your commit messages here
- Standardize - your commit messages here
If you have any suggestions or found any bugs, please open an issue here, will try to fix it as soon as possible.
This project is licensed under the MIT License - see the LICENSE file for details
這個機器人將盡可能的同步Discord與Line的所有訊息,運用包括Line bot、Line Notify、Discord bot及Discord webhook等技術。
目前支援同步的訊息種類:
Line -----傳送至----> Discord | 支援 |
---|---|
文字訊息 | ☑️ |
圖片 | ☑️ |
影片 | ☑️ |
音檔 | ☑️ |
檔案 | ❌️ |
貼圖 | ❌️ |
位置訊息 | ❌️ |
任何其他種類的訊息 | ❌️ |
Discord -----傳送至----> Line | 支援 |
---|---|
文字訊息 | ☑️ |
圖片 (jpg, jpeg, png) | ☑️ |
影片 (mp4) | ☑️ |
音檔 (m4a, mp3, wav, aac, flac, ogg, opus) | ☑️ |
其他種類的檔案 | ❌ |
GIFs | ❌ |
貼圖 | ❌ |
任何其他種類的訊息 | ❌ |
想要自己架設這個訊息同步機器人嗎? 快點看看下面的使用教學吧!
- 從 這裡 下載最新的版本
- 解壓縮檔案後,於資料夾內開啟
config.yml
, 建議使用 Notepad++來編輯檔案 - 遵照內文完成填寫
config.yml
,請參考 這裡 - 運行
run.bat
- 確認你已經邀請Line bot/Line Notify/Discord bot至你的伺服器及聊天室
- 在 Line 群組中,發送
!綁定
開始整個綁定流程,點擊機器人發送給你的 URL 並依照指示操作 - 當你完成 Line Notify 的綁定後,你將收到一個綁定代碼,請將
/link <binding_code>
發送到你想要同步的 Discord 頻道 - 完成!盡情享受 | Discord<>Line | 訊息同步服務吧!
- ffmpeg - 你必須安裝ffmpeg,並將其路徑加入環境變數才可使用此機器人
# ++--------------------------------++
# | Discord-Line-Message-Sync ver. |
# | Made by LD (MIT License) |
# ++--------------------------------++
# Bot Owner
# Fill in your name so others can know who is hosting the bot
# This will be shown when someone types /about
bot_owner: ''
# Paste your endpoint for the webhook here.
# You can use ngrok to get a free static endpoint now!
# Find out more here: https://ngrok.com/
webhook_url: ''
# Bot tokens and secrets
# You will need to fill in the tokens and secrets for your Line, Line Notify and Discord bots
# Line bot: https://developers.line.biz/console/
# Line Notify: https://notify-bot.line.me/my/services/
# Discord bot: https://discord.com/developers/applications/
Line_bot:
channel_access_token: ''
channel_secret: ''
Line_notify:
client_id: ''
client_secret: ''
Discord_bot:
bot_token: ''
# (Optional settings)
# You can fill in your own bot invite link here
# This will be shown when someone types /about
# Noted that if you share your bot invite link, anyone can invite your bot to their server
line_bot_invite_link: ''
discord_bot_invite_link: ''
簡單來說,Webhook URL 是其他服務可以用來將訊息發送給我們的端點網址。而我們將使用它來接收來自 Line 和 Discord
的訊息,所以 webhook_url
的值應該是你伺服器的對外URL網址(需為HTTPS協議)。你可以使用 ngrok
來簡單的達成此目標,請參考 這裡的教學
- 前往 Line Developers 並使用你的Line帳號登入
- 如果你沒有 Business ID,請按照官網的指示建立一個
- 點擊
Create a new provider
- 填寫完需要的資料後點擊
Create
- 點擊
Create a new channel
並選擇Messaging API
的分類 - 填寫完需要的資料後點擊
Create
- 現在你可以在 Basic settings 找到你的
channel secret
以及在 Message API 找到channel access token
,點擊Issue
來複製
註:請確保你在 Line 機器人設定中的 Messaging API
> LINE Official Account features
, 勾選
Allow bot to join group chats
選項,並 取消勾選 Auto-reply messages
選項
- 前往 Line Developers 並使用你的Line帳號登入
- 點擊你要使用的
channel application
- 選擇 Messaging API 分類, 找到
Webhook URL
並點擊edit
- 貼上你的 Webhook URL 並在尾處加上
/callback
- 點擊
Save
- 在
Webhook URL
底下勾選Use webhook
註:Line Webhook 僅適用於 HTTPS
協議,恕不接受任何未經認證過的網址
如果你不知道如何申請,可以使用 ngrok
創建一個簡單的導向服務,請參考 這裡的教學
- 前往 Line Notify,並使用您的 Line 帳號登入
- 點擊
Add service
- 在 Service Name 欄位輸入
【Discord訊息】
- 在 Callback URL 欄位輸入您的 Webhook URL,並在尾處加上
/notify
- 填寫其他必要資訊,然後點擊
Agree and continue
- 您現在可以在頁面頂部找到您的客戶端 ID 和密鑰
- 前往 Discord Developer Portal 並使用你的Discord帳號登入
- 點擊
New Application
- 幫此機器人取名為
Line訊息
後點擊Create
- 點擊左側列表的
Bot
- 點擊
Add Bot
- 在
Privileged Gateway Intents
底下將Presence Intent
,Server Members Intent
及Message Content Intent
都打勾 - 現在你可以在
Build-A-Bot
底下找到你的 bot token,點擊Reset Token
來複製
- 前往 Ngrok 註冊一個帳號並登入
- 在 Domains Dashboard 中點擊
+ New Domain
,複製您所建立的網域名稱,成功的話應該會長這樣something-random-idontknow.ngrok-free.app
- 從 這裡 下載最新版本的 ngrok 程式
- 解壓縮你下載的 zip 檔案,然後執行
ngrok.exe
- 執行
ngrok config edit
,它會打開一個文字編輯器 - 複製以下並完全替代原本的內容
authtoken: <your_auth_token> version: 2 tunnels: app: proto: http hostname: <domain_name> addr: 127.0.0.1:5000
- 把
<domain_name>
替換為您在步驟3所建立的網域名稱 - 把
<your_auth_token>
替換為您的授權金鑰,您可以在 這裡 找到
- 把
- 現在儲存檔案並關閉,繼續在命令行中執行
ngrok start app
- 複製
Fowarding
所生成的URL,它應該與您在步驟3中創建的網域名稱相同 - 完成!現在你可以將此 URL 作為你的 Webhook URL
- Fork 這個專案
- 複製你剛剛 Fork 的專案至本地
- 建立新的分支
- 盡情發揮你的能力
- Commit / Push 你的程式碼
- 建立新的 Pull Request
- 等待回覆
- Flask 用來架設Webhook伺服器
- LineBotSDK 用來與Line API溝通
- discord.py 用來與Discord API溝通
- ZeroMQ 用來在兩個程式之間進行溝通
- PyYAML 用來讀取config.yml檔案
- requests 用來傳送HTTP請求
- moviepy 用來製作影片的縮圖
- pydub 用來使用ffmpeg處理影音檔案
- 每行不超過100個字元
- 使用
snake_case
命名變數及函式 - 在檔案尾處加上一個空行
- 最佳化程式碼並移除不必要的import
- Google style TODO註解
- 使用 Sphinx Docstring 進行函式註解
- 提交請求時請使用以下格式,並全英文撰寫
- Update - your commit messages here
- Fix bug - your commit messages here
- Optimize - your commit messages here
- Standardize - your commit messages here
如果你有任何建議或是發現了任何問題,請在 Issues 提交你的意見,我會盡快回覆你!
此專案的版權規範採用 MIT License - 至 LICENSE 查看更多相關聲明