1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//! # VTG - dual-platform bots library
//!
//! VTG is a fully functional library for creating bots for both VK and Telegram. Presents unified context and methods, for comfortable work with dual-platform bots.
//!
//! ## Features
//! - Support callback and longpoll updates
//! - 90% VK and TG API coverage (messages)
//! - Unified context for both platforms
//! - Unified context methods for both platforms
//! - Unified attachments and file uploads for both platforms
//! - Unified keyboard for both platforms
//! - Easy to use
//! - Easy to understand
//! - Easy to contribute
//!
//! ## Usage
//!
//! Example using longpoll client:
//!```
//!use std::env;
//!
//!use vtg::{
//!    client::start_longpoll_client,
//!    structs::{
//!        config::Config,
//!        context::UnifyedContext,
//!        middleware::MiddlewareChain,
//!    },
//!};
//!
//!async fn catch_new_message(ctx: UnifyedContext) -> UnifyedContext {
//!    ctx
//!}
//!
//!#[tokio::main]
//!async fn main() {
//!    let config = Config {
//!        vk_access_token: env::var("VK_ACCESS_TOKEN").unwrap(),
//!        vk_group_id: env::var("VK_GROUP_ID").unwrap().parse().unwrap(),
//!        tg_access_token: env::var("TG_ACCESS_TOKEN").unwrap(), // token stats with bot, like: bot1234567890:ABCDEFGHIJKL
//!        ..Default::default()
//!    };
//!
//!    let mut middleware_chain = MiddlewareChain::new();
//!    middleware_chain.add_middleware(|ctx| Box::pin(catch_new_message(ctx)));
//!
//!    start_longpoll_client(middleware_chain, config).await;
//!}
//!```
//!
//! Example using callback server:
//!```
//!use std::env;
//!
//!use vtg::{
//!    server::start_callback_server,
//!    structs::{
//!        config::{CallbackSettings, Config},
//!        context::UnifyedContext,
//!        middleware::MiddlewareChain,
//!    },
//!};
//!
//!async fn catch_new_message(ctx: UnifyedContext) -> UnifyedContext {
//!    ctx
//!}
//!
//!#[tokio::main]
//!async fn main() {
//!    let config = Config {
//!        vk_access_token: env::var("VK_ACCESS_TOKEN").unwrap(),
//!        vk_group_id: env::var("VK_GROUP_ID").unwrap().parse().unwrap(),
//!        tg_access_token: env::var("TG_ACCESS_TOKEN").unwrap(), // token stats with bot, like: bot1234567890:ABCDEFGHIJKL
//!        vk_api_version: "5.199".to_owned(),
//!        callback: Some(CallbackSettings {
//!            port: 1234,
//!            callback_url: "https://valnesfjord.com".to_string(),
//!            secret: "secret".to_string(),
//!            path: "yourcallbacksecretpathwithoutslashinstartandend".to_string(),
//!        }),
//!    };
//!
//!    let mut middleware_chain = MiddlewareChain::new();
//!    middleware_chain.add_middleware(|ctx| Box::pin(catch_new_message(ctx)));
//!
//!    start_callback_server(middleware_chain, config).await;
//!}
//!```
//!
//! ## Context
//! Context is a struct that contains all the information about the event that happened in the chat
//!
//! You can see context documentation [here](structs/context/struct.UnifyedContext.html)
//!
//! ## Examples
//! You can find example bot in the examples folder
//!
//! ## It's not finished yet:
//!
//! - [ ] Add more tests
//! - [ ] Add more examples
//! - [ ] Add VK and TG API documentation
//! - [ ] Add more features (like more API coverage, etc)

/// Longpoll client for getting updates from VK and Telegram
///
/// This module contains function for getting updates from VK and Telegram
pub mod client;

/// Module for keyboard creation
///
/// This module contains function for creating keyboards for VK and Telegram
pub mod keyboard;

/// Module for callback (webhook) server for getting updates from VK and Telegram
///
/// This module contains function for starting callback server
pub mod server;
#[cfg(test)]
mod tests;

/// Module for all the structures used in the library
///
/// This module contains all the structures used in the library
pub mod structs;

/// Module for all the functions for working with uploads
///
/// This module contains all the functions for working with uploads
pub mod upload;