Import bot::Bot into lib.rs

This commit is contained in:
Temirkhan Myrzamadi 2019-10-18 03:36:13 +06:00
parent 715298c713
commit 6f4bd19382
8 changed files with 27 additions and 33 deletions

View file

@ -8,13 +8,12 @@ use crate::{
SendAnimation, SendAudio, SendChatAction, SendContact, SendDocument,
SendLocation, SendMediaGroup, SendMessage, SendPhoto, SendPoll,
SendVenue, SendVideo, SendVideoNote, SendVoice, SetChatDescription,
SetChatStickerSet, StopMessageLiveLocation, UnbanChatMember,
UnpinChatMessage, SetChatTitle
SetChatStickerSet, SetChatTitle, StopMessageLiveLocation,
UnbanChatMember, UnpinChatMessage,
},
types::{ChatAction, ChatId, ChatPermissions, InputFile, InputMedia},
};
/// Telegram functions
impl Bot {
pub fn get_me(&self) -> GetMe {
GetMe::new(self)
@ -357,11 +356,7 @@ impl Bot {
SendAnimation::new(self, chat_id, animation)
}
pub fn set_chat_title<C, T>(
&self,
chat_id: C,
title: T,
) -> SetChatTitle
pub fn set_chat_title<C, T>(&self, chat_id: C, title: T) -> SetChatTitle
where
C: Into<ChatId>,
T: Into<String>,

View file

@ -19,7 +19,7 @@ impl Bot {
/// use telebofr::types::File as TgFile;
/// use tokio::fs::File;
/// # use telebofr::RequestError;
/// use telebofr::bot::Bot;
/// use telebofr::Bot;
///
/// # async fn run() -> Result<(), Box<dyn std::error::Error>> {
/// let bot = Bot::new("TOKEN");

View file

@ -1,10 +1,9 @@
//! A Telegram bot.
use reqwest::Client;
mod api;
mod download;
/// A Telegram bot used to build requests.
#[derive(Debug, Clone)]
pub struct Bot {
token: String,

View file

@ -32,7 +32,7 @@ type Handlers<'a, T, E> =
///
/// Simplest example:
/// ```no_run
/// # use telebofr::bot::Bot;
/// # use telebofr::Bot;
/// use telebofr::types::Message;
/// async fn run() {
/// use std::convert::Infallible;

View file

@ -5,12 +5,13 @@ extern crate serde;
#[macro_use]
extern crate thiserror;
pub use bot::Bot;
pub use errors::{DownloadError, RequestError};
mod errors;
mod network;
pub mod bot;
mod bot;
pub mod dispatcher;
pub mod requests;
pub mod types;

View file

@ -1,4 +1,4 @@
//! Raw API functions.
//! API requests.
use async_trait::async_trait;
use serde::de::DeserializeOwned;

View file

@ -1,9 +1,11 @@
use async_trait::async_trait;
use crate::bot::Bot;
use crate::types::{ChatId, True};
use crate::requests::{Request, ResponseResult};
use crate::network;
use crate::{
bot::Bot,
network,
requests::{Request, ResponseResult},
types::{ChatId, True},
};
#[derive(Debug, Clone, Serialize)]
pub struct SetChatTitle<'a> {
@ -29,20 +31,17 @@ impl SetChatTitle<'_> {
&self.bot.client(),
&self.bot.token(),
"SetChatTitle",
&self
).await
&self,
)
.await
}
}
impl<'a> SetChatTitle<'a> {
pub(crate) fn new<C, T>(
bot: &'a Bot,
chat_id: C,
title: T
) -> Self
where
C: Into<ChatId>,
T: Into<String>,
pub(crate) fn new<C, T>(bot: &'a Bot, chat_id: C, title: T) -> Self
where
C: Into<ChatId>,
T: Into<String>,
{
Self {
bot,
@ -52,16 +51,16 @@ impl<'a> SetChatTitle<'a> {
}
pub fn chat_id<C>(mut self, chat_id: C) -> Self
where
C: Into<ChatId>,
where
C: Into<ChatId>,
{
self.chat_id = chat_id.into();
self
}
pub fn title<C>(mut self, title: C) -> Self
where
C: Into<String>,
where
C: Into<String>,
{
self.title = title.into();
self

View file

@ -1,4 +1,4 @@
//! Raw API structures.
//! API types.
pub use animation::*;
pub use audio::*;