Add /setname command
I'm not sure about that replies check in handleStandardReply. If more of those are added the reply counter system will definitely need refactoring.master
parent
b4ed58602b
commit
1662b01a5f
10
catgirl.1
10
catgirl.1
|
@ -328,6 +328,9 @@ command is likely needed
|
||||||
for command output.
|
for command output.
|
||||||
.It Ic /say Ar message
|
.It Ic /say Ar message
|
||||||
Send a regular message.
|
Send a regular message.
|
||||||
|
.It Ic /setname Ar name
|
||||||
|
Update realname
|
||||||
|
if supported by the server.
|
||||||
.It Ic /topic Op Ar topic
|
.It Ic /topic Op Ar topic
|
||||||
Show or set the topic of the channel.
|
Show or set the topic of the channel.
|
||||||
Press
|
Press
|
||||||
|
@ -735,6 +738,13 @@ ignore = * [JPQ][OAU][IR][NT] #example
|
||||||
.Re
|
.Re
|
||||||
.It
|
.It
|
||||||
.Rs
|
.Rs
|
||||||
|
.%A Janne Mareike Koschinski
|
||||||
|
.%T IRCv3 setname Extension
|
||||||
|
.%I IRCv3 Working Group
|
||||||
|
.%U https://ircv3.net/specs/extensions/setname
|
||||||
|
.Re
|
||||||
|
.It
|
||||||
|
.Rs
|
||||||
.%A Mantas Mikul\[u0117]nas
|
.%A Mantas Mikul\[u0117]nas
|
||||||
.%T IRCv3.2 userhost-in-names Extension
|
.%T IRCv3.2 userhost-in-names Extension
|
||||||
.%I IRCv3 Working Group
|
.%I IRCv3 Working Group
|
||||||
|
|
2
chat.h
2
chat.h
|
@ -171,6 +171,7 @@ extern struct Network {
|
||||||
X("multi-prefix", CapMultiPrefix) \
|
X("multi-prefix", CapMultiPrefix) \
|
||||||
X("sasl", CapSASL) \
|
X("sasl", CapSASL) \
|
||||||
X("server-time", CapServerTime) \
|
X("server-time", CapServerTime) \
|
||||||
|
X("setname", CapSetname) \
|
||||||
X("userhost-in-names", CapUserhostInNames)
|
X("userhost-in-names", CapUserhostInNames)
|
||||||
|
|
||||||
enum Cap {
|
enum Cap {
|
||||||
|
@ -256,6 +257,7 @@ extern struct Replies {
|
||||||
uint list;
|
uint list;
|
||||||
uint mode;
|
uint mode;
|
||||||
uint names;
|
uint names;
|
||||||
|
uint setname;
|
||||||
uint topic;
|
uint topic;
|
||||||
uint who;
|
uint who;
|
||||||
uint whois;
|
uint whois;
|
||||||
|
|
|
@ -159,6 +159,13 @@ static void commandAway(uint id, char *params) {
|
||||||
replies.away++;
|
replies.away++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void commandSetname(uint id, char *params) {
|
||||||
|
(void)id;
|
||||||
|
if (!params) return;
|
||||||
|
ircFormat("SETNAME :%s\r\n", params);
|
||||||
|
replies.setname++;
|
||||||
|
}
|
||||||
|
|
||||||
static void commandTopic(uint id, char *params) {
|
static void commandTopic(uint 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);
|
||||||
|
@ -486,6 +493,7 @@ static const struct Handler {
|
||||||
{ "/quit", commandQuit, 0 },
|
{ "/quit", commandQuit, 0 },
|
||||||
{ "/quote", commandQuote, Multiline | Restricted },
|
{ "/quote", commandQuote, Multiline | Restricted },
|
||||||
{ "/say", commandPrivmsg, Multiline },
|
{ "/say", commandPrivmsg, Multiline },
|
||||||
|
{ "/setname", commandSetname, 0 },
|
||||||
{ "/topic", commandTopic, 0 },
|
{ "/topic", commandTopic, 0 },
|
||||||
{ "/unban", commandUnban, 0 },
|
{ "/unban", commandUnban, 0 },
|
||||||
{ "/unexcept", commandUnexcept, 0 },
|
{ "/unexcept", commandUnexcept, 0 },
|
||||||
|
|
16
handle.c
16
handle.c
|
@ -97,6 +97,10 @@ typedef void Handler(struct Message *msg);
|
||||||
|
|
||||||
static void handleStandardReply(struct Message *msg) {
|
static void handleStandardReply(struct Message *msg) {
|
||||||
require(msg, false, 3);
|
require(msg, false, 3);
|
||||||
|
if (!strcmp(msg->params[0], "SETNAME")) {
|
||||||
|
if (!replies.setname) return;
|
||||||
|
replies.setname--;
|
||||||
|
}
|
||||||
for (uint i = 2; i < ParamCap - 1; ++i) {
|
for (uint i = 2; i < ParamCap - 1; ++i) {
|
||||||
if (msg->params[i + 1]) continue;
|
if (msg->params[i + 1]) continue;
|
||||||
uiFormat(
|
uiFormat(
|
||||||
|
@ -1150,6 +1154,17 @@ static void handleReplyNowAway(struct Message *msg) {
|
||||||
replies.away--;
|
replies.away--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handleSetname(struct Message *msg) {
|
||||||
|
require(msg, true, 1);
|
||||||
|
if (!replies.setname) return;
|
||||||
|
if (strcmp(msg->nick, self.nick)) return;
|
||||||
|
uiFormat(
|
||||||
|
Network, Warm, tagTime(msg),
|
||||||
|
"You update your name tag: %s", msg->params[0]
|
||||||
|
);
|
||||||
|
replies.setname--;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -1343,6 +1358,7 @@ static const struct Handler {
|
||||||
{ "PING", handlePing },
|
{ "PING", handlePing },
|
||||||
{ "PRIVMSG", handlePrivmsg },
|
{ "PRIVMSG", handlePrivmsg },
|
||||||
{ "QUIT", handleQuit },
|
{ "QUIT", handleQuit },
|
||||||
|
{ "SETNAME", handleSetname },
|
||||||
{ "TOPIC", handleTopic },
|
{ "TOPIC", handleTopic },
|
||||||
{ "WARN", handleStandardReply },
|
{ "WARN", handleStandardReply },
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue