gluon/src/utils/telegram/data_getters.rs

23 lines
759 B
Rust

use telers::{
methods::GetChatAdministrators,
types::{ChatMember, Message},
Bot,
errors::SessionErrorKind
};
use crate::types::structs::{handler_entity::HandlerEntity, message_sender::MessageSender};
pub fn get_chat_data(bot: &Bot, message: &Message) -> (i64, HandlerEntity) {
let (message_id, chat_id): (i64, i64) = (message.id(), message.chat().id());
let sender = MessageSender::builder(chat_id).reply_to(message_id);
let handler_entity: HandlerEntity = HandlerEntity::new(bot.clone(), message.clone(), sender);
(chat_id, handler_entity)
}
#[inline]
pub async fn get_all_admins(bot: &Bot, chat_id: i64) -> Result<Vec<ChatMember>, SessionErrorKind> {
bot.send(GetChatAdministrators::new(chat_id))
.await
}