Page MenuHomePhabricator

Set up a bridge between ukwiki's informal telegram ВікіФлудочат в тг and Ukrainian Wikipedia Discord server
Closed, ResolvedPublic

Description

We want to set up a bridge between ukwiki's informal telegram group ВікіФлудочат в тг, uk:ВП:Телеграм / m:Telegram#Wikimedia, and ukwiki's Discord server, uk:ВП:Discord.

The group should be connected to the #телеграм (744643102001725521) chat on the Discord server

I (@Base) am an admin of the former one and @Ata is the admin of the latter one.

Event Timeline

I confirm.
There wasn't a formal voting on Discord server, but there weren't any objections from server members during a discussion either.

bd808 added a subscriber: bd808.

I did some testing and figured out what we need to do to setup the bot on both sides of this bridge.

@Base, you will need to invite the "@wmtelegram_bot" user to the Telegram chat.

@Ata, you will need to use the bot's invite link to add it to your Discord server.

Once the bot has been added/invited to both sides of the bridge, I will need to do these things:

  • Watch the bot's logs while someone sends a message to the bot from the Telegram channel. This is described at https://wikitech.wikimedia.org/wiki/Tool:Bridgebot#Telegram and needed to find the Telegram channel id for configuring the bridge. @Base and I can probably coordinate this happening.
  • Copy the Telegram channel id into $HOME/bridgebot.toml on Toolforge and restart the bot
  • Cross my fingers that it works like it did in my tests. :)

@Base, you will need to invite the "@wmtelegram_bot" user to the Telegram chat.

I've used @RawDataBot ( SO ) and got this:

{
    "update_id": 755076036,
    "message": {
        "message_id": 1314,
        "from": {
            "id": 252804496,
            "is_bot": false,
            "first_name": "Bohdan",
            "last_name": "Melnychuk",
            "username": "Thecladis"
        },
        "chat": {
            "id": -1001328771247,
            "title": "\u0412\u0456\u043a\u0456\u0424\u043b\u0443\u0434\u043e\u0427\u0430\u0442 \u0432 \u0442\u0433",
            "type": "supergroup"
        },
        "date": 1597654593,
        "new_chat_participant": {
            "id": 211246197,
            "is_bot": true,
            "first_name": "Telegram Bot Raw",
            "username": "RawDataBot"
        },
        "new_chat_member": {
            "id": 211246197,
            "is_bot": true,
            "first_name": "Telegram Bot Raw",
            "username": "RawDataBot"
        },
        "new_chat_members": [
            {
                "id": 211246197,
                "is_bot": true,
                "first_name": "Telegram Bot Raw",
                "username": "RawDataBot"
            }
        ]
    }
}

Unless the IDs are unique per bot I assume you can use the id from here (-1001328771247).

@Ata, you will need to use the bot's invite link to add it to your Discord server.

Mentioned in SAL (#wikimedia-cloud) [2020-08-17T20:16:15Z] <wm-bot> <bd808> Enabling ukwiki Telegram<->Discord bridge (T260502)

I think I see the bot passing messages between the channels in its debug log, but I'll wait for confirmation from @Base or @Ata before resolving.

Mentioned in SAL (#wikimedia-cloud) [2020-08-17T22:19:31Z] <wm-bot> <bd808> Really enabling ukwiki Telegram<->Discord bridge this time. (T260502)

Mentioned in SAL (#wikimedia-cloud) [2020-08-17T22:29:33Z] <wm-bot> <bd808> Update Discord server id for ukwiki Telegram<->Discord bridge. (T260502)

The bot is at least getting connected to the Discord server now:

time="2020-08-17T22:30:18Z" level=info msg="Parsing gateway ukwiki-discord-telegram" func=Start file="gateway/router.go:66" prefix=router
time="2020-08-17T22:30:36Z" level=info msg="Starting bridge: discord.ukwiki " func=Start file="gateway/router.go:75" prefix=router
time="2020-08-17T22:30:37Z" level=info msg="discord.ukwiki: joining телеграм (ID: телеграмdiscord.ukwiki)" func=joinChannels file="bridge/bridge.go:77" prefix=discord

But it is failing to proxy messages:

time="2020-08-17T22:35:13Z" level=debug msg="<= Sending message from Base on discord.ukwiki to gateway" func=messageCreate file="bridge/discord/handlers.go:130" prefix=discord
time="2020-08-17T22:35:13Z" level=debug msg="<= Message is config.Message{Text:"
Мур", Channel:"телеграм", Username:"Base", UserID:"223196252307718144", Avatar:"https://cdn.discordapp.com/avatars/223196252307718144/.jpg", Account:"discord.ukwiki", Event:"", Protocol:"", Gateway:"", ParentID:"", Timestamp:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}, ID:"745048116306247831", Extra:map[string][]interface {}(nil)}" func=messageCreate file="bridge/discord/handlers.go:131" prefix=discord
time="2020-08-17T22:35:13Z" level=debug msg="=> Sending config.Message{Text:"Мур
", Channel:"телеграм", Username:"Base", UserID:"223196252307718144", Avatar:"https://cdn.discordapp.com/avatars/223196252307718144/.jpg", Account:"discord.ukwiki", Event:"", Protocol:"discord", Gateway:"ukwiki-discord-telegram", ParentID:"", Timestamp:time.Time{wall:0xbfc6df68535f6749, ext:295449986577, loc:(*time.Location)(0x31407e0)}, ID:"745048116306247831", Extra:map[string][]interface {}(nil)} from discord.ukwiki (телеграм) to telegram.bridgebot (1001328771247)" func=SendMessage file="gateway/gateway.go:421" prefix=gateway
time="2020-08-17T22:35:13Z" level=debug msg="=> Receiving config.Message{Text:"М
ур", Channel:"1001328771247", Username:"[discord] <Base> ", UserID:"223196252307718144", Avatar:"https://cdn.discordapp.com/avatars/223196252307718144/.jpg", Account:"discord.ukwiki", Event:"", Protocol:"discord", Gateway:"ukwiki-discord-telegram", ParentID:"", Timestamp:time.Time{wall:0xbfc6df68535f6749, ext:295449986577, loc:(*time.Location)(0x31407e0)}, ID:"", Extra:map[string][]interface {}(nil)}" func=Send file="bridge/telegram/telegram.go:60" prefix=telegram
time="2020-08-17T22:35:13Z" level=error msg="SendMessage failed: Bad Request: chat not found" func=handleMessage file="gateway/handlers.go:228" prefix=gateway

Looks like something is not quite right on the Telegram side of the bridge now.

Mentioned in SAL (#wikimedia-cloud) [2020-08-17T22:45:51Z] <wm-bot> <bd808> Update Telegram channel id for ukwiki Telegram<->Discord bridge. (T260502)

Problems that kept it from working:

  • Left enable=false in the gateway config
  • Had the wrong Discord server id in the config (used channel id rather than server id)
  • Had the wrong Telegram channel id in the config (missed the - when copy-n-pasting)

It works now, thanks!

As the last stroke, can we have the prefixes customised to тг for telegram and дс for discord, please?

It works now, thanks!

As the last stroke, can we have the prefixes customised to тг for telegram and дс for discord, please?

{{Done}}

I need to document this on wikitech, but the custom prefix mappings are done in $HOME/remotenickformat.tengo. That file now looks like this:

/**
 * The script will have the following global variables:
 * to modify: result
 * to read: channel, bridge, gateway, protocol, nick
 */

ret := "[" + protocol + "] <" + nick + "> "

if gateway == "ukwiki-discord-telegram" {
  protos := immutable({
    discord: "дс",
    telegram: "тг"
  })
  proto := protos[protocol]
  ret = "[" + (proto == undefined ? protocol : proto) + "] <" + nick + "> "

} else if gateway == "wikipedia-abstract-irc-telegram" {
  ret = "<" + nick + "> "

}


result = ret
bd808 moved this task from To Do to Done on the Tool-bridgebot board.