2020-03-04 07:38:01 +01:00
|
|
|
use futures::prelude::*;
|
|
|
|
use irc::client::prelude::*;
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> irc::error::Result<()> {
|
|
|
|
let config = Config {
|
2020-03-07 06:17:35 +01:00
|
|
|
nickname: Some("pickles".to_owned()),
|
|
|
|
server: Some("irc.pdgn.co".to_owned()),
|
2020-03-04 07:38:01 +01:00
|
|
|
channels: vec!["#rust-spam".to_owned()],
|
|
|
|
proxy_type: Some(ProxyType::Socks5),
|
|
|
|
proxy_server: Some("127.0.0.1".to_owned()),
|
|
|
|
proxy_port: Some(9050),
|
|
|
|
..Default::default()
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut client = Client::from_config(config).await?;
|
|
|
|
client.identify()?;
|
|
|
|
|
|
|
|
let mut stream = client.stream()?;
|
2020-03-07 06:17:35 +01:00
|
|
|
let sender = client.sender();
|
2020-03-04 07:38:01 +01:00
|
|
|
|
|
|
|
while let Some(message) = stream.next().await.transpose()? {
|
|
|
|
print!("{}", message);
|
2020-03-07 06:17:35 +01:00
|
|
|
|
|
|
|
match message.command {
|
|
|
|
Command::PRIVMSG(ref target, ref msg) => {
|
|
|
|
if msg.contains(client.current_nickname()) {
|
|
|
|
sender.send_privmsg(target, "Hi!")?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => (),
|
|
|
|
}
|
2020-03-04 07:38:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|