Skip to content

Commit 045ef47

Browse files
authored
Log warning for unknown update types instead of NRE (#94)
Updates like chat_member have EditedOrMessage as null, causing NRE. Now we check for EditedOrMessage before processing and log a warning for unknown update types.
1 parent 3a2e076 commit 045ef47

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/VahterBanBot/Bot.fs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,10 @@ let onUpdate
879879
do! onCallback botClient botConfig logger update.CallbackQuery
880880
elif update.MessageReaction <> null then
881881
onMessageReaction logger update.MessageReaction
882-
else
882+
elif update.EditedOrMessage <> null then
883883
do! tryEnrichMessageWithOcr botClient botConfig computerVision logger update
884884
do! onMessage botUser botClient botConfig logger ml update.EditedOrMessage
885+
else
886+
// unknown update type, just log and ignore
887+
logger.LogWarning("Unknown update type: {UpdateType}", update.Type)
885888
}

0 commit comments

Comments
 (0)