From 72dbd5cbab06c9ff28219b5306f71dbd630b9084 Mon Sep 17 00:00:00 2001 From: wrk Date: Mon, 19 Jun 2023 09:57:25 +0200 Subject: [PATCH] preparing for async shit --- .gitignore | 3 ++- Cargo.toml | 5 ++++- examples/hello_world.rs | 14 ++++++++++++++ irc_config.yaml => irc_config.example.yaml | 0 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 examples/hello_world.rs rename irc_config.yaml => irc_config.example.yaml (100%) diff --git a/.gitignore b/.gitignore index 869df07..7ef86ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target -Cargo.lock \ No newline at end of file +Cargo.lock +irc_config.yaml \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index dbd4e0e..6333036 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,4 +10,7 @@ tokio = { version = "1.28.2", features = ["full"] } async-native-tls = { version = "0.5.0", default-features = false, features = [ "runtime-tokio" ] } serde = { version = "1.0.163", features = ["derive"] } serde_yaml = "0.9.21" -log = "0.4.18" \ No newline at end of file +log = "0.4.18" + +[dev-dependencies] +env_logger = "0.10.0" \ No newline at end of file diff --git a/examples/hello_world.rs b/examples/hello_world.rs new file mode 100644 index 0000000..41e6b93 --- /dev/null +++ b/examples/hello_world.rs @@ -0,0 +1,14 @@ +use ircie::{system::IntoResponse, Irc, IrcPrefix}; + +#[tokio::main] +async fn main() -> std::io::Result<()> { + let mut irc = Irc::from_config("irc_config.yaml").await?; + + irc.add_system("hello", hello_world).await; + + irc.run().await +} + +fn hello_world(prefix: IrcPrefix) -> impl IntoResponse { + format!("Hello {}!", prefix.nick) +} diff --git a/irc_config.yaml b/irc_config.example.yaml similarity index 100% rename from irc_config.yaml rename to irc_config.example.yaml