tucnak / telebot

Telebot is a Telegram bot framework in Go.
MIT License
3.95k stars 461 forks source link

Added forward handler #697

Closed nikepan closed 1 month ago

nikepan commented 3 months ago

Resolve #696

nikepan commented 1 month ago

Here ok? https://github.com/tucnak/telebot/blob/350ac26ac84216662c19baea128c18fecbc0eb84/update.go#L68

demget commented 1 month ago

Here ok?

https://github.com/tucnak/telebot/blob/350ac26ac84216662c19baea128c18fecbc0eb84/update.go#L68

Yes

nikepan commented 1 month ago

I made some tests again. text="" if it forward from channel. if it from chat, text is original and trigger text events. I tested reply event. It works fine.

demget commented 1 month ago

I made some tests again. text="" if it forward from channel. if it from chat, text is original and trigger text events. I tested reply event. It works fine.

Then you should move the m.Origin check before the m.Text check. Complete this and I'll merge your PR into v3.4.

nikepan commented 1 month ago

I think this action will create a backwards incompatibility for applications that recognise forwarding from chats now as a normal message

demget commented 1 month ago

I think this action will create a backwards incompatibility for applications that recognise forwarding from chats now as a normal message

Oh yeah, you're definitely right. We should check somehow if there is OnForward or OnReply handler registered, before trying to execute them, if not, the bot should follow the usual OnText flow.

Do you think you can implement it in a separate PR?

nikepan commented 1 month ago

I don't think that's a good idea. Because it violates the text filters. I took another look. The current version doesn't break anything if there is no OnForward handler. But if there is one, 2 events are triggered. I think the most correct thing would be to move the check down. Then it will be possible to catch the event if text filters are not triggered, which I believe should be a priority.