Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegram Topics <-> Discord Channel Bridging #372

Open
MyrTheMoth opened this issue Sep 12, 2023 · 30 comments
Open

Telegram Topics <-> Discord Channel Bridging #372

MyrTheMoth opened this issue Sep 12, 2023 · 30 comments
Assignees
Labels
Milestone

Comments

@MyrTheMoth
Copy link
Contributor

MyrTheMoth commented Sep 12, 2023

Currently, it seems the new Telegram Topics bridging feature only works by bridging them to a Discord Thread, I understand this use case, even with the volatility of threads on the discord side, but I'd like it if you could bridge a Topic to a whole Channel instead, making it so a single Telegram Group can have parity with a single Discord Server, rather than needing one Telegram Group per Channel.

Such that

Telegram Group < - - - > Discord Server
Topic 1 < - - - > Channel 1
Topic 2 < - - -> Channel 2

etc etc etc

In such a way that messages in Topic 1 only bridge with Channel 1, and so on.

@MyrTheMoth MyrTheMoth changed the title Telegram Topics <= Telegram Topics <-> Discord Channel Bridging Sep 12, 2023
@Lulalaby Lulalaby self-assigned this Sep 12, 2023
@Lulalaby Lulalaby added this to the v1.0.0 milestone Sep 12, 2023
@Exzender
Copy link
Contributor

This can be achieved easily.
Restriction to map Telegram topics only to Discord threads is not mandatory and can be removed.
But keep in mind one thing: you still need one more channel on your server to map 'general' telegram topic.
So the structure will be:

Telegram Group < - - - > Discord Server
Telegram General topic (group itself) < - - - > channel 0
Topic 1 < - - - > Channel 1
Topic 2 < - - -> Channel 2

To summarize up: the only thing will change - that you will be able to map telegram topics not only to threads but also to channels.
It it what you want?

@Lulalaby
Copy link
Collaborator

That's what's meant by them, yep.

@Exzender
Copy link
Contributor

I've checked.
Nothing needs to be changed in code.
Users can already map discord's channel instead of thread.
There are no restrictions in the code.
We can maybe just add this remark to the readme: any discord channel or discord thread may be used for topics mapping in threadMap

@Lulalaby
Copy link
Collaborator

I wonder if threadMap is really the best name

@Lulalaby Lulalaby removed the feature label Sep 12, 2023
@Exzender
Copy link
Contributor

than, maybe just threads be better?

@Fabian42
Copy link
Collaborator

Sure, you can manually enter IDs of threads every single time and restart the bot, but that is infeasible to do, even if you knew when a new one was created on whichever side you're not actively chatting on. A good implementation would just create a thread on the other side. If it can't do that and can't create new chats either, then it could PM the chat IDs or route everything to the main chat with replies.

@Lulalaby
Copy link
Collaborator

than, maybe just threads be better?

That's not what what I mean.
More like since we can map topics with normal channels, and thread is the official discord name, but telegram uses topic..

topicMap? topicBridge?

@Exzender
Copy link
Contributor

than, maybe just threads be better?

That's not what what I mean. More like since we can map topics with normal channels, and thread is the official discord name, but telegram uses topic..

topicMap? topicBridge?

I don't mind. Choose any.

@Exzender
Copy link
Contributor

Sure, you can manually enter IDs of threads every single time and restart the bot, but that is infeasible to do, even if you knew when a new one was created on whichever side you're not actively chatting on. A good implementation would just create a thread on the other side. If it can't do that and can't create new chats either, then it could PM the chat IDs or route everything to the main chat with replies.

I think it's possible. I will look at it.

@Lulalaby
Copy link
Collaborator

The question is how the impact would be if we change it now.

I'd like to go with topicBridges, because from a discord library developer perspective, are threads just a channel sub type while telegram seems to not consider it as channel or whoatsever.

@Exzender
Copy link
Contributor

The question is how the impact would be if we change it now.

I'd like to go with topicBridges, because from a discord library developer perspective, are threads just a channel sub type while telegram seems to not consider it as channel or whoatsever.

I propose just to change readme.
But support both names when reading config file, mapping from old name to a new one.

@Lulalaby
Copy link
Collaborator

Oh yeah. That's a way. Perfect.

@mszaro
Copy link

mszaro commented Sep 24, 2023

So, I just tried to configure this on my own instance, but heads up that topics bridging doesn't appear to work at all - regardless of whether they're channels or threads on the Discord side. With the threadMap section configured on 0.12.3, there is no difference to the behaviour. Messages in other threads/channels on Discord don't show up in Telegram, and all messages from Telegram show up in the main bridged channel, with varying degrees of brokenness depending on which topic they originated in on the Telegram side.

@mszaro
Copy link

mszaro commented Sep 24, 2023

If there's any logging or information I can provide that may be of help, please let me know. (cc @Lulalaby)

@Lulalaby
Copy link
Collaborator

Hmm we have it in use with threads and had no issues at all.
Sounds like your config is messed up.

@mszaro
Copy link

mszaro commented Sep 25, 2023

This is what we're using:

  - name: Bridging Bot
    direction: both
    threadMap:
      - telegram: 142483
        discord: '1155609776097595473'
    telegram:
      chatId: -1001061926369
      relayJoinMessages: true
      relayLeaveMessages: true
      sendUsernames: true
      relayCommands: true
      crossDeleteOnDiscord: true
    discord:
      channelId: '334111268166172673'
      relayJoinMessages: true
      relayLeaveMessages: true
      sendUsernames: true
      crossDeleteOnTelegram: true
      useEmbeds: auto

Are there any special permissions that the bot needs on either side to allow it to work with threads, perhaps?
There are no error messages output in the console, by the way. The messages just get tagged as a reply to a nonexistent message, and then dumped into the #general channel.

@Lulalaby
Copy link
Collaborator

how tf did you got such a big thread id
image

@mszaro
Copy link

mszaro commented Sep 25, 2023

Well that might be the source of the problem then. I found what I thought was it by right clicking and copying the message link from Telegram. (The /threadinfo command for Tedicross doesn't generate any response from the bot.)

@mszaro
Copy link

mszaro commented Sep 25, 2023

Ah, I see. The thread ID is that large because it's spawned from the ID of the message where the topic was created, and we were turning them on for an old group with tons of messages. That does appear to be the legitimate thread ID though.

@Lulalaby
Copy link
Collaborator

Well that might be the source of the problem then. I found what I thought was it by right clicking and copying the message link from Telegram. (The /threadinfo command for Tedicross doesn't generate any response from the bot.)

Make sure the commands are actually registered and the bot has the right perms

@mszaro
Copy link

mszaro commented Sep 25, 2023

Make sure the commands are actually registered and the bot has the right perms

What do you mean by commands are registered? How do I register them?

@Lulalaby
Copy link
Collaborator

The bot registers them. Just check the logs on startup lol. Make sure you have the last version.

The commands are no text commands anymore. They became normal telegram bot commands

@mszaro
Copy link

mszaro commented Sep 25, 2023

Entirety of the log:

$ npm start

> tedicross@0.12.3 start
> node dist/main.js

2023-09-25 17:21:17 [INFO] Telegram: c9gc_bridging_bot (374022301)
2023-09-25 17:21:17 [LOG] [WS => Manager] Fetched Gateway Information
    URL: wss://gateway.discord.gg
    Recommended Shards: 1
2023-09-25 17:21:17 [LOG] [WS => Manager] Session Limit Information
    Total: 1000
    Remaining: 983
2023-09-25 17:21:17 [LOG] [WS => Manager] Spawning shards: 0
2023-09-25 17:21:17 [LOG] [WS => Shard 0] [CONNECT]
    Gateway    : wss://gateway.discord.gg/
    Version    : 10
    Encoding   : json
    Compression: none
2023-09-25 17:21:17 [LOG] [WS => Shard 0] Setting a HELLO timeout for 20s.
2023-09-25 17:21:17 [LOG] [WS => Shard 0] [CONNECTED] Took 156ms
2023-09-25 17:21:17 [LOG] [WS => Shard 0] Clearing the HELLO timeout.
2023-09-25 17:21:17 [LOG] [WS => Shard 0] Setting a heartbeat interval for 41250ms.
2023-09-25 17:21:17 [LOG] [WS => Shard 0] [IDENTIFY] Shard 0/1 with intents: 33281
2023-09-25 17:21:17 [LOG] [WS => Shard 0] [READY] Session b747af1c17f120a12fef5cf3bf07fde2.
2023-09-25 17:21:17 [LOG] [WS => Shard 0] [ReadyHeartbeat] Sending a heartbeat.
2023-09-25 17:21:18 [LOG] [WS => Shard 0] Shard received all its guilds. Marking as fully ready.
2023-09-25 17:21:18 [INFO] Discord: C9GC Telegram <> Discord Bridge (334119059102760972)
2023-09-25 17:21:18 [LOG] [WS => Shard 0] Heartbeat acknowledged, latency of 146ms.

Tried making it an administrator on both Discord and Telegram but yeah, /threadinfo doesn't show up as a command or trigger anything on either side. /chatinfo does though.

@Lulalaby
Copy link
Collaborator

wtf

@Lulalaby
Copy link
Collaborator

image
this is what u should get

@mszaro
Copy link

mszaro commented Sep 25, 2023

Uhh... 😁
I'll try updating node and pulling the repo fresh 🤷‍♂️

@Nam-Ereh-Won
Copy link

Nam-Ereh-Won commented Oct 24, 2023

Did that work for you? I'm testing out the thread functions on 0.12.3 and also getting everything dumped into the the channel set in channel set in ChannelID.

bridges:
  - name: Test bridge
    direction: both
    threadmap:
      - telegram: 65
        discord: '1166231261094891520'
    telegram:
      chatId: -1002077251018
      relayJoinMessages: false
      relayLeaveMessages: false
      sendUsernames: true
      crossDeleteOnDiscord: true
    discord:
      channelId: '1109325629423362118'
      relayJoinMessages: false
      relayLeaveMessages: false
      sendUsernames: true
      crossDeleteOnTelegram: true
      disableWebPreviewOnTelegram: false
      useEmbeds: auto

I've also tried added this to the threadmap list to see if I needed to explicitly send stuff from general but no dice.

      - telegram: 0
        discord: '1109325629423362118'

@Exzender
Copy link
Contributor

threadmap

Try changing param name to threadMap

@Exzender
Copy link
Contributor

So, automatic creation of Topics is almost ready.
User crates topic in TG - bot creates same topic on Discord side and updates the bridges.
And and vice versa.
And that's it for now.

Additional questions:

  1. Should the bot manage deletion of topics as it do with messages? (this for sure will not work for TG -> Discord...). So, I think that bot shouldn't do that.
  2. What to do if user deletes mapped topic on one of the sides? In this case bot will create a new mapping. Looks not good. So user HAVE to delete topics on both sides.
  3. What other cases should be provided for in this scheme?

Exzender added a commit to Exzender/TediCrossFork that referenced this issue Nov 22, 2023
New config option: topicBridgesAutoCreate
@Lakhtiste
Copy link

Lakhtiste commented Mar 20, 2024

here's what I tested

 bridges:
      - name: First bridge
        direction: both
        threadMap: # Remove this and (telegram/discord pairs below if not planing to use Threads )
          - telegram: 2035325236_1
            discord: '1219804367209627818' # Discord thread IDs looks like other channel IDs
        telegram:
          chatId: -1002035325236
          relayJoinMessages: true
          relayLeaveMessages: true
          sendUsernames: true
          crossDeleteOnDiscord: true
        discord:
          channelId: '1219804367209627818'
          relayJoinMessages: true
          relayLeaveMessages: true
          sendUsernames: true
          crossDeleteOnTelegram: true
          disableWebPreviewOnTelegram: false
          useEmbeds: 'auto' # always / never / auto

currently when I send a message in any room on telegram it goes to the discord room when there should only be topic _1, but when I send a message on discord it goes to topic _1 as intended.

and when I write a message on any chat room on discord the bot sends me back the following message "This is an instance of a TediCross bot, bridging a chat in Telegram with one in Discord. If you wish to use TediCross yourself, please download and create an instance. See https://github.com/TediCross/TediCross" when it shouldn't be

how do I get all my Discord rooms to be linked to their respective topics on Telegram only!

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants