From 53450398d1e4eb96a31f9f0a073087101e187e70 Mon Sep 17 00:00:00 2001 From: Michael Czigler <37268479+mcpcpc@users.noreply.github.com> Date: Fri, 25 Sep 2020 06:57:30 -0400 Subject: Add alias PRIVMSG aliased command --- kirc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/kirc.c b/kirc.c index 28bec21..4256038 100644 --- a/kirc.c +++ b/kirc.c @@ -229,7 +229,7 @@ handle_server_message(void) { static void handle_user_input(void) { - char usrin[MSG_MAX]; + char usrin[MSG_MAX], *tok; fgets(usrin, MSG_MAX, stdin); @@ -238,15 +238,16 @@ handle_user_input(void) { usrin[msg_len - 1] = '\0'; } - if (usrin[0] == '/') { - if (usrin[1] == '#') { - strcpy(chan_default, usrin + 2); - printf("new channel: #%s\n", chan_default); - } else if (usrin[1] == '?' && msg_len == 3) { - printf("current channel: #%s\n", chan_default); - } else { - raw("%s\r\n", usrin + 1); - } + if (usrin[0] == '/' && usrin[1] == '#') { + strcpy(chan_default, usrin + 2); + printf("new channel: #%s\n", chan_default); + } else if (usrin[0] == '/' && usrin[1] == '@') { + strtok_r(usrin, " ", &tok); + raw("privmsg %s :%s\r\n", usrin + 2, tok); + } else if (usrin[0] == '/' && usrin[1] == '?' && msg_len == 3) { + printf("current channel: #%s\n", chan_default); + } else if (usrin[0] == '/') { + raw("%s\r\n", usrin + 1); } else { raw("privmsg #%s :%s\r\n", chan_default, usrin); } -- cgit v1.2.3 From c6d6d3d7f5394dd557e3ceffb4b3c7f8eb854932 Mon Sep 17 00:00:00 2001 From: Michael Czigler <37268479+mcpcpc@users.noreply.github.com> Date: Fri, 25 Sep 2020 07:32:17 -0400 Subject: Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 95cd6f8..c4c9cdc 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,11 @@ * Simple shortcut commands and full support for all IRC commands in the [RFC 2812](https://tools.ietf.org/html/rfc2812) standard: ```shell - Send a PRIVMSG to the current channel. -/ Send command to IRC server (see RFC 2812 for full list). -/# Assign new default message channel. -/? Print current message channel. + Send a PRIVMSG to the current channel. +/ Send command to IRC server (see RFC 2812 for full list). +/# Assign new default message channel. +/? Print current message channel. +/@ Send a message to a specified channel or nick ``` * Color scheme definition via [ANSI 8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code). Therefore, one could theoretically achieve uniform color definition across all shell applications and tools. -- cgit v1.2.3