diff options
author | Michael Czigler <37268479+mcpcpc@users.noreply.github.com> | 2020-09-25 07:35:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-25 07:35:50 -0400 |
commit | ffc0220f44011e1659f1a7ccf6c46a176e4a4ecc (patch) | |
tree | 1a858b4611345de560e770bbb5ca2f70c10af11b | |
parent | squash commits to address README and defaults (diff) | |
parent | Update README.md (diff) | |
download | kirc-ffc0220f44011e1659f1a7ccf6c46a176e4a4ecc.tar.gz kirc-ffc0220f44011e1659f1a7ccf6c46a176e4a4ecc.tar.bz2 kirc-ffc0220f44011e1659f1a7ccf6c46a176e4a4ecc.tar.xz kirc-ffc0220f44011e1659f1a7ccf6c46a176e4a4ecc.tar.zst kirc-ffc0220f44011e1659f1a7ccf6c46a176e4a4ecc.zip |
Merge pull request #33 from mcpcpc/add_privmsg_alias
Add alias PRIVMSG aliased command
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | kirc.c | 21 |
2 files changed, 16 insertions, 14 deletions
@@ -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 -<message> Send a PRIVMSG to the current channel. -/<command> Send command to IRC server (see RFC 2812 for full list). -/#<channel> Assign new default message channel. -/? Print current message channel. +<message> Send a PRIVMSG to the current channel. +/<command> Send command to IRC server (see RFC 2812 for full list). +/#<channel> Assign new default message channel. +/? Print current message channel. +/@<channel|nick> <message> 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. @@ -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); } |