diff --git a/.cargo/config.toml b/.cargo/config.toml index c18cb00..7f8c829 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,2 @@ [env] -TDLIB_COMMIT_HASH = "cb164927417f22811c74cd8678ed4a5ab7cb80ba" +TDLIB_COMMIT_HASH = "d321984b75fccdb76239529e8aadcf7f80b0e35a" diff --git a/docker-compose.yml b/docker-compose.yml index 84f6fb8..e72dcc6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ services: craiyon-bot: build: . environment: - TDLIB_COMMIT_HASH: cb164927417f22811c74cd8678ed4a5ab7cb80ba + TDLIB_COMMIT_HASH: d321984b75fccdb76239529e8aadcf7f80b0e35a USER_AGENT: TELEGRAM_TOKEN: API_ID: diff --git a/src/apis/makersuite.rs b/src/apis/makersuite.rs index 26a03b7..f6e22da 100644 --- a/src/apis/makersuite.rs +++ b/src/apis/makersuite.rs @@ -169,7 +169,7 @@ pub struct GenerateContentResponse { #[serde(rename_all = "camelCase")] pub struct Candidate { pub content: Option, - pub finish_reason: String, + pub finish_reason: Option, pub citation_metadata: Option, } diff --git a/src/commands/makersuite.rs b/src/commands/makersuite.rs index a6d8e53..c40b45f 100644 --- a/src/commands/makersuite.rs +++ b/src/commands/makersuite.rs @@ -255,7 +255,7 @@ impl CommandTrait for GooglePalm { struct GenerationProgress { parts: Vec, - finish_reason: String, + finish_reason: Option, citation_sources: Vec, } @@ -326,8 +326,10 @@ impl GenerationProgress { text.push('…'); } - if self.finish_reason != "STOP" { - write!(text, " [{}]", self.finish_reason).unwrap(); + if let Some(finish_reason) = self.finish_reason.as_ref() { + if finish_reason != "STOP" { + write!(text, " [finish reason: {finish_reason}]").unwrap(); + } } if !self.citation_sources.is_empty() { diff --git a/src/utilities/telegram_utils.rs b/src/utilities/telegram_utils.rs index df338e8..b2eee78 100644 --- a/src/utilities/telegram_utils.rs +++ b/src/utilities/telegram_utils.rs @@ -34,7 +34,7 @@ pub enum MessageAttachment<'a> { Video(Cow<'a, Video>), VideoNote(Cow<'a, VideoNote>), VoiceNote(Cow<'a, VoiceNote>), - Story(Cow<'a, StoryContent>), + Story(Box>), ChatChangePhoto(Cow<'a, ChatPhoto>), } @@ -49,7 +49,7 @@ impl MessageAttachment<'_> { Self::Video(video) => &video.video, Self::VideoNote(video_note) => &video_note.video, Self::VoiceNote(voice_note) => &voice_note.voice, - Self::Story(story) => match story.borrow() { + Self::Story(story) => match story.as_ref().borrow() { enums::StoryContent::Photo(photo) => largest_photo(&photo.photo.sizes).unwrap(), enums::StoryContent::Video(video) => &video.video.video, enums::StoryContent::Unsupported => { @@ -78,7 +78,7 @@ impl MessageAttachment<'_> { Self::Video(video) => &video.mime_type, Self::VideoNote(_) => "video/mp4", Self::VoiceNote(voice_note) => &voice_note.mime_type, - Self::Story(story) => match story.borrow() { + Self::Story(story) => match story.as_ref().borrow() { enums::StoryContent::Photo(_) => "image/jpeg", enums::StoryContent::Video(_) => "video/mp4", enums::StoryContent::Unsupported => { @@ -154,10 +154,10 @@ pub async fn get_message_attachment( match story.content { enums::StoryContent::Photo(_) => { - MessageAttachment::Story(Cow::Owned(story.content)) + MessageAttachment::Story(Box::new(Cow::Owned(story.content))) } enums::StoryContent::Video(_) if not_only_images => { - MessageAttachment::Story(Cow::Owned(story.content)) + MessageAttachment::Story(Box::new(Cow::Owned(story.content))) } _ => return Ok(None), } @@ -207,10 +207,10 @@ pub async fn get_message_attachment( match story.content { enums::StoryContent::Photo(_) => { - MessageAttachment::Story(Cow::Owned(story.content)) + MessageAttachment::Story(Box::new(Cow::Owned(story.content))) } enums::StoryContent::Video(_) if not_only_images => { - MessageAttachment::Story(Cow::Owned(story.content)) + MessageAttachment::Story(Box::new(Cow::Owned(story.content))) } _ => return Ok(None), } @@ -281,7 +281,7 @@ pub fn log_status_update(update: &UpdateChatMember, chat: &CompactChat) { } let status = match update.new_chat_member.status { - ChatMemberStatus::Member => "joined", + ChatMemberStatus::Member(_) => "joined", ChatMemberStatus::Left => "left", _ => return, }; diff --git a/src/utilities/test_fixtures.rs b/src/utilities/test_fixtures.rs index dbc0cf4..08eb334 100644 --- a/src/utilities/test_fixtures.rs +++ b/src/utilities/test_fixtures.rs @@ -36,19 +36,7 @@ pub fn command_context() -> CommandContext { is_outgoing: false, is_pinned: false, is_from_offline: false, - can_be_edited: false, - can_be_forwarded: false, - can_be_replied_in_another_chat: false, can_be_saved: false, - can_be_deleted_only_for_self: false, - can_be_deleted_for_all_users: false, - can_get_added_reactions: false, - can_get_statistics: false, - can_get_message_thread: false, - can_get_read_date: false, - can_get_viewers: false, - can_get_media_timestamp_links: false, - can_report_reactions: false, has_timestamped_media: false, is_channel_post: false, is_topic_message: false, @@ -72,6 +60,7 @@ pub fn command_context() -> CommandContext { author_signature: "message_author_signature".into(), media_album_id: 0, effect_id: 0, + has_sensitive_content: false, restriction_reason: "message_restriction_reason".into(), content: MessageContent::MessageText(MessageText { text: FormattedText { text: "message_content_text".into(), ..Default::default() },