Skip to content

Commit

Permalink
Clean up, add HTINFO command, rename plugin
Browse files Browse the repository at this point in the history
Hopefully the last major change.
  • Loading branch information
Yaulendil committed May 24, 2022
1 parent b3124f6 commit 2b2b4a1
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 21 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"]


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion benches/benches_irc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

extern crate test;

use hextwitchr::irc::*;
use hextwitch::irc::*;
use test::Bencher;

const MSG_WITHOUT_TAGS: &str =
Expand Down
16 changes: 6 additions & 10 deletions src/ht_core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}",
Expand All @@ -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!(
"{}: '{}'",
Expand Down
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
17 changes: 15 additions & 2 deletions src/plugin/menu/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn create_menus() -> Vec<MenuGroup> {
twitch.add_separator();
twitch.add_item(MenuPrefToggle {
pref: PREF_DEBUG,
desc: "Enable Debug mode",
desc: "Enable debug mode",
set: "HTDEBUG",
unset: None,
});
Expand All @@ -73,12 +73,25 @@ pub fn create_menus() -> Vec<MenuGroup> {
});
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 {
Expand Down
6 changes: 6 additions & 0 deletions src/plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.",
Expand Down

0 comments on commit 2b2b4a1

Please sign in to comment.