Add /list

weechat-hashes
Curtis McEnroe 2019-07-02 22:12:07 -04:00
parent 6223c9c8f8
commit 3d1f7d8065
No known key found for this signature in database
GPG Key ID: CEA2F97ADCFCD77C
3 changed files with 46 additions and 1 deletions

View File

@ -123,6 +123,9 @@ may be used to abbreviate a command.
.It Ic /join Ar chan Op Ar key .It Ic /join Ar chan Op Ar key
Join a channel. Join a channel.
. .
.It Ic /list Op Ar chan
List channels.
.
.It Ic /me Op Ar action .It Ic /me Op Ar action
Send an action message. Send an action message.
. .

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2018 Curtis McEnroe <june@causal.agency> /* Copyright (C) 2018, 2019 Curtis McEnroe <june@causal.agency>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by * it under the terms of the GNU Affero General Public License as published by
@ -157,6 +157,35 @@ static void handleReplyMOTD(char *prefix, char *params) {
uiFmt(TagStatus, UICold, "%s", mesg); uiFmt(TagStatus, UICold, "%s", mesg);
} }
static void handleReplyList(char *prefix, char *params) {
char *chan, *count, *topic;
parse(prefix, NULL, NULL, NULL, params, 4, 0, NULL, &chan, &count, &topic);
if (topic[0] == '[') {
char *skip = strstr(topic, "] ");
if (skip) topic = &skip[2];
}
const char *people = (strcmp(count, "1") ? "people" : "person");
if (topic[0]) {
uiFmt(
TagStatus, UIWarm,
"You see %s %s in \3%d%s\3 under the banner, \"%s\"",
count, people, colorGen(chan), chan, topic
);
} else {
uiFmt(
TagStatus, UIWarm,
"You see %s %s in \3%d%s\3",
count, people, colorGen(chan), chan
);
}
}
static void handleReplyListEnd(char *prefix, char *params) {
(void)prefix;
(void)params;
uiLog(TagStatus, UICold, L"You don't see anyone else");
}
static enum IRCColor whoisColor; static enum IRCColor whoisColor;
static void handleReplyWhoisUser(char *prefix, char *params) { static void handleReplyWhoisUser(char *prefix, char *params) {
char *nick, *user, *host, *real; char *nick, *user, *host, *real;
@ -499,6 +528,8 @@ static const struct {
{ "315", handleReplyEndOfWho }, { "315", handleReplyEndOfWho },
{ "317", handleReplyWhoisIdle }, { "317", handleReplyWhoisIdle },
{ "319", handleReplyWhoisChannels }, { "319", handleReplyWhoisChannels },
{ "322", handleReplyList },
{ "323", handleReplyListEnd },
{ "332", handleReplyTopic }, { "332", handleReplyTopic },
{ "352", handleReplyWho }, { "352", handleReplyWho },
{ "366", handleReplyEndOfNames }, { "366", handleReplyEndOfNames },

11
input.c
View File

@ -50,6 +50,16 @@ static void inputJoin(struct Tag tag, char *params) {
} }
} }
static void inputList(struct Tag tag, char *params) {
(void)tag;
char *chan = strsep(&params, " ");
if (chan) {
ircFmt("LIST %s\r\n", chan);
} else {
ircFmt("LIST\r\n");
}
}
static void inputMe(struct Tag tag, char *params) { static void inputMe(struct Tag tag, char *params) {
privmsg(tag, true, params ? params : ""); privmsg(tag, true, params ? params : "");
} }
@ -189,6 +199,7 @@ static const struct {
{ "/close", inputClose }, { "/close", inputClose },
{ "/help", inputMan }, { "/help", inputMan },
{ "/join", inputJoin }, { "/join", inputJoin },
{ "/list", inputList },
{ "/man", inputMan }, { "/man", inputMan },
{ "/me", inputMe }, { "/me", inputMe },
{ "/move", inputMove }, { "/move", inputMove },