2019-08-27 15:05:51 +02:00
|
|
|
use futures::prelude::*;
|
2018-09-17 23:50:53 +02:00
|
|
|
use irc::client::prelude::*;
|
2019-08-27 15:05:51 +02:00
|
|
|
use std::time::Duration;
|
2018-09-17 23:50:53 +02:00
|
|
|
|
|
|
|
// NOTE: this example is a conversion of `tweeter.rs` to an asynchronous style with `IrcReactor`.
|
2019-08-27 15:05:51 +02:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> irc::error::Result<()> {
|
2018-09-17 23:50:53 +02:00
|
|
|
let config = Config {
|
|
|
|
nickname: Some("mastodon".to_owned()),
|
2020-03-07 06:17:35 +01:00
|
|
|
server: Some("irc.pdgn.co".to_owned()),
|
2019-09-29 00:54:07 +02:00
|
|
|
channels: vec!["#rust-spam".to_owned()],
|
2018-09-17 23:50:53 +02:00
|
|
|
..Default::default()
|
|
|
|
};
|
|
|
|
|
2019-08-27 15:05:51 +02:00
|
|
|
let client = Client::from_config(config).await?;
|
|
|
|
let sender = client.sender();
|
2018-09-17 23:50:53 +02:00
|
|
|
|
2019-08-27 15:05:51 +02:00
|
|
|
let mut interval = tokio::time::interval(Duration::from_secs(1)).fuse();
|
2018-09-17 23:50:53 +02:00
|
|
|
|
2019-08-27 15:05:51 +02:00
|
|
|
loop {
|
|
|
|
let _ = interval.select_next_some().await;
|
|
|
|
sender.send_privmsg("#rust-spam", "AWOOOOOOOOOO")?;
|
|
|
|
}
|
2018-09-17 23:50:53 +02:00
|
|
|
}
|