commit 866c8adbacf996efde690b13928e76cca18c7108
parent 3b7b6d5d7a5f3c8d6515368d6fcaccb18fda7d33
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 7 Feb 2025 21:25:23 -0800
add Unkick command
Diffstat:
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/main.rs b/src/main.rs
@@ -89,6 +89,7 @@ lazy_static! {
static ref COLOR1_RGX: Regex = Regex::new(r#"^#([0-9A-Fa-f]{6})$"#).unwrap();
static ref PM_RGX: Regex = Regex::new(r#"^/pm ([^\s]+) (.*)"#).unwrap();
static ref KICK_RGX: Regex = Regex::new(r#"^/(?:kick|k) ([^\s]+)\s?(.*)"#).unwrap();
+ static ref UNKICK_RGX: Regex = Regex::new(r#"^/(?:unkick|uk) (.+)$"#).unwrap();
static ref IGNORE_RGX: Regex = Regex::new(r#"^/ignore ([^\s]+)"#).unwrap();
static ref UNIGNORE_RGX: Regex = Regex::new(r#"^/unignore ([^\s]+)"#).unwrap();
static ref DLX_RGX: Regex = Regex::new(r#"^/dl([\d]+)$"#).unwrap();
@@ -949,6 +950,10 @@ impl LeChatPHPClient {
let username = captures[1].to_owned();
let msg = captures[2].to_owned();
self.post_msg(PostType::Kick(msg, username)).unwrap();
+ } else if let Some(captures) = UNKICK_RGX.captures(&input) {
+ // Unkick a user
+ let username = captures[1].to_owned();
+ self.post_msg(PostType::Unkick(username)).unwrap();
} else if let Some(captures) = IGNORE_RGX.captures(&input) {
// Ignore a user
let username = captures[1].to_owned();
@@ -998,6 +1003,7 @@ impl LeChatPHPClient {
let mut prefix = "";
if parts.len() == 1
&& ((parts[0] == "/kick" || parts[0] == "/k")
+ || (parts[0] == "/unkick" || parts[0] == "/uk")
|| parts[0] == "/pm"
|| parts[0] == "/ignore"
|| parts[0] == "/unignore")
@@ -1324,6 +1330,17 @@ fn post_msg(client: &Client, post_type_recv: PostType, full_url: &str, session:
("what", "purge".to_owned()),
]);
}
+ PostType::Unkick(username) => {
+ params.extend(vec![
+ ("action", "admin".to_owned()),
+ ("session", session.clone()),
+ ("lang", LANG.to_owned()),
+ ("nc", nc_value.to_owned()),
+ ("do", "sessions".to_owned()),
+ ("logout", "1".to_owned()),
+ ("nick", username),
+ ]);
+ }
PostType::DeleteLast | PostType::DeleteAll => {
params.extend(vec![("action", "delete".to_owned())]);
if let PostType::DeleteAll = post_type {
@@ -1964,6 +1981,7 @@ fn main() -> anyhow::Result<()> {
enum PostType {
Post(String, Option<String>), // Message, SendTo
Kick(String, String), // Message, Username
+ Unkick(String), // Username
Upload(String, String, String), // FilePath, SendTo, Message
DeleteLast, // DeleteLast
DeleteAll, // DeleteAll