GoatBot is a bot which bridges a chat in Telegram with a channel in Discord. (Cedit to TediCross: https://github.com/TediCross/TediCross)(Do not contact TediCross for issues with this bot)
There is no public GoatBot. You need to host it yourself. To host a bot, you need nodejs. The bot requires NodeJS 8 or higher
Updates for this bot are lacking and changes may be needed to catch up with updates Discord and Telegam have made on their ends.
The bot is able to relay text messages and media files between Discord and Telegram. @-mentions, URLs, code (both inline and block-style) works well. This includes @everyone and @here, if you don't want these to work, turn it off in the Bot's discord permissions.
Setting up the bot requires basic knowledge of the command line, which is bash or similar on Linux/Mac, and cmd.exe in Windows
-
Install nodejs
-
Clone this git repo, or download it as a zip or whatever https://github.com/Myke500/GoatBot/
-
Open a terminal and enter the repo with the
cd
command. Something likecd Downloads/goat-master
. Your exact command may differ -
Run the command
npm install
-
Make a copy of the file
example.settings.yaml
and name itsettings.yaml
-
Aquire a bot token for Telegram (How to create a Telegram bot) and put it in the settings file The Telegram bot must be able to access all messages. Talk to @BotFather to disable privacy mode for the bot Do NOT use another bot you already have running. That will cause all sorts of weird problems. Make a new one
-
Aquire a bot token for Discord (How to create a Discord bot) and put it in the settings file under
discord.token
. NOTE that the token is NOT the "Client Secret". The token is under the section "App bot user" further down the page Also make it a Real Bot! Scroll down until you see "Create a bot user" and click that. Also click "Yes, do it!"
- Do NOT use another bot you already have running. That will cause all sorts of weird problems. Make a new one
- Add the Telegram bot to the Telegram chat
- If the Telegram chat is a supergroup, the bot also needs to be admin of the group, or it won't get the messages. The creator of the supergroup is able to give it admin rights
- Add the Discord bot to the Discord server (https://discordapp.com/oauth2/authorize?client_id=YOUR_CLIENT_ID_HERE&scope=bot&permissions=248832). This requires that you have admin rights on the server
- Start GoatBot:
npm start
- Ask the bots for the remaining details. In the Telegram chat and the Discord channel, write
/chatinfo
. Put the info you get in the settings file.
- If you want to bridge a Telegram group or channel, remember that the ID is negative. Include the
-
when entering it into the settings file - It is important that the Discord IDs are wrapped with single quotes when entered into the settings file.
'244791815503347712'
, not244791815503347712
- Restart GoatBot. You stop it by pressing CTRL + C in the terminal it is running in
- Next you will want to make sure it stays running if you log out. See the options here (https://stackoverflow.com/questions/12701259/how-to-make-a-node-js-application-run-permanently) and choose the one that works best for you.
screen npm start
and then Ctrl+A+D will work as well, but it will not restart if the server is restarted or if the application crashes. On Linux/Ubuntu I recommend using PM2 Monitor. http://pm2.io it also has a webinterface for monitoring and restarting the bot if needed instead of logging into the server. Some common commands with pm2 are: pm2 start main.js [start the bot, may need to add a path depending on your installation] pm2 list all [Show a list of running processes] pm2 restart # [restart/reboot the process identified by a number ]
Done! You now have a nice bridge between a Telegram chat and a Discord channel
As mentioned in the step by step installation guide, there is a settings file. Here is a description of what the settings do.
telegram
: Object authorizing and defining the Telegram bot's behaviourtoken
: The Telegram bot's token. It is needed for the bot to authenticate to the Telegram servers and be able to send and receive messages. If set to"env"
, GoatBot will read the token from the environment variableTELEGRAM_BOT_TOKEN
useFirstNameInsteadOfUsername
: EXPERIMENTAL If set tofalse
, the messages sent to Discord will be tagged with the sender's username. If set totrue
, the messages sent to Discord will be tagged with the sender's first name (or nickname). Note that Discord users can't @-mention Telegram users by their first name. Defaults tofalse
colonAfterSenderName
: Whether or not to put a colon after the name of the sender in messages from Discord to Telegram. If true, the name is displayedName:
. If false, it is displayedName
. Defaults to falseskipOldMessages
: Whether or not to skip through all previous messages cached from the telegram-side and start processing new messages ONLY. Defaults to true. Note that there is no guarantee the old messages will arrive at Discord in ordersendEmojiWithStickers
: Whether or not to send the corresponding emoji when relaying stickers to Discord
discord
: Object authorizing and defining the Discord bot's behaviourtoken
: The Discord bot's token. It is needed for the bot to authenticate to the Discord servers and be able to send and receive messages. If set to"env"
, GoatBot will read the token from the environment variableDISCORD_BOT_TOKEN
skipOldMessages
: Whether or not to skip through all previous messages sent since the bot was last turned off and start processing new messages ONLY. Defaults to true. Note that there is no guarantee the old messages will arrive at Telegram in order. NOTE: Telegram has a limit on how quickly a bot can send messages. If there is a big backlog, this will cause problemsuseNickname
: Uses the sending user's nickname instead of username when relaying messages to TelegramdisplayTelegramReplies
: How to display Telegram replies. Either the stringblockqoute
,inline
orembed
replyLength
: How many characters of the original message to display on repliesmaxReplyLines
: How many lines of the original message to display on replies
debug
: If set totrue
, activates debugging output from the bot. Defaults tofalse
bridges
: An array containing all your chats and channels. For each object in this array, you should have the following properties:name
: A internal name of the chat. Appears in the logdirection
: Direction of the bridge. "both" for bidirectional, "d2t" for discord-to-telegram, "t2d" for telegram-to-discordtelegram.chatId
: ID of the chat that is the Telegram end of this bridge. See step 11 on how to aquire ittelegram.relayJoinMessages
: Whether or not to relay messages to Discord about people joining the Telegram chattelegram.relayLeaveMessages
: Whether or not to relay messages to Discord about people leaving the Telegram chattelegram.sendUsernames
: Whether or not to send the sender's name with the messages to Discordtelegram.relayCommands
: If set tofalse
, messages starting with a/
are not relayed to Discorddiscord.channelId
: ID of the channel the Discord end of the bridge is in. See step 11 on how to aquire itdiscord.relayJoinMessages
: Whether or not to relay messages to Telegram about people joining the Discord chatdiscord.relayLeaveMessages
: Whether or not to relay messages to Telegram about people leaving the Discord chatdiscord.sendUsernames
: Whether or not to send the sender's name with the messages to Telegram
The available settings will occasionally change. The bot takes care of this automatically
Anything capable of running NodeJS should be able to run GoatBot. People have had success running it on ordinary laptops, raspberry pis, Amazon Web Services, Google Cloud Platform, and other machines. It runs on both Linux and Windows, and probably also macOS. It does NOT, however, run on Heroku
The machine must be on for GoatBot to work
Not much at all. Almost all the commands are written in the installation guide exactly as they should be entered. The only thing you need to know in addition is the cd
command, in order to navigate to wherever you unpacked.
This likely means you are using Ubuntu or another Debian based Linux distro. You get node version 4 when you do apt-get install nodejs
, and it is called nodejs
instead of node
.
GoatBot requires node 8 or higher to run. To get node 8 on an Ubuntu machine, run the following two commands:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Then try to run the bot again
The bot just responds with a generic message and repeats itself repeates itself repeates itself with every reply
This happens when you have not entered correct chat IDs in the settings file. See step 11 in the step by step installation guide for instructions on how to get these.
A small gotcha here is that Telegram group chats always have a negative chat ID. Remember to include the "-" in the settings file!
The Telegram team unfortunately decided that bots cannot interact with each other, fearing they would get stuck in infinite loops. This means it is impossible, under any circumstances, for GoatBot to relay messages from other Telegram bots to Discord. Discord does not have this limitation, and the Discord side of the bot will happily relay messages from other Discord bots to Telegram
See https://core.telegram.org/bots/faq#why-doesn-39t-my-bot-see-messages-from-other-bots
The Discord library GoatBot is using has support for audio channels and voice chat. For this, it needs some additional libraries, like node-opus, libsodium and others. GoatBot does not do audio, so these warnings can safely be ignored
GoatBot supports a theoretically infinite number of bridges, limited only by your hardware. Even a simple Raspberry Pi is powerful enough to run multiple bridges, so don't worry about making more
To make more bridges, just copy the one you have, paste it right below and make necessary changes:
...
bridges:
- name: bridge 1
direction: both
telegram:
...
discord:
...
- name: bridge 2
direction: d2t
telegram:
...
discord:
...
...
The names of the bridges are practically only log identifiers. They can be whatever string you want them to be. Note, however, that the setting discord.skipOldMessages
uses the names to know which messages was last sent from which channel, so they should be unique.
Note that the settings file is indentation sensitive. If you do for example
- name: Bridge 1
direction: both
it won't work. The "d" in "direction" must be directly below the "n" in "name". See example.settings.yaml
for proper indentation
This happens when two applications use the same Telegram bot token, or someone has set a webhook on the Telegram bot token. You may simply have accidently launched two instances of GoatBot, or someone else has somehow gotten hold of your token
If you haven't accidently launched two instances of GoatBot, assume the token is compromised. First, talk to @BotFather to generate a new token for the bot. Then go to https://api.telegram.org/botTOKEN/deleteWebhook (with TOKEN
replaced with your actual token) to get rid of any webhook set for the bot. Then update the settings file, and restart the bot
Take a look in guides/autostart/ of this repo
If you cloned the git repo, just do a git pull https://github.com/Myke500/GoatBot
. Running npm install
may or may not be necessary. It doesn't hurt to run it anyway
If you downloaded GoatBot as a zip, do step 2, 3 and 4 in the installation guide again. Then move settings.yaml
(or the deprecated settings.json
, which will automatically be converted to settings.yaml
) and the whole data/
directory from the old version to the new one and start it.
No, maybe hire a guy to do it for you on FIVER?
GoatBot Support: If you have any questions contact @Myke500 on Telegram
Crypto Donations accepted and appriciated:
- x42 coin: XT8W8bm5f7FJ3KeqyRqmEo2Vs5crH5Pzi2
- BTC 35rW7sSrxdJDsy6sbRwY3qyd6dbGcedBXg
- LTC MEXTA5GeRanntN4a6dyDftZs2LdSAQpVP1