mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Fix
This commit is contained in:
@@ -12,7 +12,7 @@ enum SupportCommand {
|
||||
Support,
|
||||
}
|
||||
|
||||
pub async fn support_command_handler(message: Message, bot: Bot) -> BotHandlerInternal {
|
||||
pub async fn support_command_handler(message: Message, bot: Throttle<Bot>) -> BotHandlerInternal {
|
||||
const MESSAGE_TEXT: &str = "
|
||||
[Лицензии](https://github.com/flibusta-apps/book_bot/blob/main/LICENSE.md)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ use regex::Regex;
|
||||
use teloxide::{
|
||||
prelude::*,
|
||||
types::{InlineKeyboardButton, InlineKeyboardMarkup},
|
||||
utils::command::BotCommands,
|
||||
utils::command::BotCommands, adaptors::Throttle,
|
||||
};
|
||||
|
||||
use super::utils::{generic_get_pagination_keyboard, GetPaginationCallbackData};
|
||||
@@ -77,7 +77,7 @@ impl GetPaginationCallbackData for UpdateLogCallbackData {
|
||||
}
|
||||
}
|
||||
|
||||
async fn update_log_command(message: Message, bot: Bot) -> BotHandlerInternal {
|
||||
async fn update_log_command(message: Message, bot: Throttle<Bot>) -> BotHandlerInternal {
|
||||
let now = Utc::now().date_naive();
|
||||
let d3 = now - Duration::days(3);
|
||||
let d7 = now - Duration::days(7);
|
||||
@@ -134,7 +134,7 @@ async fn update_log_command(message: Message, bot: Bot) -> BotHandlerInternal {
|
||||
|
||||
async fn update_log_pagination_handler(
|
||||
cq: CallbackQuery,
|
||||
bot: Bot,
|
||||
bot: Throttle<Bot>,
|
||||
update_callback_data: UpdateLogCallbackData,
|
||||
) -> BotHandlerInternal {
|
||||
let message = match cq.message {
|
||||
@@ -223,7 +223,7 @@ pub fn get_update_log_handler() -> crate::bots::BotHandler {
|
||||
.chain(filter_callback_query::<UpdateLogCallbackData>())
|
||||
.endpoint(
|
||||
|cq: CallbackQuery,
|
||||
bot: Bot,
|
||||
bot: Throttle<Bot>,
|
||||
update_log_data: UpdateLogCallbackData| async move {
|
||||
update_log_pagination_handler(cq, bot, update_log_data).await
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use teloxide::prelude::*;
|
||||
use teloxide::{prelude::*, adaptors::Throttle};
|
||||
|
||||
use std::error::Error;
|
||||
|
||||
@@ -10,7 +10,7 @@ pub mod utils;
|
||||
|
||||
pub async fn message_handler(
|
||||
message: Message,
|
||||
bot: Bot,
|
||||
bot: Throttle<Bot>,
|
||||
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
let from_user = message.from().unwrap();
|
||||
let text = message.text().unwrap_or("");
|
||||
|
||||
@@ -3,7 +3,7 @@ pub mod bots_manager;
|
||||
|
||||
use std::error::Error;
|
||||
|
||||
use teloxide::prelude::*;
|
||||
use teloxide::{prelude::*, adaptors::Throttle};
|
||||
|
||||
pub type BotHandlerInternal = Result<(), Box<dyn Error + Send + Sync>>;
|
||||
|
||||
@@ -27,7 +27,7 @@ fn ignore_chat_member_update() -> crate::bots::BotHandler {
|
||||
}
|
||||
|
||||
fn get_pending_handler() -> BotHandler {
|
||||
let handler = |msg: Message, bot: Bot| async move {
|
||||
let handler = |msg: Message, bot: Throttle<Bot>| async move {
|
||||
let message_text = "
|
||||
Бот зарегистрирован, но не подтвержден администратором! \
|
||||
Подтверждение занимает примерно 12 часов.
|
||||
@@ -44,7 +44,7 @@ fn get_pending_handler() -> BotHandler {
|
||||
}
|
||||
|
||||
fn get_blocked_handler() -> BotHandler {
|
||||
let handler = |msg: Message, bot: Bot| async move {
|
||||
let handler = |msg: Message, bot: Throttle<Bot>| async move {
|
||||
let message_text = "Бот заблокирован!";
|
||||
|
||||
bot.send_message(msg.chat.id, message_text).await?;
|
||||
|
||||
@@ -76,9 +76,9 @@ impl BotsManager {
|
||||
async fn start_bot(&mut self, bot_data: &BotData) -> bool {
|
||||
let bot = Bot::new(bot_data.token.clone())
|
||||
.set_api_url(config::CONFIG.telegram_bot_api.clone())
|
||||
// .throttle(Limits::default());
|
||||
.throttle(Limits::default());
|
||||
|
||||
let token = bot.token();
|
||||
let token = bot.inner().token();
|
||||
let port = self.bot_port_map
|
||||
.get(&bot_data.id)
|
||||
.unwrap_or_else(|| panic!("Can't get bot port!"));
|
||||
|
||||
Reference in New Issue
Block a user