@ChanM 4.3

In part 2 we added /id but we need to fix the problem if the user doesnt have a username.

So we do it like this:

bot.on(['/id'], (msg, self) => {
  let id = msg.chat.id;
  let replyToMessage = msg.message_id;
  let username = msg.chat.username;
  let type = self.type;
  let parseMode = 'markdown';

  if (username != 'undefined') {
    return bot.sendMessage(id, `Chat ID: \`${id}\`
Message ID: \`${replyToMessage}\`
username: @${username}
t.me link: t.me/${username}
telegram link: [${msg.from.first_name}](tg://user?id=${ id })`, {replyToMessage, parseMode});
  } else {
    return bot.sendMessage(id, `Chat ID: \`${ id }\`
Message ID: \`${replyToMessage}\`
telegram link: [${msg.from.first_name}](tg://user?id=${ id })`, {replyToMessage, parseMode});
  }
});

2 Replies to “@ChanM 4.3”

Leave a Reply

Your email address will not be published. Required fields are marked *