[hackers] [ii][PATCH] add CTCP ACTION support

From: satanist <satanist+suckless_AT_bureaucracy.de>
Date: Mon, 22 Jul 2019 07:17:25 +0200

Adds support for writing CTCP ACTIONs with the use of '/m some action'.
This can be done simply by writing '^AACTION some action^A',
but this patch is for people who are too lazy to do that.

Based on patch from Evan Gates (emg) evan.gates_AT_gmail.com
---
 ii.1 |  3 +++
 ii.c | 10 ++++++++++
 2 files changed, 13 insertions(+)
diff --git a/ii.1 b/ii.1
index 8e06af7..11cb540 100644
--- a/ii.1
+++ b/ii.1
_AT_@ -81,6 +81,9 @@ quit ii
 .TP
 .BI /t " topic"
 set the topic of a channel
+.TP
+.BI /m " action"
+send action as a CTCP ACTION (think /me)
 .SH RAW COMMANDS
 .LP
 Everything which is not a command will be posted into the channel or to the server.
diff --git a/ii.c b/ii.c
index 55d5f52..4ae9d9f 100644
--- a/ii.c
+++ b/ii.c
_AT_@ -459,6 +459,7 @@ proc_channels_input(int ircfd, Channel *c, char *buf)
 {
 	char *p = NULL;
 	size_t buflen;
+	char tmp[IRC_MSG_MAX-2];
 
 	if (buf[0] == '\0')
 		return;
_AT_@ -534,6 +535,15 @@ proc_channels_input(int ircfd, Channel *c, char *buf)
 			isrunning = 0;
 			return;
 			break;
+		case 'm':
+			if (buflen >= 3) {
+				snprintf(tmp, sizeof(tmp), "\01ACTION %s\01", &buf[3]);
+			} else {
+				snprintf(tmp, sizeof(tmp), "\01ACTION\01");
+			}
+			proc_channels_privmsg(ircfd, c, tmp);
+			return;
+			break;
 		default: /* raw IRC command */
 			snprintf(msg, sizeof(msg), "%s\r\n", &buf[1]);
 			break;
-- 
2.11.0
Received on Mon Jul 22 2019 - 07:17:25 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 22 2019 - 09:00:26 CEST