Skip to content

Instantly share code, notes, and snippets.

@d33tah
Created February 25, 2023 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d33tah/0a660a6183179a574bda376ab9288384 to your computer and use it in GitHub Desktop.
Save d33tah/0a660a6183179a574bda376ab9288384 to your computer and use it in GitHub Desktop.
[package]
name = "ircclient"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
failure = "0.1.8"
futures = "0.3.26"
irc = "0.15.0"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
[[bin]]
name = "ircclient"
path = "main.rs"
FROM rust as build
ADD ./Cargo.toml /app/Cargo.toml
ADD ./src /app/src
WORKDIR /app
RUN cargo build --release
FROM scratch
COPY --from=build /app/target/release/ircclient /ircclient
use irc::client::prelude::*;
use futures::prelude::*;
#[tokio::main]
async fn main() -> Result<(), failure::Error> {
// We can also load the Config at runtime via Config::load("path/to/config.toml")
let config = Config {
nickname: Some("the-irc-crate".to_owned()),
server: Some("irc.libera.chat".to_owned()),
channels: vec!["#hakierspejs".to_owned()],
..Config::default()
};
let mut client = Client::from_config(config).await?;
client.identify()?;
let mut stream = client.stream()?;
while let Some(message) = stream.next().await.transpose()? {
match message.command {
Command::PRIVMSG(ref channel, ref cmd) => {
println!("{}", cmd);
}
_ => (),
}
}
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment