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 matterbridge does not send or receive messages #4719

Closed
psuter80 opened this issue Dec 7, 2020 · 11 comments
Closed

Telegram matterbridge does not send or receive messages #4719

psuter80 opened this issue Dec 7, 2020 · 11 comments
Assignees
Labels

Comments

@psuter80
Copy link

psuter80 commented Dec 7, 2020

I can't get a matterbridge to telegram up and running. not sure if i'm doing it all right, so here are all the steps I've executed to set up the bridge:

Steps to reproduce

  1. create a new telegram bot using bothfather and note the API Key (1234567890:AAH7pHpFOoKL8PVy15s6Kkqnx31hZUviPUc)
  2. create a new group in telegram and add the bot to it
  3. send "/command" message to the group
  4. navigate to https://api.telegram.org/bot1234567890:AAH7pHpFOoKL8PVy15s6Kkqnx31hZUviPUc/getUpdates?offset=0
  5. note down the chat id field (negative number i.e.: -987654321)
  6. in nextcloud, as admin enable talk app and install matterbridge via nextcloud admin UI
  7. as user in nextcloud, add new group conversation without participants
  8. open the group conversation and go to the settings tab on the right side
  9. add a new telegram bridge
  10. enter api key and chat id as noted before and click save
  11. check the enabled box to start the matterbridge service
  12. send message to the chat group

Expected behaviour

message should appear in telegram group

Actual behaviour

message only appears in nextcloud talk group but is not sent to telegram group. the same is true for the opposite direction, no messages from telegram are displayed in nextcloud talk.

Talk app

Talk app version: 10.0.3
Server/PHP: PHP 7.2.24-0ubuntu0.18.04.7
Browser: Firefox 83.0 on Ubuntu 18.04

matterbridge log:

time="2020-12-07T15:20:55+01:00" level=info msg="Running version 1.20.0 1a5353d7" prefix=main
time="2020-12-07T15:20:55+01:00" level=info msg="Parsing gateway myGateway" prefix=router
time="2020-12-07T15:20:55+01:00" level=info msg="Starting bridge: telegram.0 " prefix=router
time="2020-12-07T15:20:55+01:00" level=info msg=Connecting prefix=telegram
time="2020-12-07T15:20:55+01:00" level=info msg="Connection succeeded" prefix=telegram
time="2020-12-07T15:20:55+01:00" level=info msg="telegram.0: joining  (ID: telegram.0)" prefix=telegram
time="2020-12-07T15:20:55+01:00" level=info msg="Starting bridge: nctalk.1 " prefix=router
time="2020-12-07T15:20:55+01:00" level=info msg=Connecting prefix=nctalk
time="2020-12-07T15:20:55+01:00" level=info msg=Connected prefix=nctalk
time="2020-12-07T15:20:55+01:00" level=info msg="nctalk.1: joining y5mbqawf (ID: y5mbqawfnctalk.1)" prefix=nctalk
time="2020-12-07T15:20:55+01:00" level=info msg="Gateway(s) started succesfully. Now relaying messages" prefix=main
time="2020-12-07T15:21:00+01:00" level=error msg="SendMessage failed: strconv.ParseInt: parsing "": invalid syntax" prefix=gateway

the last line of the log file appeared after trying to send a message to telegram

@nickvergessen nickvergessen added the feature: integration 📦 Integration with 3rd party (chat) service label Dec 8, 2020
@juliosibaja
Copy link

Hello, Actually i found that the problem is related to: https://github.com/nextcloud/spreed/blob/master/lib/MatterbridgeManager.php#L508

We can see in matterbridge that it uses channel and not chatid.
A solution can be to add an if condition to process telegram like:
$content .= sprintf(' channel = "%s"', $part['chatid']) . "\n\n";

@juliosibaja
Copy link

juliosibaja commented Dec 9, 2020

I can confirm that changing
} elseif (in_array($type, ['telegram', 'steam'])) { $content .= sprintf(' chatid = "%s"', $part['chatid']) . "\n\n"; }
to:
} elseif ($type === 'telegram') { $content .= sprintf(' channel = "%s"', $part['chatid']) . "\n\n"; } elseif ($type === 'steam') { $content .= sprintf(' chatid = "%s"', $part['chatid']) . "\n\n"; }
in MatterbridgeManager solves the telegram issue. Anyway I'm not sure that steam really uses chatid and i did not test it.

This is the log from my matterbrige:
time="2020-12-09T09:43:02Z" level=info msg="Running version 1.20.0 1a5353d7" prefix=main time="2020-12-09T09:43:02Z" level=info msg="Parsing gateway myGateway" prefix=router time="2020-12-09T09:43:02Z" level=info msg="Starting bridge: telegram.0 " prefix=router time="2020-12-09T09:43:02Z" level=info msg=Connecting prefix=telegram time="2020-12-09T09:43:03Z" level=info msg="Connection succeeded" prefix=telegram time="2020-12-09T09:43:03Z" level=info msg="telegram.0: joining -419XXXX12 (ID: -419XXXX12telegram.0)" prefix=telegram time="2020-12-09T09:43:03Z" level=info msg="Starting bridge: nctalk.1 " prefix=router time="2020-12-09T09:43:03Z" level=info msg=Connecting prefix=nctalk time="2020-12-09T09:43:04Z" level=info msg=Connected prefix=nctalk time="2020-12-09T09:43:04Z" level=info msg="nctalk.1: joining tajXXXXi (ID: tajXXXXinctalk.1)" prefix=nctalk time="2020-12-09T09:43:05Z" level=info msg="Gateway(s) started succesfully. Now relaying messages" prefix=main

@psuter80
Copy link
Author

psuter80 commented Dec 9, 2020

thank you, that helped.. i changed the lines around the region where you pointed to as follows:

                        } elseif (in_array($type, ['steam'])) {
                                $content .= sprintf('   chatid = "%s"', $part['chatid']) . "\n\n";
                        } elseif ($type == "telegram"){
                                $content .= sprintf('   channel = "%s"', $part['chatid']) . "\n\n";
                        }

after which i was able to send messages to the telegram group chat. I then had to disable privacymode for the telegram bot in order to also be able to receive messages.

i'd appreciate if someone who is working actively on spreed could patch this, i'm not familiar with the wohle process yet and and don't have too much time atm to get into that :)

I think my "steps to reproduce" could also be used for documentation purposes in the future. just add a step where privacy mode is disalbed as step 2 into the list :)

@psuter80
Copy link
Author

psuter80 commented Dec 9, 2020

@juliosibaja you beat me by a couple of minutes ;)

@julien-nc
Copy link
Member

julien-nc commented Dec 9, 2020

@psuter80 @juliosibaja Thanks a lot! I'll make a PR to fix this on the Talk side.

There are still 2 changes to make/suggest in Matterbridge project:

julien-nc pushed a commit that referenced this issue Dec 9, 2020
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
backportbot-nextcloud bot pushed a commit that referenced this issue Dec 9, 2020
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
backportbot-nextcloud bot pushed a commit that referenced this issue Dec 9, 2020
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
@juliosibaja
Copy link

Nice!!
Thank you @eneiluj @psuter80 .

I'm not a matterbrige expert but looking some examples like the zulip's conf into matterbridge.toml.sample
or the msteams's and same for Steam. It seems like all the message services use the channel tag/var to identify the chat id / room id and the ids in the table (i.e. https://github.com/42wim/matterbridge/blob/0d7315249d20bf9856605068074a7b6c6bcce835/matterbridge.toml.sample#L1825 ) is just how it is originally called on each platform.

This is only for the '[[gateway]]' part of the toml. Please correct me if i'm wrong, but i think that the line $content .= sprintf(' channel = "%s"', $part['channel']) . "\n"; is enough for all the services.

@nickvergessen
Copy link
Member

So close because #4727 is merged? or is this a new issue and also needs fixing? @eneiluj

@julien-nc
Copy link
Member

@juliosibaja You are probably right and that would explain why I never managed to make MsTeams work... I'll check this out.

@nickvergessen It's a new issue but related enough to stay here.

julien-nc pushed a commit that referenced this issue Dec 11, 2020
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
@julien-nc
Copy link
Member

@juliosibaja Thanks a lot, channel is indeed always used. So now MsTeams work fine, tested and approved. Steam should also work fine.

@juliosibaja
Copy link

Great @eneiluj. Thank you!!

backportbot-nextcloud bot pushed a commit that referenced this issue Dec 18, 2020
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
backportbot-nextcloud bot pushed a commit that referenced this issue Dec 18, 2020
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
@no-response
Copy link

no-response bot commented Dec 31, 2020

This issue has been automatically closed because there has been no response to our request for more information. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@no-response no-response bot closed this as completed Dec 31, 2020
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

4 participants