pub struct SafeVkBot { /* private fields */ }Implementations§
Source§impl SafeVkBot
impl SafeVkBot
Sourcepub fn create(token: &str) -> Self
pub fn create(token: &str) -> Self
Creates a new instance for SafeVkBot
Examples found in repository?
examples/members.rs (line 21)
13async fn main() {
14 let group_id: u32 = env::var("GROUP_ID")
15 .unwrap_or_else(|_| "0".into())
16 .parse()
17 .expect("GROUP_ID must be a valid u32");
18
19 let token = env::var("TOKEN").expect("TOKEN environment variable not set");
20
21 let bot = SafeVkBot::create(&token);
22
23 bot.command("$members", members)
24 .start_polling(group_id)
25 .await;
26}More examples
examples/keyboard.rs (line 47)
39async fn main() {
40 let group_id: u32 = env::var("GROUP_ID")
41 .unwrap_or_else(|_| "0".into())
42 .parse()
43 .expect("GROUP_ID must be a valid u32");
44
45 let token = env::var("TOKEN").expect("TOKEN environment variable not set");
46
47 let bot = SafeVkBot::create(&token);
48
49 bot.watch(changes)
50 .command("$alert", alert)
51 .start_polling(group_id)
52 .await;
53}examples/reply.rs (line 41)
33async fn main() {
34 let group_id: u32 = env::var("GROUP_ID")
35 .unwrap_or_else(|_| "0".into())
36 .parse()
37 .expect("GROUP_ID must be a valid u32");
38
39 let token = env::var("TOKEN").expect("TOKEN environment variable not set");
40
41 let bot = SafeVkBot::create(&token);
42
43 bot.command("$help", help)
44 .command("$hi", hi)
45 .command("$number", random)
46 .start_polling(group_id)
47 .await;
48}Sourcepub fn command<F, Fut>(self, trigger: &str, handler: F) -> Self
pub fn command<F, Fut>(self, trigger: &str, handler: F) -> Self
Creates a new command that bot will listen
Examples found in repository?
examples/members.rs (line 23)
13async fn main() {
14 let group_id: u32 = env::var("GROUP_ID")
15 .unwrap_or_else(|_| "0".into())
16 .parse()
17 .expect("GROUP_ID must be a valid u32");
18
19 let token = env::var("TOKEN").expect("TOKEN environment variable not set");
20
21 let bot = SafeVkBot::create(&token);
22
23 bot.command("$members", members)
24 .start_polling(group_id)
25 .await;
26}More examples
examples/keyboard.rs (line 50)
39async fn main() {
40 let group_id: u32 = env::var("GROUP_ID")
41 .unwrap_or_else(|_| "0".into())
42 .parse()
43 .expect("GROUP_ID must be a valid u32");
44
45 let token = env::var("TOKEN").expect("TOKEN environment variable not set");
46
47 let bot = SafeVkBot::create(&token);
48
49 bot.watch(changes)
50 .command("$alert", alert)
51 .start_polling(group_id)
52 .await;
53}examples/reply.rs (line 43)
33async fn main() {
34 let group_id: u32 = env::var("GROUP_ID")
35 .unwrap_or_else(|_| "0".into())
36 .parse()
37 .expect("GROUP_ID must be a valid u32");
38
39 let token = env::var("TOKEN").expect("TOKEN environment variable not set");
40
41 let bot = SafeVkBot::create(&token);
42
43 bot.command("$help", help)
44 .command("$hi", hi)
45 .command("$number", random)
46 .start_polling(group_id)
47 .await;
48}Sourcepub fn watch<F, Fut>(self, handler: F) -> Self
pub fn watch<F, Fut>(self, handler: F) -> Self
Callback for each new request
Examples found in repository?
examples/keyboard.rs (line 49)
39async fn main() {
40 let group_id: u32 = env::var("GROUP_ID")
41 .unwrap_or_else(|_| "0".into())
42 .parse()
43 .expect("GROUP_ID must be a valid u32");
44
45 let token = env::var("TOKEN").expect("TOKEN environment variable not set");
46
47 let bot = SafeVkBot::create(&token);
48
49 bot.watch(changes)
50 .command("$alert", alert)
51 .start_polling(group_id)
52 .await;
53}Sourcepub async fn start_polling(&self, group_id: u32)
pub async fn start_polling(&self, group_id: u32)
Starts a new long poll session For more info: https://dev.vk.com/en/api/bots-long-poll/getting-started
Examples found in repository?
examples/members.rs (line 24)
13async fn main() {
14 let group_id: u32 = env::var("GROUP_ID")
15 .unwrap_or_else(|_| "0".into())
16 .parse()
17 .expect("GROUP_ID must be a valid u32");
18
19 let token = env::var("TOKEN").expect("TOKEN environment variable not set");
20
21 let bot = SafeVkBot::create(&token);
22
23 bot.command("$members", members)
24 .start_polling(group_id)
25 .await;
26}More examples
examples/keyboard.rs (line 51)
39async fn main() {
40 let group_id: u32 = env::var("GROUP_ID")
41 .unwrap_or_else(|_| "0".into())
42 .parse()
43 .expect("GROUP_ID must be a valid u32");
44
45 let token = env::var("TOKEN").expect("TOKEN environment variable not set");
46
47 let bot = SafeVkBot::create(&token);
48
49 bot.watch(changes)
50 .command("$alert", alert)
51 .start_polling(group_id)
52 .await;
53}examples/reply.rs (line 46)
33async fn main() {
34 let group_id: u32 = env::var("GROUP_ID")
35 .unwrap_or_else(|_| "0".into())
36 .parse()
37 .expect("GROUP_ID must be a valid u32");
38
39 let token = env::var("TOKEN").expect("TOKEN environment variable not set");
40
41 let bot = SafeVkBot::create(&token);
42
43 bot.command("$help", help)
44 .command("$hi", hi)
45 .command("$number", random)
46 .start_polling(group_id)
47 .await;
48}Auto Trait Implementations§
impl Freeze for SafeVkBot
impl !RefUnwindSafe for SafeVkBot
impl !Send for SafeVkBot
impl !Sync for SafeVkBot
impl Unpin for SafeVkBot
impl !UnwindSafe for SafeVkBot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more