fix i32 uid in check_rights

This commit is contained in:
Shiroyasha 2025-01-28 21:30:25 +03:00
parent c84385bc68
commit 3132ebd036
Signed by: shiroyashik
GPG key ID: E4953D3940D7860A
2 changed files with 5 additions and 4 deletions

View file

@ -10,7 +10,7 @@ use crate::{check_subscription, markup, notify, AppState, DialogueState, MyDialo
pub async fn message(bot: Bot, msg: Message, dialogue: MyDialogue) -> anyhow::Result<()> {
use youtube::*;
if let Some(text) = msg.clone().text() {
if let Some(user) = check_subscription(&bot, &msg.from.ok_or(anyhow::anyhow!("Message not from user!"))?.id).await {
if let Some(user) = check_subscription(&bot, &msg.clone().from.ok_or(anyhow::anyhow!("Message not from user!"))?.id).await {
// Get ready!
if let Some(ytid) = extract_youtube_video_id(text) {
let meta = get_video_metadata(&ytid).await?;
@ -21,6 +21,7 @@ pub async fn message(bot: Bot, msg: Message, dialogue: MyDialogue) -> anyhow::Re
)).parse_mode(ParseMode::Html).reply_markup(markup::inline_yes_or_no()).await?;
dialogue.update(DialogueState::AcceptVideo { ytid, uid: user.id.0, title: meta.title }).await?;
} else {
tracing::debug!("Not a YouTube video: {:?}", msg);
bot.send_message(msg.chat.id, "Это не похоже на YouTube видео... Долбоёб").await?;
}
} else {

View file

@ -93,7 +93,7 @@ async fn main() -> anyhow::Result<()> {
// Pass the shared state to the handler as a dependency.
.dependencies(dptree::deps![state, InMemStorage::<DialogueState>::new()])
.default_handler(|upd| async move {
tracing::warn!("Unhandled update: {:?}", upd);
tracing::debug!("Unhandled update: {:?}", upd);
})
.enable_ctrlc_handler()
.build()
@ -184,7 +184,7 @@ impl AppState {
async fn check_rights(&self, uid: &UserId) -> anyhow::Result<Rights> {
use database::moderators::Entity as Moderators;
Ok(if let Some(moder) = Moderators::find_by_id(uid.0 as i32).one(&self.db).await? {
Ok(if let Some(moder) = Moderators::find_by_id(uid.0 as i64).one(&self.db).await? {
Rights::Moderator { can_add_mods: moder.can_add_mods }
} else {
Rights::None