Compare commits

..

No commits in common. "655e195c91342623e3edd5476c13a022b1f70324" and "c84385bc68fb62de634e7353e8461656a0745aca" have entirely different histories.

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

View file

@ -29,7 +29,7 @@ pub async fn inline(bot: Bot, q: CallbackQuery, state: Arc<AppState>, uid: Strin
if let Some(data) = q.clone().data { if let Some(data) = q.clone().data {
let text= if &data == "yes" { let text= if &data == "yes" {
if let Ok(uid) = uid.parse::<u64>() { if let Ok(uid) = uid.parse::<u64>() {
if Entity::delete_by_id(uid as i64).exec(&state.db).await?.rows_affected != 0 { if Entity::delete_by_id(uid as i32).exec(&state.db).await?.rows_affected != 0 {
"Модератор удалён!" "Модератор удалён!"
} else { } else {
"Произошла ошибка!\nПо всей видимости такого модератора не существует." "Произошла ошибка!\nПо всей видимости такого модератора не существует."

View file

@ -8,7 +8,7 @@ use crate::AppState;
/// Invert notify status for moderator /// Invert notify status for moderator
pub async fn command(bot: Bot, msg: Message, uid: UserId, state: Arc<AppState>) -> anyhow::Result<()> { pub async fn command(bot: Bot, msg: Message, uid: UserId, state: Arc<AppState>) -> anyhow::Result<()> {
let text = if let Some(moder) = moderators::Entity::find_by_id(uid.0 as i64).one(&state.db).await? { let text = if let Some(moder) = moderators::Entity::find_by_id(uid.0 as i32).one(&state.db).await? {
let moder = match moder.notify { let moder = match moder.notify {
true => { true => {
let mut moder = moder.into_active_model(); let mut moder = moder.into_active_model();

View file

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