]> PatchyGit - patchyircd.git/commitdiff
add bot flag
authorEgor <egor@patchysicp.xyz>
Fri, 3 Feb 2023 17:46:31 +0000 (19:46 +0200)
committerEgor <egor@patchysicp.xyz>
Fri, 3 Feb 2023 17:46:31 +0000 (19:46 +0200)
common.h
irc.c
ircfmt.c
ircfmt.h

index 8c8887a..5e0ecf5 100644 (file)
--- a/common.h
+++ b/common.h
@@ -16,6 +16,7 @@ struct tls;
 #define UMODE_REGISTERED 8
 #define UMODE_WALLOPS 16
 #define UMODE_SECURE 32
+#define UMODE_BOT 64
 #define REG_INIT 0
 #define REG_CAPLS 1
 #define REG_REGISTERED 2
diff --git a/irc.c b/irc.c
index 6c35f60..df40c7e 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -86,7 +86,7 @@ void sendbuf_visible(struct client_data *client) {
        sendbuf_visible_caps(client, 0, 0);
 }
 const char *format_umodes(struct client_data *cl) {
-       static char umodes[6] = "";
+       static char umodes[8] = "";
        char *p = umodes;
        *p++ = '+';
        if (cl->umode & UMODE_INVISIBLE) *p++ = 'i';
@@ -94,6 +94,7 @@ const char *format_umodes(struct client_data *cl) {
        if (cl->umode & UMODE_REGISTERED) *p++ = 'r';
        if (cl->umode & UMODE_WALLOPS) *p++ = 'w';
        if (cl->umode & UMODE_SECURE) *p++ = 'Z';
+       if (cl->umode & UMODE_BOT) *p++ = 'B';
        *p++ = '\0';
        return umodes;
 }
@@ -651,6 +652,11 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                                                        sendbuf(client);
                                                }
                                                break;
+                                       case 'B':
+                                               SETBIT(cl->umode, UMODE_BOT, is_plus);
+                                               copy_strf(&databuf, ":%s MODE %s %sB\n", hostname, client->nick, is_plus?"+":"-");
+                                               sendbuf(client);
+                                               break;
                                        default:
                                                copy_strf(&databuf, ":%s 501 %s :Unknown MODE flag\n", hostname, client->nick);
                                                sendbuf(client);
@@ -993,6 +999,8 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                        if (client == cl || client->umode & UMODE_OPER)
                                rpl_whoisactually(client, cl), sendbuf(client);
                        rpl_whoismodes(client, cl), sendbuf(client);
+                       if (client->umode & UMODE_BOT)
+                               rpl_whoisbot(client, cl), sendbuf(client);
                        rpl_endofwhois(client, cl), sendbuf(client);
                } else {
                        err_nosuchnick(client, nick);
index 6e9ab73..4f57e24 100644 (file)
--- a/ircfmt.c
+++ b/ircfmt.c
@@ -137,7 +137,7 @@ void rpl_myinfo(struct client_data *client) // 004
 }
 void rpl_isupport(struct client_data *client) // 005
 {
-       copy_strf(&databuf, ":%s 005 %s CASEMAPPING=ascii NICKLEN=%u EXCEPTS=e INVEX=I MAXTARGETS=1 CHANMODES=beIqw,k,l,Pimnst CHANTYPES=#& PREFIX=(ov)@+ STATUSMSG=@+ :are supported by this server\r\n", hostname, client->nick, MAX_NICKLEN-1);
+       copy_strf(&databuf, ":%s 005 %s CASEMAPPING=ascii NICKLEN=%u EXCEPTS=e INVEX=I MAXTARGETS=1 CHANMODES=beIqw,k,l,Pimnst CHANTYPES=#& PREFIX=(ov)@+ STATUSMSG=@+ BOT=B :are supported by this server\r\n", hostname, client->nick, MAX_NICKLEN-1);
 
 }
 #if 0
@@ -251,9 +251,10 @@ void rpl_nowaway(struct client_data *client) // 306
 }
 void rpl_whoreply(struct client_data *client, struct client_data *cl, struct channel *chan) // 352
 {
-       copy_strf(&databuf, ":%s 352 %s %s %s %s %s %s %s%s%s :1 %s\r\n",
+       copy_strf(&databuf, ":%s 352 %s %s %s %s %s %s %s%s%s%s :1 %s\r\n",
                        hostname, client->nick, chan ? chan->name : "*", cl->username, cl->hostname, hostname, cl->nick,
-                       cl->away ? "G" : "H", cl->umode&UMODE_OPER ? "*" : "", format_prefixes(client, cl, chan), cl->realname);
+                       cl->away ? "G" : "H", cl->umode&UMODE_BOT ? "B" : "",
+                       cl->umode&UMODE_OPER ? "*" : "", format_prefixes(client, cl, chan), cl->realname);
 }
 void rpl_endofwho(struct client_data *client, const char *query) // 315
 {
@@ -349,6 +350,10 @@ void rpl_topicwhotime(struct client_data *client, struct channel *chan) // 333
        copy_strf(&databuf, ":%s 333 %s %s %s %u\r\n", hostname, client->nick,
                        chan->name, chan->topic_who, (unsigned)chan->topic_when);
 }
+void rpl_whoisbot(struct client_data *client, struct client_data *cl) // 335
+{
+       copy_strf(&databuf, ":%s 335 %s %s :is a bot\r\n", hostname, client->nick, cl->nick);
+}
 void rpl_invitelist(struct client_data *client, struct channel *chan) // 336
 {
        copy_strf(&databuf, ":%s 336 %s %s\r\n", hostname, client->nick, chan->name);
index cc83cd0..5df5350 100644 (file)
--- a/ircfmt.h
+++ b/ircfmt.h
@@ -64,6 +64,7 @@ void rpl_whoisaccount(struct client_data *client, struct client_data *cl); // 33
 void rpl_notopic(struct client_data *client, struct channel *chan); // 331
 void rpl_topic(struct client_data *client, struct channel *chan); // 332
 void rpl_topicwhotime(struct client_data *client, struct channel *chan); // 333
+void rpl_whoisbot(struct client_data *client, struct client_data *cl); // 335
 void rpl_invitelist(struct client_data *client, struct channel *chan); // 336
 void rpl_endofinvitelist(struct client_data *client); // 337
 void rpl_whoisactually(struct client_data *client, struct client_data *cl); // 338