jehy / telegram-test-api

Simple implimentation of telegram API which can be used for testing telegram bots
MIT License
98 stars 24 forks source link

sendMessage doesn't send options correctly #39

Open mbogomazov opened 3 years ago

mbogomazov commented 3 years ago

Try to send this message to a bot(Telegraf.js library)

message = client.makeMessage('@testuser1', options={
    entities: [{
        type: 'mention',
        offset: 0,
        length: 9
    }]
});
await client.sendMessage(message);

but bot receive only

{ message_id: 11,
  from: { id: 1, first_name: 'TestName', username: 'testUserName' },
  chat:
   { id: 1,
     title: 'Test Name',
     first_name: 'TestName',
     username: 'testUserName',
     type: 'private' },
  date: 1610304898,
  text: '@testuser1' }

(without entities). I also tried to send location but bot didn't get too. How to fix it? Or maybe I should use another method or parameters?

jehy commented 3 years ago

Right now many of specific telegram features like mentions, pictures, stickers, polls and so on - are not supported. Just basic messaging. But adding it is pretty simple - PRs welcome!

mbogomazov commented 3 years ago

Okay, I'm ready to implement it but I can't understand, why bot doesn't get all options which I sent because in makeMessage function there should be all of them(due to merge function)

makeMessage(messageText, options = {}) {
    return merge({
      botToken: this.botToken,
      from: {id: this.userId, first_name: this.firstName, username: this.userName},
      chat: {
        id: this.chatId,
        title: this.chatTitle,
        first_name: this.firstName,
        username: this.userName,
        type: this.type,
      },
      date: Math.floor(Date.now() / 1000),
      text: messageText,
    }, options);
  }

So in which modules I should add handlers of different options(i.e. for entities, files, location)?