@@ -179,12 +179,12 @@ func mainMenuHandler(b *gotgbot.Bot, ctx *ext.Context) error {
179179func showPriceagentDetail (b * gotgbot.Bot , ctx * ext.Context ) error {
180180 cb := ctx .Update .CallbackQuery
181181
182- priceagentID , parseErr := parseIDFromCallbackData (cb .Data , "m03_00_" )
182+ menu , parseErr := models . NewMenu (cb .Data )
183183 if parseErr != nil {
184- return fmt .Errorf ("showPriceagentDetail: failed to parse priceagentID from callback data: %w" , parseErr )
184+ return fmt .Errorf ("showPriceagentDetail: failed to parse callback data: %w" , parseErr )
185185 }
186186
187- priceagent , dbErr := database .GetPriceagentForUserByID (ctx .EffectiveUser .Id , priceagentID )
187+ priceagent , dbErr := database .GetPriceagentForUserByID (ctx .EffectiveUser .Id , menu . PriceAgent )
188188 if dbErr != nil {
189189 return fmt .Errorf ("showPriceagentDetail: failed to get priceagent from database: %w" , dbErr )
190190 }
@@ -220,21 +220,25 @@ func showPriceagentDetail(b *gotgbot.Bot, ctx *ext.Context) error {
220220 },
221221 }
222222
223- // Check if the initial message contained a photo, if yes, we're coming from the price history graph
224- if len (cb .Message .Photo ) > 0 {
223+ switch menu .SubMenu {
224+ case "00" :
225+ _ , err := cb .Message .EditText (b , editedText , & gotgbot.EditMessageTextOpts {ReplyMarkup : markup , ParseMode : "HTML" })
226+ if err != nil {
227+ return fmt .Errorf ("showPriceagent: failed to edit message text: %w" , err )
228+ }
229+ case "01" :
225230 bot .DeleteMessage (ctx .EffectiveChat .Id , cb .Message .MessageId )
226231
227232 _ , err := b .SendMessage (ctx .EffectiveChat .Id , editedText , & gotgbot.SendMessageOpts {ReplyMarkup : markup , ParseMode : "HTML" })
228233 if err != nil {
229234 return fmt .Errorf ("showPriceagent: failed to send new message: %w" , err )
230235 }
231- } else {
232- _ , err := cb . Message . EditText ( b , editedText , & gotgbot.EditMessageTextOpts {ReplyMarkup : markup , ParseMode : "HTML" })
236+ case "02" :
237+ _ , err := b . SendMessage ( ctx . EffectiveChat . Id , editedText , & gotgbot.SendMessageOpts {ReplyMarkup : markup , ParseMode : "HTML" })
233238 if err != nil {
234- return fmt .Errorf ("showPriceagent: failed to edit message text : %w" , err )
239+ return fmt .Errorf ("showPriceagent: failed to send new message : %w" , err )
235240 }
236241 }
237-
238242 return nil
239243}
240244
@@ -410,7 +414,7 @@ func addMessageHandlers(dispatcher *ext.Dispatcher) {
410414 dispatcher .AddHandler (handlers .NewCallback (callbackquery .Prefix ("m04_02_" ), setNotificationBelowHandler ))
411415 dispatcher .AddHandler (handlers .NewCallback (callbackquery .Prefix ("m04_01_" ), setNotificationAlwaysHandler ))
412416 dispatcher .AddHandler (handlers .NewCallback (callbackquery .Prefix ("m04_00_" ), changePriceagentSettingsHandler ))
413- dispatcher .AddHandler (handlers .NewCallback (callbackquery .Prefix ("m03_00_ " ), showPriceagentDetail ))
417+ dispatcher .AddHandler (handlers .NewCallback (callbackquery .Prefix ("m03_ " ), showPriceagentDetail ))
414418 dispatcher .AddHandler (handlers .NewCallback (callbackquery .Equal ("m02_00" ), showWishlistPriceagents ))
415419 dispatcher .AddHandler (handlers .NewCallback (callbackquery .Equal ("m02_01" ), showProductPriceagents ))
416420 dispatcher .AddHandler (handlers .NewCallback (callbackquery .Equal ("m01_01" ), viewPriceagentsHandler ))
0 commit comments