hirc

IRC client
Log | Files | Refs

commit f6e41f6af8e9d3e8c07ba722d00679840324285f
parent 927b59735f22aeb82848b6130497613fa2e97565
Author: hhvn <dev@hhvn.uk>
Date:   Sun, 24 Oct 2021 22:19:21 +0100

commands.c: forgot commands.c, woops

Diffstat:
Acommands.c | 32++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+), 0 deletions(-)

diff --git a/commands.c b/commands.c @@ -0,0 +1,32 @@ +#include <ncurses.h> +#include <ncurses.h> +#include <ncurses.h> +#include "hirc.h" + +void +command_eval(char *str) { + char msg[512]; + + if (*str != '/' || strncmp(str, "/ /", sizeof("/ /")) == 0) { + if (strncmp(str, "/ /", sizeof("/ /")) == 0) + str += 3; + + if (selected.channel && selected.server) { + // TODO: message splitting + snprintf(msg, sizeof(msg), "PRIVMSG %s :%s", selected.channel->name, str); + ircprintf(selected.server, "%s\r\n", msg); + hist_format(selected.server, selected.channel->history, Activity_self, HIST_SHOW|HIST_LOG|HIST_SELF, msg); + } else + ui_error("channel not selected, message ignored", NULL); + + return; + } + + if (strcmp(str, "/quit") == 0) { + endwin(); + exit(0); + } + + str++; + ircprintf(selected.server, "%s\r\n", str); +}