From 2b2b4a1c0103bf6fcfc3e66e8ff7c30936361d1b Mon Sep 17 00:00:00 2001 From: Yaulendil Date: Mon, 23 May 2022 20:47:53 -0400 Subject: [PATCH] Clean up, add HTINFO command, rename plugin Hopefully the last major change. --- Cargo.toml | 14 +++++++------- README.md | 2 +- benches/benches_irc.rs | 2 +- src/ht_core/mod.rs | 16 ++++++---------- src/lib.rs | 10 ++++++++++ src/plugin/menu/setup.rs | 17 +++++++++++++++-- src/plugin/mod.rs | 6 ++++++ 7 files changed, 46 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e1778b4..1a30fa2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "hextwitchr" +name = "hextwitch" description = "HexChat plugin for Twitch integration over IRC" -version = "1.14.0-b5" +version = "1.14.0" authors = ["Yaulendil"] -repository = "https://github.com/yaulendil/hextwitchr" -edition = "2018" +repository = "https://github.com/yaulendil/hextwitch" +edition = "2021" readme = "README.md" keywords = ["hexchat", "xchat", "twitch", "irc", "plugin"] license = "GPL-3.0" @@ -13,12 +13,12 @@ license = "GPL-3.0" [dependencies] cached = "0.19.0" chrono = "0.4" -hexchat = { git = "https://github.com/Yaulendil/hexchat-rs" } -parking_lot = { version = "0.11" } #features = ["nightly"] } +hexchat = { git = "https://github.com/yaulendil/hexchat-rs" } +parking_lot = "0.11" [lib] -name = "hextwitchr" +name = "hextwitch" crate-type = ["cdylib", "rlib"] diff --git a/README.md b/README.md index 73f4947..5af765a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ You will need to have [Cargo](https://github.com/rust-lang/cargo) installed. Car cargo build --release ``` -After Cargo compiles the plugin, its Binary should be in `target/release/`, and should be named something like `libhextwitchr` or `libhextwitchr.so`. Move this File into the `addons` Directory in your HexChat config Directory; On Linux, this should be at `$XDG_CONFIG_HOME/hexchat/addons/`. +After Cargo compiles the plugin, its Binary should be in `target/release/`, and should be named something like `libhextwitch` or `libhextwitch.so`. Move this File into the `addons` Directory in your HexChat config Directory; On Linux, this should be at `$XDG_CONFIG_HOME/hexchat/addons/`. If you have not patched HexChat, it will probably crash. Otherwise, you should now have Twitch features. diff --git a/benches/benches_irc.rs b/benches/benches_irc.rs index 4d835e7..24a92e1 100644 --- a/benches/benches_irc.rs +++ b/benches/benches_irc.rs @@ -2,7 +2,7 @@ extern crate test; -use hextwitchr::irc::*; +use hextwitch::irc::*; use test::Bencher; const MSG_WITHOUT_TAGS: &str = diff --git a/src/ht_core/mod.rs b/src/ht_core/mod.rs index 4204108..cf75bf1 100644 --- a/src/ht_core/mod.rs +++ b/src/ht_core/mod.rs @@ -302,6 +302,12 @@ pub fn cmd_ht_debug(_arg_full: &[String]) -> EatMode { } +pub fn cmd_ht_info(_arg_full: &[String]) -> EatMode { + hexchat::print_plain(crate::PLUGIN_INFO); + EatMode::All +} + + pub fn cmd_prediction(_arg_full: &[String]) -> EatMode { alert_basic(&format!( "Current Prediction: {}", @@ -318,16 +324,6 @@ pub fn cmd_reward(arg_full: &[String]) -> EatMode { // Print the current Reward Names. alert_basic("REWARD EVENTS:"); - // for pref in get_prefs() { - // if !pref.is_empty() && !pref.starts_with(Pref::PREFIX) { - // alert_basic(&format!( - // "{}: '{}'", - // pref, - // get_pref_string(&pref).unwrap_or_default(), - // )); - // } - // } - for reward in Reward::get_all() { alert_basic(&format!( "{}: '{}'", diff --git a/src/lib.rs b/src/lib.rs index 332303d..b475a8e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,16 @@ use plugin::HexTwitch; const NETWORK: &str = "Twitch"; +const PLUGIN_INFO: &str = "\ +About HexTwitch: +\ +HexTwitch is a HexChat plugin implementing Twitch.tv functionality, written in \ +Rust. Using data from IRC Tags, it displays channel events such as Bits and \ +Subscriptions, and applies Twitch badges to users in the form of Unicode \ +characters. +\ +Repository: https://github.com/Yaulendil/HexTwitch +"; hexchat::plugin!(HexTwitch); diff --git a/src/plugin/menu/setup.rs b/src/plugin/menu/setup.rs index 234d903..5cff8f0 100644 --- a/src/plugin/menu/setup.rs +++ b/src/plugin/menu/setup.rs @@ -61,7 +61,7 @@ pub fn create_menus() -> Vec { twitch.add_separator(); twitch.add_item(MenuPrefToggle { pref: PREF_DEBUG, - desc: "Enable Debug mode", + desc: "Enable debug mode", set: "HTDEBUG", unset: None, }); @@ -73,12 +73,25 @@ pub fn create_menus() -> Vec { }); twitch.add_item(MenuPrefToggle { pref: PREF_WHISPERS, - desc: "Show Whispers in current tab", + desc: "Show whispers in current tab", set: "WHISPERHERE", unset: None, }); } + // Main menu: Section 4: Plugin misc. + { + twitch.add_separator(); + twitch.add_item(MenuCommand { + cmd: concat!("RELOAD ", env!("CARGO_PKG_NAME")), + desc: "Reload plugin", + }); + twitch.add_item(MenuCommand { + cmd: "HTINFO", + desc: "About HexTwitch", + }); + } + // Channel utility submenu. { twitch_ch_admin.add_item(MenuCommand { diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index 955611f..721d845 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -8,6 +8,7 @@ use crate::ht_core::{ cb_print, cb_server, cmd_follow_hosts, + cmd_ht_info, cmd_ht_debug, cmd_prediction, cmd_reward, @@ -71,6 +72,11 @@ impl Plugin for HexTwitch { "Toggle whether unknown UserNotices should show the full plain IRC.", cmd_ht_debug, ); + plugin.hook_command( + "HTINFO", + "Print information about the HexTwitch plugin.", + cmd_ht_info, + ); plugin.hook_command( "HOSTFOLLOW", "Toggle whether Twitch Hosts will be followed through to the target channel.",