Skip to content

Commit 2c4024a

Browse files
committed
fix: don't unwrap when message detection fails
An oversight. If the message detection reports an error or nothing was detected, then simply ignore the message instead of unwrapping and crashing the server.
1 parent 1862f87 commit 2c4024a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/twitch/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,15 @@ async fn handle_message(
157157
msg: ChannelChatMessageV1Payload,
158158
client: &Replier,
159159
) -> Result<()> {
160+
let Ok(Some(content)) = textparse::parse(&msg.message.text, Source::Twitch, None) else {
161+
return Ok(());
162+
};
163+
160164
let response = async {
161165
let message = Message {
162166
span: Span::current(),
163167
source: Source::Twitch,
164-
content: textparse::parse(&msg.message.text, Source::Twitch, None)
165-
.unwrap()
166-
.unwrap(),
168+
content,
167169
author: AuthorId::Twitch(msg.message_id.as_str().to_owned()),
168170
mention: None,
169171
};

0 commit comments

Comments
 (0)