telegram-bot-sdk icon indicating copy to clipboard operation
telegram-bot-sdk copied to clipboard

Emit a new UpdateEvent

Open alies-dev opened this issue 1 year ago • 0 comments

UpdateEvent event back-ported from SDK v4.

Differences with SDKv4 events:

  • event from SDKv4 has public Bot $bot, in current PR it's public Api $telegram;. Reason -- there is no Bot class in SDK v3.
  • in this PR this event extends \League\Event\AbstractEvent (because we use league/event events system here), in SDK v4 it doesn't extend any classes.
  • this PR has better test than in SDK v4 :)

Challenges

SDK v3 has a weird feature, I don't know a reason why we have it. This is $shouldEmitEvent parameter:

// in Update.php trait
public function getWebhookUpdate($shouldEmitEvent = true, ...

I decided to not touch it, always emit a new event and keep emitting the old one UpdateWasReceived depends on $shouldEmitEvent argument's value. Reason - it provides more consistency with SDK v4.

alies-dev avatar Aug 09 '22 22:08 alies-dev

Thank you 👍

irazasyed avatar Aug 20 '22 19:08 irazasyed