@@ -11,53 +11,53 @@ import (
1111// called once from New. Update-conversion failures are logged and swallowed so
1212// a single bad update never tears down the update stream.
1313func (b * Bot ) installHandlers () {
14- b .disp .OnNewMessage (func (ctx context.Context , _ tg.Entities , u * tg.UpdateNewMessage ) error {
15- b .dispatchMessage (ctx , u .Message , false )
14+ b .disp .OnNewMessage (func (ctx context.Context , e tg.Entities , u * tg.UpdateNewMessage ) error {
15+ b .dispatchMessage (ctx , e , u .Message , false )
1616
1717 return nil
1818 })
19- b .disp .OnEditMessage (func (ctx context.Context , _ tg.Entities , u * tg.UpdateEditMessage ) error {
20- b .dispatchMessage (ctx , u .Message , true )
19+ b .disp .OnEditMessage (func (ctx context.Context , e tg.Entities , u * tg.UpdateEditMessage ) error {
20+ b .dispatchMessage (ctx , e , u .Message , true )
2121
2222 return nil
2323 })
24- b .disp .OnNewChannelMessage (func (ctx context.Context , _ tg.Entities , u * tg.UpdateNewChannelMessage ) error {
25- b .dispatchMessage (ctx , u .Message , false )
24+ b .disp .OnNewChannelMessage (func (ctx context.Context , e tg.Entities , u * tg.UpdateNewChannelMessage ) error {
25+ b .dispatchMessage (ctx , e , u .Message , false )
2626
2727 return nil
2828 })
29- b .disp .OnEditChannelMessage (func (ctx context.Context , _ tg.Entities , u * tg.UpdateEditChannelMessage ) error {
30- b .dispatchMessage (ctx , u .Message , true )
29+ b .disp .OnEditChannelMessage (func (ctx context.Context , e tg.Entities , u * tg.UpdateEditChannelMessage ) error {
30+ b .dispatchMessage (ctx , e , u .Message , true )
3131
3232 return nil
3333 })
3434 b .disp .OnBotCallbackQuery (func (ctx context.Context , e tg.Entities , u * tg.UpdateBotCallbackQuery ) error {
35- b .route (ctx , & Update {CallbackQuery : callbackQueryFromTg (e , u )})
35+ b .route (ctx , & Update {CallbackQuery : callbackQueryFromTg (e , u ), Entities : e })
3636
3737 return nil
3838 })
3939 b .disp .OnBotInlineQuery (func (ctx context.Context , e tg.Entities , u * tg.UpdateBotInlineQuery ) error {
40- b .route (ctx , & Update {InlineQuery : inlineQueryFromTg (e , u )})
40+ b .route (ctx , & Update {InlineQuery : inlineQueryFromTg (e , u ), Entities : e })
4141
4242 return nil
4343 })
4444 b .disp .OnBotInlineSend (func (ctx context.Context , e tg.Entities , u * tg.UpdateBotInlineSend ) error {
45- b .route (ctx , & Update {ChosenInlineResult : chosenInlineResultFromTg (e , u )})
45+ b .route (ctx , & Update {ChosenInlineResult : chosenInlineResultFromTg (e , u ), Entities : e })
4646
4747 return nil
4848 })
4949 b .disp .OnInlineBotCallbackQuery (func (ctx context.Context , e tg.Entities , u * tg.UpdateInlineBotCallbackQuery ) error {
50- b .route (ctx , & Update {CallbackQuery : inlineCallbackQueryFromTg (e , u )})
50+ b .route (ctx , & Update {CallbackQuery : inlineCallbackQueryFromTg (e , u ), Entities : e })
5151
5252 return nil
5353 })
5454 b .disp .OnBotShippingQuery (func (ctx context.Context , e tg.Entities , u * tg.UpdateBotShippingQuery ) error {
55- b .route (ctx , & Update {ShippingQuery : shippingQueryFromTg (e , u )})
55+ b .route (ctx , & Update {ShippingQuery : shippingQueryFromTg (e , u ), Entities : e })
5656
5757 return nil
5858 })
5959 b .disp .OnBotPrecheckoutQuery (func (ctx context.Context , e tg.Entities , u * tg.UpdateBotPrecheckoutQuery ) error {
60- b .route (ctx , & Update {PreCheckoutQuery : preCheckoutQueryFromTg (e , u )})
60+ b .route (ctx , & Update {PreCheckoutQuery : preCheckoutQueryFromTg (e , u ), Entities : e })
6161
6262 return nil
6363 })
@@ -67,7 +67,7 @@ func (b *Bot) installHandlers() {
6767// dispatchMessage converts a message and routes it as the appropriate update
6868// field. Channel-broadcast messages become channel posts; everything else is a
6969// regular message. edited selects the edited_* fields.
70- func (b * Bot ) dispatchMessage (ctx context.Context , msg tg.MessageClass , edited bool ) {
70+ func (b * Bot ) dispatchMessage (ctx context.Context , e tg. Entities , msg tg.MessageClass , edited bool ) {
7171 // Drop the bot's own outgoing messages. MTProto echoes them back on the
7272 // update stream, but the HTTP Bot API never delivers them — without this a
7373 // bot that replies to messages would answer its own replies in a loop.
@@ -88,6 +88,8 @@ func (b *Bot) dispatchMessage(ctx context.Context, msg tg.MessageClass, edited b
8888
8989 u := & Update {}
9090
91+ u .Entities = e
92+
9193 switch {
9294 case m .Chat .Type == ChatTypeChannel && edited :
9395 u .EditedChannelPost = m
0 commit comments