coredump-ch / flamebot

The most polite chatbot you’ve ever seen.
ISC License
3 stars 2 forks source link

Insult joiners #10

Closed rnestler closed 8 years ago

rnestler commented 8 years ago

Currently the bot doesn't insult the person that joins but the person that invited the other. I think this is wrong, the new person should get insulted :wink:

rnestler commented 8 years ago

This is the message that one receives:

{ message_id: 233,
  from: { id: 123456, first_name: 'Inviter' },
  chat: { id: -12345, title: 'FlameBotTestChat', type: 'group' },
  date: 1448628945,
  new_chat_participant: 
   { id: 12707489,
     first_name: 'NewPerson',
     username: 'new_person' } }
netzhuffle commented 8 years ago

Are you sure? The bot responds to the inviting message but it should use the name of message.new_chat_participant instead of message.from: https://github.com/coredump-ch/telegram-flame-bot/blob/3d41aa09de3fab330441aa1dbe34a3097dc78946/bot.js#L68

rnestler commented 8 years ago

It may use the name if it is contained in the insult, but it replies to the old user:

  replyText(getInsult(message, message.new_chat_participant), message);
  function replyText(text, message) {
    bot.sendMessage(message.chat.id, text, {'reply_to_message_id': message.message_id});
  }

replyText answers to the sender of message

netzhuffle commented 8 years ago

It replies to the entry message, which technically has the old user as the sender. There is no other message to reply to and a message without replying would look out of context.

Of course you could do an own list with “entry insults”, each with the new user name, but the current behavior is as intended.

netzhuffle commented 8 years ago

Fixed with #11 – the messages now contain the name, so it’s clear who was insulted.