shurillu / CTBot

A simple (and easy to use) Arduino Telegram BOT Library for ESP8266/ESP32
MIT License
147 stars 34 forks source link

How to get messages form group where is bot is #41

Closed 1UnkMan3 closed 4 years ago

1UnkMan3 commented 4 years ago

I try to teach bot answer on messages from one group try this if (msg.sender.id == -Idgroud){ Serial.println("yes"); Can you please help me?

shurillu commented 4 years ago

Hi 1UnkMan3, you are using the sender ID, so it always answer to the sender, not the group. Try to use msg.group.id instead: msg.group.id store the group ID (if any) or the sender ID (if there is no group). Let me know if this answer your question. Cheers,

Stefano

1UnkMan3 commented 4 years ago

Hello shurillu is cod now works if (myBot.getNewMessage(msg)) { if (msg.group.id == -xxxxxxxxxxxxx){ Serial.println("yes"); } } Works but you need to Talk to @botfather and disable the privacy mode =) And add bot to the group again after this

By the way thank you to the author for the Library