Add /away
parent
0d23f8f1b8
commit
8aa6dd86f6
|
@ -1,4 +1,4 @@
|
||||||
.Dd February 13, 2020
|
.Dd February 14, 2020
|
||||||
.Dt CATGIRL 1
|
.Dt CATGIRL 1
|
||||||
.Os
|
.Os
|
||||||
.
|
.
|
||||||
|
@ -240,6 +240,8 @@ can be typed
|
||||||
.
|
.
|
||||||
.Ss Chat Commands
|
.Ss Chat Commands
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
|
.It Ic /away Op Ar message
|
||||||
|
Set or clear your away status.
|
||||||
.It Ic /join Ar channel
|
.It Ic /join Ar channel
|
||||||
Join a channel.
|
Join a channel.
|
||||||
.It Ic /list Op Ar channel
|
.It Ic /list Op Ar channel
|
||||||
|
|
1
chat.h
1
chat.h
|
@ -131,6 +131,7 @@ void ircFormat(const char *format, ...)
|
||||||
void ircClose(void);
|
void ircClose(void);
|
||||||
|
|
||||||
extern struct Replies {
|
extern struct Replies {
|
||||||
|
size_t away;
|
||||||
size_t join;
|
size_t join;
|
||||||
size_t list;
|
size_t list;
|
||||||
size_t names;
|
size_t names;
|
||||||
|
|
11
command.c
11
command.c
|
@ -110,6 +110,16 @@ static void commandNick(size_t id, char *params) {
|
||||||
ircFormat("NICK :%s\r\n", params);
|
ircFormat("NICK :%s\r\n", params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void commandAway(size_t id, char *params) {
|
||||||
|
(void)id;
|
||||||
|
if (params) {
|
||||||
|
ircFormat("AWAY :%s\r\n", params);
|
||||||
|
} else {
|
||||||
|
ircFormat("AWAY\r\n");
|
||||||
|
}
|
||||||
|
replies.away++;
|
||||||
|
}
|
||||||
|
|
||||||
static void commandTopic(size_t id, char *params) {
|
static void commandTopic(size_t id, char *params) {
|
||||||
if (params) {
|
if (params) {
|
||||||
ircFormat("TOPIC %s :%s\r\n", idNames[id], params);
|
ircFormat("TOPIC %s :%s\r\n", idNames[id], params);
|
||||||
|
@ -235,6 +245,7 @@ static const struct Handler {
|
||||||
Command *fn;
|
Command *fn;
|
||||||
bool restricted;
|
bool restricted;
|
||||||
} Commands[] = {
|
} Commands[] = {
|
||||||
|
{ "/away", .fn = commandAway },
|
||||||
{ "/close", .fn = commandClose },
|
{ "/close", .fn = commandClose },
|
||||||
{ "/copy", .fn = commandCopy, .restricted = true },
|
{ "/copy", .fn = commandCopy, .restricted = true },
|
||||||
{ "/debug", .fn = commandDebug, .restricted = true },
|
{ "/debug", .fn = commandDebug, .restricted = true },
|
||||||
|
|
9
handle.c
9
handle.c
|
@ -549,6 +549,13 @@ static void handleReplyAway(struct Message *msg) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handleReplyNowAway(struct Message *msg) {
|
||||||
|
require(msg, false, 2);
|
||||||
|
if (!replies.away) return;
|
||||||
|
uiFormat(Network, Warm, tagTime(msg), "%s", msg->params[1]);
|
||||||
|
replies.away--;
|
||||||
|
}
|
||||||
|
|
||||||
static bool isAction(struct Message *msg) {
|
static bool isAction(struct Message *msg) {
|
||||||
if (strncmp(msg->params[1], "\1ACTION ", 8)) return false;
|
if (strncmp(msg->params[1], "\1ACTION ", 8)) return false;
|
||||||
msg->params[1] += 8;
|
msg->params[1] += 8;
|
||||||
|
@ -675,6 +682,8 @@ static const struct Handler {
|
||||||
{ "005", handleReplyISupport },
|
{ "005", handleReplyISupport },
|
||||||
{ "276", handleReplyWhoisGeneric },
|
{ "276", handleReplyWhoisGeneric },
|
||||||
{ "301", handleReplyAway },
|
{ "301", handleReplyAway },
|
||||||
|
{ "305", handleReplyNowAway },
|
||||||
|
{ "306", handleReplyNowAway },
|
||||||
{ "307", handleReplyWhoisGeneric },
|
{ "307", handleReplyWhoisGeneric },
|
||||||
{ "311", handleReplyWhoisUser },
|
{ "311", handleReplyWhoisUser },
|
||||||
{ "312", handleReplyWhoisServer },
|
{ "312", handleReplyWhoisServer },
|
||||||
|
|
Loading…
Reference in New Issue