y6_echo_bot/
y6_echo_bot.rs1use asciicker_rs::callback;
2use asciicker_rs::macro_rules_attribute::apply;
3use asciicker_rs::y6::prelude::*;
4use std::sync::Arc;
5use tokio::sync::Mutex;
6
7#[tokio::main]
8async fn main() {
9 let mut bot = Bot::new("player", "ws://asciicker.com/ws/y6/", true);
10 bot.on_talk(talk_callback);
11 let (threads, _data) = match bot.run().await {
12 Err(e) => panic!("Failed to run the bot: {:?}", e),
13 Ok(stuff) => stuff,
14 };
15 println!("{:?}", threads.0.thread.await);
16}
17
18#[apply(callback!)]
19pub async fn talk_callback(
20 talk_brc: TalkBroadcast,
21 _: Arc<Mutex<Player>>,
22 _: Arc<Mutex<World>>,
23 sender: MessageSender,
24) -> BotResult {
25 sender.send(talk_brc.str.into_string().unwrap());
26 Ok(())
27}