Giter Site home page Giter Site logo

tedicross / tedicross Goto Github PK

View Code? Open in Web Editor NEW
644.0 30.0 276.0 1.16 MB

Bot which bridges Telegram chats with Discord channels

License: MIT License

Dockerfile 0.17% TypeScript 99.83%
bridge discord discord-bot discordjs-bot telegraf-bot telegram telegram-bot telegram-discord discord-telegram javascript

tedicross's Introduction

TediCross

TediCross is a bot which bridges a chat in Telegram with a channel in Discord.

There is no public TediCross bot. You need to host it yourself. To host a bot, you need nodejs. The bot requires NodeJS 16 or higher.

If you are cloning the repository and looking for the stable release, switch to the stable branch.

TediCross News Channel

We now have a Telegram channel where we post news about the bot! Join us at https://t.me/TediCross

Features & known bugs

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

For a list of known bugs, or to submit a bug or feature request, see this repo's "Issues" tab

Step by step installation:

Setting up the bot requires basic knowledge of the command line, which is bash or similar on Linux/Mac, and cmd.exe in Windows

  1. Install nodejs. TediCross requires at least node version 16
  2. Download the latest release
  3. Open a terminal and enter the repo with the cd command. Something like cd Downloads/TediCross-master. Your exact command may differ
  4. Run the command npm install --omit=dev
  5. Make a copy of the file example.settings.yaml and name it settings.yaml
  6. Acquire 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
  1. Acquire a bot token for Discord (How to create a Discord bot), enable the Message Content Intent under Bot > Privileged Gateway Intents 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 "Bot" further down the page
  • Do NOT use another bot you already have running. That will cause all sorts of weird problems. Make a new one
  1. 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
  1. Add the Discord bot to the Discord server (https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID_HERE&scope=bot&permissions=248832). This requires that you have admin rights on the server
  2. Start TediCross: npm start
  3. 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 channel ID is wrapped with single quotes when entered into the settings file. '244791815503347712', not 244791815503347712
  1. Restart TediCross. You stop it by pressing CTRL + C in the terminal it is running in
  2. To turn on threads support (EXPERIMENTAL) just add threadMap section under particular Bridge. Write /threadinfo in telegram and discord threads to get corresponding IDs.

Done! You now have a nice bridge between a Telegram chat and a Discord channel

Running in Docker

Please refer to Docker Guide for the details.

Settings

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 behavior
    • token: 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", TediCross will read the token from the environment variable TELEGRAM_BOT_TOKEN
    • useFirstNameInsteadOfUsername: If set to true, the messages sent to Discord will be tagged with the sender's first name + last name. If set to false - sender's username will be preferred, but if username is not set - first name + last name. Note that Discord users can't @-mention Telegram users by their first name. Defaults to false
    • colonAfterSenderName: Whether to put a colon after the name of the sender in messages from Discord to Telegram. If true, the name is displayed Name:. If false, it is displayed Name. Defaults to false
    • skipOldMessages: Whether 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 order
    • sendEmojiWithStickers: Whether to send the corresponding emoji when relaying stickers to Discord
    • filterCustomEmojis: Determines what to do with custom emojis from Discord message before it reaches telegram. Has three states:
      1. default - custom emojis will be transferred without any processing (ex: <:emojisnhead:1102667149627113602> My Text);
      2. remove - custom emojis will be removed from the output (ex: My Text);
      3. replace - custom emojis will be replaced with a definable string. Defined in replaceCustomEmojisWith (ex: 🔹 My Text). Defaults to default
    • replaceCustomEmojisWith: Determines a string that will be used as a replacement for custom emojis. Anything that can be passed as a string is supported, including emojis. Defaults to 🔹
    • replaceAtSign: Whether to replace @ sign to something else from Discord message before it reaches. When set to true will replace @ with a string you put into settings.replaceAtSignWith. If set to false - will do nothing. Defaults to false
    • replaceAtSignWith: Determines the string that will be used as a replacement for @ sign. Anything that can be passed as a string is supported, including emojis. Defaults to #
    • removeExcessiveSpacings: USE WITH CAUTION Whether to remove excessive (2 or more) whitespaces from Discord message. Can help to neat your message up if it wasn't particulary untidy in the source. When set to true will remove excessive whitespaces and replace them with a single whitespace instead. If set to false - will do nothing. Defaults to false
    • suppressFileTooBigMessages: Suppress warning messages on errors with sending too big files (due to API limitations) from telegram to discord. Defaults to false.
    • suppressThisIsPrivateBotMessage: If set to true - suppress warning messages (This is an instance of a TediCross bot...) in telegram chats outside configured bridges. Defaults to false
  • discord: Object authorizing and defining the Discord bot's behavior
    • token: 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", TediCross will read the token from the environment variable DISCORD_BOT_TOKEN
    • skipOldMessages: Whether 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 problems
    • useNickname: Uses the sending user's nickname instead of username when relaying messages to Telegram
    • replyLength: How many characters of the original message to display on replies
    • maxReplyLines: How many lines of the original message to display on replies
    • suppressThisIsPrivateBotMessage: If set to true - suppress warning messages (This is an instance of a TediCross bot...) in discord channels outside configured bridges. Defaults to false
    • enableCustomStatus: If set to true - enables the custom status. Defaults to false
    • customStatusMessage: The message to set as custom status. Defaults to "TediCross"
  • debug: If set to true, activates debugging output from the bot. Defaults to false
  • messageTimeoutAmount: Amount for your unit of time to expire messages in MessageMap. Defaults to 24
  • messageTimeoutUnit: Format of time as a string (ie: 'hours', 'days', 'weeks', etc...). Defaults to 'hours'
  • persistentMessageMap: Allow MessageMap to persist between reboots by saving it to a file. Defaults to false
  • 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 log
    • direction: Direction of the bridge. "both" for bidirectional, "d2t" for discord-to-telegram, "t2d" for telegram-to-discord
    • telegram.chatId: ID of the chat that is the Telegram end of this bridge. See step 11 on how to acquire it
    • telegram.relayJoinMessages: Whether to relay messages to Discord about people joining the Telegram chat
    • telegram.relayLeaveMessages: Whether to relay messages to Discord about people leaving the Telegram chat
    • telegram.sendUsernames: Whether to send the sender's name with the messages to Discord
    • telegram.crossDeleteOnDiscord: Whether to also delete the corresponding message on Discord when one is deleted on Telegram. NOTE: See FAQ about deleting messages.
    • discord.channelId: ID of the channel the Discord end of the bridge is in. See step 11 on how to acquire it
    • discord.relayJoinMessages: Whether to relay messages to Telegram about people joining the Discord chat
    • discord.relayLeaveMessages: Whether to relay messages to Telegram about people leaving the Discord chat
    • discord.sendUsernames: Whether to send the sender's name with the messages to Telegram
    • discord.crossDeleteOnTelegram: Whether to also delete the corresponding message on Telegram when one is deleted in Discord
    • discord.disableWebPreviewOnTelegram: Whether to disable links preview when relaying to Telegram
    • discord.useEmbeds: Whether to use embeds for current bridge. Can be always, never, auto. Defaults to false
    • threadMap: An array containing all threads mapping for each bridge
      • telegram: Telegram thread ID. See step 13 on how to acquire it
      • discord: Discord thread ID. See step 13 on how to acquire it

The available settings will occasionally change. The bot takes care of this automatically

FAQ

What kind of machine do I need to run this?

Anything capable of running NodeJS should be able to run TediCross. 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 TediCross to work

Just how much knowledge of the command line do I need to get the bot working?

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 TediCross

The bot gives an error with the message node: not found when I try to run it

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.

TediCross requires node 16 or higher to run. To get node 16 on a Debian based system (including Ubuntu), run the following two commands:

curl -sL https://deb.nodesource.com/setup_16.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 telling me to get my own TediCross instance

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 bot doesn't relay messages sent by other bots

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 TediCross 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

Deleting a message in Telegram does not delete it in Discord

Telegram bots are unfortunately completely unable to detect when a message is deleted. There is no way to implement T2D cross-deletion until Telegram implements this. NOTE: A partial solution to this has been implemented. When a message on Telegram is edited to become just a single dot (.), TediCross will delete it both on Telegram and on Discord.

Deleting messages D2T works as expected

When running npm install, it complains about missing dependencies?

The Discord library TediCross is using has support for audio channels and voice chat. For this, it needs some additional libraries, like node-opus, libsodium and others. TediCross does not do audio, so these warnings can safely be ignored

How do I create more bridges?

TediCross 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: Default bridge
    direction: both
    telegram:
      ...
    discord:
      ...
  - name: Another bridge
    direction: both
    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: Bridge1
      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

TediCross spams errors in the console saying "terminated by other long poll or web hook"

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 accidentally launched two instances of TediCross, or someone else has somehow gotten hold of your token

If you haven't accidentally launched two instances of TediCross, 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

How do I make the bot run automatically when my computer/server starts?

Take a look in guides/autostart/ of this repo

How do I update TediCross?

Most updates are announced on the TediCross News channel. Only very minor ones are not

If you cloned the git repo, just do a git pull, followed by npm install --omit=dev.

If you downloaded TediCross as a zip, do step 2, 3 and 4 in the installation guide again. Then move settings.yaml and the whole data/ directory from the old version to the new one and start it.

Why don't you use webhooks to send the messages to Discord? They are much better

This has been tried, and it did indeed make the messages much prettier. The bot can impersonate multiple people this way. Unfortunately, messages sent through a webhook does not belong to the bot, meaning the bot cannot edit them. Cross-editing from Telegram to Discord is then lost. In addition, it requires the bot owner to have two-factor authentication activated.

Do you know of any way to relay messages from Discord to Telegram (or the other way) without bots?

No

Why is TediCross sending a link to this repository to my chat (Advertizing? Spam?)?

TediCross will send a link to this documentation to every chat it is in which is not configured to bridge correctly. Please use this documentation to configure your bot for bridging and the behavior will stop.

Other questions?

If you need any help, join our group on Telegram or our server on Discord

Want to donate?

Cryptocoins of the following types are accepted:

  • BTC: 1Gzr9ZyvTiFCPKfy2BshuZgUeFLebAfbFU
  • ETH: 0x9449D54C85C8FdB079e74379d93A9C9fe611981A

These donations go to the original creator, not the current maintainer.

tedicross's People

Contributors

3891sinned avatar abhrajo avatar chilace avatar coxxs avatar dependabot[bot] avatar eic0 avatar eli-l avatar exzender avatar jers1k avatar lulalaby avatar mkrhere avatar molteber avatar myrthemoth avatar perryyan avatar robotgryphon avatar suppen avatar t-winter avatar teejo75 avatar trgwii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tedicross's Issues

Proposal to implement the use of environment variables to not expose the secrets

Currently I use a quick workaround for this:
./lib/settings.js

/**************************************
 * Write it back to the settings file *
 **************************************/

fs.writeFile(settingsPath, JSON.stringify(settings, null, "\t"), (err) => {
	if (err) {
		console.error("Could not save changes to the settings!");
	}
});

// Use of .env
settings.telegram.auth.token = process.env.T_TOKEN || settings.telegram.auth.token;
settings.discord.auth.token = process.env.D_TOKEN || settings.discord.auth.token;

/******************************
 * Export the settings object *
 ******************************/

module.exports = settings;

Crash on init if discord_users.json is empty

SyntaxError: Unexpected end of JSON input
at Object.parse (native)
at new DiscordUserMap (/var/TediCross/DiscordUserMap.js:43:15)
at Object. (/var/TediCross/main.js:46:17)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)

Strange behavior

Sometimes a bot tries to process messages not in the right channels and produces an error message:

2017-11-21 15:57:22 [ERR]	Could not edit Telegram message: Error: No corresponding message ID for 382560129117323265
at MessageMap.getCorresponding (/app/lib/MessageMap.js:57:10)
at Promise.resolve.then (/app/lib/discord2telegram/setup.js:148:29)
at process._tickCallback (internal/process/next_tick.js:109:7)
2017-11-21 16:02:09 [ERR]	Could not edit Telegram message: Error: No corresponding message ID for 382546195597492234
at MessageMap.getCorresponding (/app/lib/MessageMap.js:57:10)
at Promise.resolve.then (/app/lib/discord2telegram/setup.js:148:29)
at process._tickCallback (internal/process/next_tick.js:109:7)
2017-11-21 16:06:44 [ERR]	Could not edit Telegram message: Error: No corresponding message ID for 382557993813671936
at MessageMap.getCorresponding (/app/lib/MessageMap.js:57:10)
at Promise.resolve.then (/app/lib/discord2telegram/setup.js:148:29)
at process._tickCallback (internal/process/next_tick.js:109:7)
2017-11-21 16:07:57 [ERR]	Could not edit Telegram message: Error: No corresponding message ID for 382546195597492234
at MessageMap.getCorresponding (/app/lib/MessageMap.js:57:10)
at Promise.resolve.then (/app/lib/discord2telegram/setup.js:148:29)
at process._tickCallback (internal/process/next_tick.js:109:7)

Bot potentially spams Discord after being offline for a while

The Telegram Bot API queues the last 100 messages sent to the bot until they are fetched. This means that if the bot is offline for a while, it will fetch up to 100 messages from Telegram immediately when it is turned on. These 100 messages will then immediately be relayed to Discord

Add option to group messages

When there are consecutive messages from one person within a certain timeframe, IM clients have taken to not remind you who sends them.
This is present in both telegram and discord, and should be a possible option in TediCross as well.

Instead of looking like this

username: message 1
username: message 2

it could look like this

username:
message 1
message 2

JSON error on start

I changed nothing about the bot (installed and uninstalled some unrelated packages), also re-downloading doesn't help. Output:

root@raspberrypi:/home/pi# cd /home/pi/Downloads/TediCross-master && npm start

> [email protected] start /home/pi/Downloads/TediCross-master
> node main.js

module.js:540
    throw err;
    ^

Error: Cannot find module 'moment'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/pi/Downloads/TediCross-master/lib/Logger.js:7:16)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node main.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-01-23T21_29_32_813Z-debug.log
root@raspberrypi:/home/pi/Downloads/TediCross-master# 

settings.json:

{
	"telegram": {
		"auth": {
			"token": "<censored>"
		},
		"useFirstNameInsteadOfUsername": false,
		"commaAfterSenderName": false,
		"colonAfterSenderName": false,
		"skipOldMessages": false,
		"sendEmojiWithStickers": true
	},
	"discord": {
		"auth": {
			"token": "<censored>"
		},
		"skipOldMessages": false
	},
	"debug": false,
	"bridgeMap": [
		{
			"name": "announcements",
			"telegram": -294472349,
			"discord": {
				"guild": "173877869640941568",
				"channel": "235052833630584832"
			}
		},
		{
			"name": "general",
			"telegram": -264625058,
			"discord": {
				"guild": "173877869640941568",
				"channel": "173877869640941568"
			}
		},
		{
			"name": "fanserver",
			"telegram": -258044072,
			"discord": {
				"guild": "173877869640941568",
				"channel": "243076315664744449"
			}
		},
		{
			"name": "patron",
			"telegram": -237765229,
			"discord": {
				"guild": "173877869640941568",
				"channel": "302158891989336065"
			}
		},
		{
			"name": "nomic",
			"telegram": -316253909,
			"discord": {
				"guild": "173877869640941568",
				"channel": "297670830802993153"
			}
		},
		{
			"name": "memes",
			"telegram": -277476841,
			"discord": {
				"guild": "173877869640941568",
				"channel": "350544518333988864"
			}
		},
		{
			"name": "version-discussion",
			"telegram": -258054368,
			"discord": {
				"guild": "173877869640941568",
				"channel": "381490427255324672"
			}
		},
		{
			"name": "moderators",
			"telegram": -286778738,
			"discord": {
				"guild": "173877869640941568",
				"channel": "235053449882894336"
			}
		},
		{
			"name": "moderationlog",
			"telegram": -283606636,
			"discord": {
				"guild": "173877869640941568",
				"channel": "284807244485361675"
			}
		}
	]
}

The mentioned log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/pi/Downloads/TediCross-master/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle [email protected]~start: CWD: /home/pi/Downloads/TediCross-master
10 silly lifecycle [email protected]~start: Args: [ '-c', 'node main.js' ]
11 silly lifecycle [email protected]~start: Returned: code: 1  signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: `node main.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/pi/Downloads/TediCross-master
16 verbose Linux 4.9.59-v7+
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v8.9.4
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: `node main.js`
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I can't find module.js, so I can't tell you what that line says.

Forward and reply in Discord

Discord doesn't have the concept of reply or forward.

When someone forwards a message in Telegram, the Discord side will claim it is the one who forwarded it who sent it.

When someone replies to a message in Telegram, it doesn't show at all that it is a reply in Discord.

Possible fix: When it is a forward, prepend the message with "<forwarder name> (forwarded from <original sender name>". With replies: "<replier name> (in reply to <name>)"

Telegram Albums Order in Discord

Telegram has now released the Album update to desktops as well, something they rolled out to mobile clients a while ago

I've noticed the pictures work just fine when TediCross sends the album pictures to Discord as individual messages, but the only issue is that they are sent out of order

So if it is doable to acquire the order of photos in an album

"As a discord user I'd like Telegram Album Photos to be sent to Discord in the same order as in the Telegram Album"

Username bolding

Currently usernames are bolded from Telegram to Discord, but not from Discord to Telegram

Do we bold both or none?

Massive spam of stacktrace

I just started up a bot that has been down for a few days. Though minimal activity has been in the channels since.

Perhaps I used an old settings.json file on a new version, or a new version of node, I'm not sure.

I'm using the master version of TediCross, with tag e6fa5ff. And node v6.11.3

The relaying is working, BUT it is producing massive amount of error messages, like 10+ a second. where all are exactly the same as this:

2017-09-19 13:51:07 [ERR] Couldn't fetch Telegram messages. Reason: Error: Conflict: terminated by other long poll or webhook
at IncomingMessage.res.on.e (node_modules/teleapiwrapper/lib/bot_api.js:716:18)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)

Any thoughts to what could have gone wrong?

Doesn't seem to relay posts by Telegram bots

Hey everyone,

Have noticed that posts by Telegram bots to the Telegram channel do not get relayed to the Discord server. Noticed this behavior with several different bots. Is this something that is limited by Telegram/Discord itself? Any input would be greatly appreciated :)

Thanks in advance.

Error on startup

Is there anything I need to do after the last update to get it running?

I am getting

npm ERR! Linux 3.10.0-327.3.1.el7.x86_64 npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start" npm ERR! node v6.9.1 npm ERR! npm v3.10.8 npm ERR! code ELIFECYCLE npm ERR! [email protected] start: node main.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node main.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tedicross package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node main.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tedicross
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tedicross
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/kamilla/relay-bot-kittenz/npm-debug.log
`

when running npm start. Node is up to date

Replies do not work in Telegram channels

If a reply is made in a Telegram channel, the message does not go through to Discord

It causes what looks like an error in fetching Telegram messages due to lack of error handling

The cause is that message objects from Telegram channels do not have a from field, and therefore causes an error to be thrown here

Unable to Edit messages from Telegram to Discord

2017-11-17 17:04:30 [ERR]       Could not edit Discord message: ReferenceError: message is not defined
    at dcBot.ready.then.then.then (D:\Apps\TediCross\lib\telegram2discord\setup.js:279:50)
    at process._tickCallback (internal/process/next_tick.js:109:7)
2017-11-17 17:06:26 [ERR]       Could not edit Discord message: ReferenceError: message is not defined
    at dcBot.ready.then.then.then (D:\Apps\TediCross\lib\telegram2discord\setup.js:279:50)
    at process._tickCallback (internal/process/next_tick.js:109:7)

When attempting to edit messages from Telegram to Discord, this error shows up
Messages edited from Discord to Telegram work properly without throwing an error message

Never write to settings file

The file settings.json should never be written to, as this belongs to the users domain.
Error out and/or warn user if it has shortcomings.

This is also troublesome when setting up the app, or doing development, because fatal errors in the startup phase will case the async write operation to cancel, and leave the file blank.

Add ":" to the end of usernames on Telegram

Currently, the messages from Discord to Telegram is styled as such:

Username
Message

But when the username becomes longer, on iOS, the Telegram notification banner becomes a bit confusing to read on first sight. Let me illustrate.


This is the current normal notification, everything looks fine:
currentnormal

But when the username of the Discord user becomes longer, the username wraps to the next line, so it kind of looks like the message itself:
currentlong

If the username is long and contains CJK characters, the problem becomes worse due to the way CJK characters are wrapped:
currentlongcjk

When glancing these notifications quickly, it becomes a problem as the usernames look like the chat content.


Therefore, I propose adding a ":" to the end of the usernames of Discord ➡️Telegram messages, or make it an option, so that the people getting notifications on iOS knows that it's just the username.

pnormal
plong
plongcjk

As these mockups show, adding the ":" to the end of usernames can allow users to easier distinguish between long usernames and the actual messages' content.

Replying from Telegram to a Discord User

A feature suggestion:

Add the Discord username when someone replies to the Telegram Bot

Example

Discord user posts

Telegram bot shares the post in telegram with the format

DiscordUsername
Message

A Telegram user replies to that bot message

Discord bot shares the post in Discord with the format

TelegramUsername (in reply to telegrambot)
Message

My suggestion is to make it so Telegram bot shares the full username of Discord users (Username#####)

And that when someone in telegram replies to the bot, the bot sees which Discord user was replied to by reading the Discord username from the replied message, to which the Discord bot replies as

TelegramUsername (in reply to @DiscordUsername#####)
Message

This could be a way to emulate Telegram replies in Discord, which lacks the feature

Embeds not working

Using a Pokemon Go bot as an example, this is an embed:
bilde
They exist in Discord, but when going through the bridge, they become just "undefined" in Telegram
bilde
as well as for some reason triggering "Could not edit Telegram message: Error: No corresponding message ID for 341170379550621708" in the bot, even though it appears to be no edit

Black/whitelisting specific user and bot messages

Currently, only messages from human users will be cross-posted. Naturally bots were not included because the TediCross bots would constantly mirror each other and create an infinite loop of each other's messages between Telegram and Discord.

However I do have a few other bots in my chats alongside my TediCross bots that I would love to be able to cross-post their messages too. Think there's any way you could add the ability to black/whitelist certain bots and even specific users?

Messages from other bots don't get forwarded

I have a Telegram group with me, the Discord bot and a reminder bot. No messages from the reminder bot get forwarded to Discord.

This might be intentional to avoid an infinite loop of two Discord/Telegram bots in the same Discord chat and the same Telegram chat forwarding each other's messages back and forth, but if I set it up that way, it's really my fault. So allowing this would be only beneficial in almost all cases.

Other people's message do get forwarded.

Add option to remove emoji from stickers

Stickers relayed to discord currently also post the emoji that the sticker uses. This takes up an extra line that really isn't needed, and adds up quickly when using many stickers. Also with the emoji removed and #39 in use, multi-sticker stickers would work close to properly instead of having ~3 lines of space between them.

Better GIF support

Both Telegam and Discord supports GIFs.
When a user from Telegram sends a GIF, TediCross sends it as a MP4 file to Discord, the user needs to download the file to see it.
It's possible to convert Telegram GIFs to a real GIF for displaying it correctly in the Discord chat?
One limiting factor as far I know, is that Discord no accept files no larger than 8 MB

Multi-Group/Multi-Channel Support

Since Telegram doesn't have support for multiple 'channels' in a 'server' as Discord does, some group owners split their group chats into several to try and simulate such organization you get from discord by having several channels in a single server

For Example:

A Telegram Community may have: Main Group, Admin Group, Media Group, etc
The same Community has a Discord with the Channels: Main, Admin, Media, etc

This feature request proposes that, using the same two bots, add support for mapping multiple telegram groups to multiple discord channels in the same server

Rather than having to run a new tedicross mapped to two new bots, we could have a single instance of tedicross using only the two bridge bots being aware of which group and channel are related and mapping them accordingly for bridging

Markdown parser too greedy

Posting an URL like for example http://example.com/cake_cheese_sauce in Discord will make it arrive in Telegram with "cheese" in italic, and no traces of the underscores

Missing peers?

Hi! While I was installing TediCross, I came across these warnings.

pi@raspberrypi:~/TediCross $ npm install
npm WARN [email protected] requires a peer of bufferutil@^3.0.0 but none was installed.
npm WARN [email protected] requires a peer of erlpack@hammerandchisel/erlpack but none was installed.
npm WARN [email protected] requires a peer of node-opus@^0.2.5 but none was installed.
npm WARN [email protected] requires a peer of opusscript@^0.0.3 but none was installed.
npm WARN [email protected] requires a peer of sodium@^2.0.1 but none was installed.
npm WARN [email protected] requires a peer of libsodium-wrappers@^0.5.1 but none was installed.
npm WARN [email protected] requires a peer of uws@^0.14.1 but none was installed.

Can they be safely ignored, or is something wrong?

Markdown formatted messages from T2D loses formatting

A user sent a markdown formatted message from Telegram to Discord. The message lost its formatting

Example message:
Test
Description
Link

The word "Link" got sent, but the actual URL of the link did not. It arrived on Discord like this:
Test
Description
Link

Bot spams messages in text channels

If there are multiple text channels on the Discord server, the bot spams a message whenever anyone says something in the channels it's not supposed to be in

Handle message edits

Would be neat to handle edit events on both sides and update the relevant message :)

"Couldn't fetch Telegram messages" error on startup

After setting skipOldMessages setting to false, this error happens on startup:

Couldn't fetch Telegram messages. Reason: TypeError: Cannot read property 'send' of undefined
    at tgBot.on.wrapFunction (c:\Bots\TediCross\lib\telegram2discord\setup.js:195:61)
    at EventEmitter._.curry (c:\Bots\TediCross\lib\telegram2discord\setup.js:132:4)
    at EventEmitter.wrapper (c:\Bots\TediCross\node_modules\lodash\lodash.js:5232:19)
    at emitOne (events.js:115:13)
    at EventEmitter.emit (events.js:210:7)
    at updates.forEach (c:\Bots\TediCross\lib\telegram2discord\updategetter.js:87:15)
    at Array.forEach (<anonymous>)
    at bot.getUpdates.then (c:\Bots\TediCross\lib\telegram2discord\updategetter.js:69:12)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Send files from Telegram to Discord

With the recent update #4, attachments/files uploaded to Discord will be posted to Telegram as a downloadable link (yey!), but any files from Telegram will not appear as a message from the bot on Discord at all.

The media type that is currently shared from Telegram to Discord properly are image files, but only if they are sent as "compressed", as well as certain links that support media previews.

Would be a wonderful feature for all media attachments uploaded from Telegram to be cross posted in Discord too, now that it works from one side.

Error while starting TediCross

Hi. I'm receiving error while trying to start TediCross

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 silly lifecycle [email protected]~prestart: no script for prestart, continuing
7 info lifecycle [email protected]~start: [email protected]
8 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/pi/TediCross/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lo$
10 verbose lifecycle [email protected]~start: CWD: /home/pi/TediCross
11 silly lifecycle [email protected]~start: Args: [ '-c', 'node main.js' ]
12 silly lifecycle [email protected]~start: Returned: code: 1  signal: null
13 info lifecycle [email protected]~start: Failed to exec start script
14 verbose stack Error: [email protected] start: `node main.js`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:877:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd /home/pi/TediCross
17 verbose Linux 4.4.50+
18 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
19 verbose node v6.5.0
20 verbose npm  v4.6.1
21 error code ELIFECYCLE
22 error errno 1
23 error [email protected] start: `node main.js`
23 error Exit status 1
24 error Failed at the [email protected] start script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

UPDATE: Got it working!

Error: Incorrect login details were provided

Hiya...

First thanks for publishing your work.. it's much appreciated.

I'm trying to setup your bot, but am having an issue on the discord side. The bot connects successfully to Telegram but does not show as 'online' in discord.

My error is:

Telegram: SOC_Relay_Bot (363152045)
(node:25763) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Incorrect login details were provided.
(node:25763) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I am thinking it's a config error with settings.json (mybe)

Bot Token = is good on my end, and bot is in user mode.

ServerID = Also called Guild ID, I find this in my widget. I think this is good on my end.

ChannelID - I have no idea what to use here or where to find this.

usersfile - is this something I need to create or worry about? My understanding is that this is the file the bot interacts with and creates if it doesnt exist?

TypeError: Cannot read property 'replace' of undefined

C:\Users\Administrator\Desktop\TediCross-master\TediCross-master\lib\discord2telegram\md2html.js:85
.replace(/</g, "<")
^

TypeError: Cannot read property 'replace' of undefined
at md2html (C:\Users\Administrator\Desktop\TediCross-master\TediCross-master\lib\discord2telegram\md2html.js:85:4)
at message.embeds.forEach (C:\Users\Administrator\Desktop\TediCross-master\TediCross-master\lib\discord2telegram\setup.js:86:85)
at Array.forEach (native)
at Client.dcBot.on (C:\Users\Administrator\Desktop\TediCross-master\TediCross-master\lib\discord2telegram\setup.js:84:20)
at emitOne (events.js:96:13)
at Client.emit (events.js:188:7)
at MessageCreateHandler.handle (C:\Users\Administrator\Desktop\TediCross-master\TediCross-master\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\Administrator\Desktop\TediCross-master\TediCross-master\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\Administrator\Desktop\TediCross-master\TediCross-master\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:330:35)
at WebSocketConnection.onMessage (C:\Users\Administrator\Desktop\TediCross-master\TediCross-master\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:293:17)

Doesn't start with cron

This might be a problem on my end and not a bug, but I don't know where that problem would be. So I report this and hope that either it actually is a bug and it can be fixed or that I can abuse this as a support forum. :D

Command in terminal: cd /home/pi/Downloads/TediCross-master/ && sudo npm start works.
Command in cron: cd /home/pi/Downloads/TediCross-master/ && sudo npm start doesn't work.

Confirmed by starting it a second time in terminal and waiting for error messages: None, so bot wasn't running.

The bot sometimes stops relaying messages from Discord to Telegram

I have occasionally the problem that tedi don't sync messages from discord to telegram.

The problem is easily worked around by restarting tedi on the server.

I got the following error message:

Error: Connection timed out on method getUpdates
Request error: { Error: socket hang up
at createHangUpError (_http_client.js:302:15)
at TLSSocket.socketCloseListener (_http_client.js:334:23)
at emitOne (events.js:101:20)
at TLSSocket.emit (events.js:191:7)
at _handle.close (net.js:509:12)
at TCP.done [as _onclose] (_tls_wrap.js:332:7) code: 'ECONNRESET' }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.