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 messaging doesn't answer to the correct conversation #607

Closed
helldog136 opened this issue Nov 13, 2019 · 2 comments
Closed

Telegram messaging doesn't answer to the correct conversation #607

helldog136 opened this issue Nov 13, 2019 · 2 comments
Labels
effort:low Tasks lower than 2 hours to develop

Comments

@helldog136
Copy link

When sending messages across different conversations having the Gladys telegram bot, the bot answers in a private message instead of answering in the conversation. this is due to the message group context id not being saved in the message context.

@helldog136
Copy link
Author

helldog136 commented Nov 14, 2019

I'll add precisions to this rather quicky typed issue:

From node-telegram-bot-api Readme:

// Listen for any kind of message. There are different kinds of
// messages.
bot.on('message', (msg) => {
  const chatId = msg.chat.id;

  // send a message to the chat acknowledging receipt of their message
  bot.sendMessage(chatId, 'Received your message');
});

From Gladys message reception code:

async function newMessage(msg) {
  logger.debug(`new message from telegram, ${msg.text}`);
  logger.debug(msg);
  const telegramUserId = msg.from.id;

  if (msg.text.startsWith('/start')) {
    const splitted = msg.text.split(' ');
    await this.linkUser(splitted[1], telegramUserId);
    return null;
  }
  const user = await this.gladys.user.getByTelegramUserId(telegramUserId);

  const message = {
    source: 'telegram',
    source_user_id: telegramUserId,
    user_id: user.id,
    user,
    language: user.language,
    date: msg.date,
    text: msg.text,
  };
  this.gladys.event.emit(EVENTS.MESSAGE.NEW, message);
  return null;
}

chat by telegram shouldn't be linked to telegram user id (msg.from.id) but telegram chat id (msg.chat.id). Gladys should listen and answer to anyone who talks to her in the correct group chat.

Setup of Telegram Service needs refinement.

  • We need Gladys to know which user in Gladys corresponds to who in Telegram chat

    • This allows Gladys to send personal notifications to its users using Telegram
  • We need Gladys bot to have parallel and independent conversations via Telegram.

    • This allowes Gladys to speak with a "family" group chat in telegram
    • and also to a specific person
    • and also to another Bot (IFTTT Telegram Bot for example)

@Pierre-Gilles
Copy link
Contributor

Agree with this! For now, Telegram integration only work in 1-1, groups are not supported.

@Pierre-Gilles Pierre-Gilles added this to the Gladys 4 RC milestone Mar 22, 2020
@Pierre-Gilles Pierre-Gilles added the effort:low Tasks lower than 2 hours to develop label Jul 27, 2020
NickDub-old pushed a commit to NickDub/Gladys that referenced this issue Aug 7, 2020
* Fix GladysAssistant#730 : Send a message when Telegram integration was configured with success

* Fix GladysAssistant#607 : In Telegram service, use the chat.id to answer to a user, not the from.id

* .gitignore .DS_Store

* Fix telegram tests
R6n0 pushed a commit to R6n0/Gladys that referenced this issue Dec 2, 2020
* Fix GladysAssistant#730 : Send a message when Telegram integration was configured with success

* Fix GladysAssistant#607 : In Telegram service, use the chat.id to answer to a user, not the from.id

* .gitignore .DS_Store

* Fix telegram tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort:low Tasks lower than 2 hours to develop
Projects
None yet
Development

No branches or pull requests

2 participants