]> PatchyGit - patchyircd.git/commitdiff
add auto op (+w)
authorEgor <egor@patchysicp.xyz>
Wed, 11 May 2022 20:40:00 +0000 (23:40 +0300)
committerEgor <egor@patchysicp.xyz>
Wed, 11 May 2022 20:40:00 +0000 (23:40 +0300)
common.h
irc.c
ircfmt.c

index 46fca0b..d786ac9 100644 (file)
--- a/common.h
+++ b/common.h
@@ -59,6 +59,8 @@ struct channel {
        struct trie_node *liste;
        struct trie_node *listI;
        struct trie_node *listq;
+       struct trie_node *listwo;
+       struct trie_node *listwv;
        char *chankey;
        int member_limit;
 };
diff --git a/irc.c b/irc.c
index 3be72f9..723bab4 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -626,6 +626,21 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                                                sendbuf(client);
                                                return 0;
                                        }
+                                       if (!strcmp(args[1], "+w")) {
+                                               if (trie_findfirst(&f, &chan->listwo) == 1)
+                                                       do {
+                                                               copy_strf(&databuf, ":%s 910 %s %s o:%s\n", hostname, client->nick, chan->name, f->key);
+                                                               sendbuf(client);
+                                                       } while(trie_findnext(&f) == 1);
+                                               if (trie_findfirst(&f, &chan->listwv) == 1)
+                                                       do {
+                                                               copy_strf(&databuf, ":%s 910 %s %s v:%s\n", hostname, client->nick, chan->name, f->key);
+                                                               sendbuf(client);
+                                                       } while(trie_findnext(&f) == 1);
+                                               copy_strf(&databuf, ":%s 911 %s %s :End of channel access list\n", hostname, client->nick, chan->name);
+                                               sendbuf(client);
+                                               return 0;
+                                       }
                                }
                                int is_plus;
                                char *p = args[1];
@@ -737,8 +752,21 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                                        case 'q':
                                                list = &chan->listq;
                                                goto set_list;
+                                       case 'w':
+                                               if (!*argp) // TODO: error msg
+                                                       break;
+                                               if (args[0][0] == 'o')
+                                                       list = &chan->listwo;
+                                               else if (args[0][0] == 'v')
+                                                       list = &chan->listwv;
+                                               else
+                                                       break; // TODO: error msg
+                                               if (args[0][1] != ':')
+                                                       break; // TODO: error msg
+                                               args[0] += 2;
+                                               goto set_list;
                                        set_list: {
-                                               if(!*argp)
+                                               if(!*argp) // TODO: error msg
                                                        break;
                                                char *mask = *argp++;
                                                if (strchr(mask, ' '))
@@ -1156,6 +1184,20 @@ void channel_join(struct client_data *client, const char *channel, const char *c
        if (newchan)
                chanlog_time(chan->creation);
        sendbuf_chan(chan);
+       // TODO: send channel modes to the joining client
+       // apply +w modes
+       if (match_list(client, &chan->listwo)) {
+               if (trie_set(&chan->o, client->key, client, NULL) == -1)
+                       abort();
+               copy_strf(&databuf, ":cia!cia@cia.gov MODE %s +o %s\r\n", chan->name, client->nick);
+               sendbuf_chan(chan);
+       }
+       if (match_list(client, &chan->listwv)) {
+               if (trie_set(&chan->v, client->key, client, NULL) == -1)
+                       abort();
+               copy_strf(&databuf, ":cia!cia@cia.gov MODE %s +v %s\r\n", chan->name, client->nick);
+               sendbuf_chan(chan);
+       }
        // send topic
        channel_sendtopic(client, chan, 1);
        // send names
@@ -1187,6 +1229,8 @@ void channel_part(struct client_data *client, struct channel *chan, const char *
                trie_free(&chan->liste);
                trie_free(&chan->listI);
                trie_free(&chan->listq);
+               trie_free(&chan->listwo);
+               trie_free(&chan->listwv);
                free(chan->chankey);
                free(chan);
        }
index 3b7e76b..73e85ed 100644 (file)
--- a/ircfmt.c
+++ b/ircfmt.c
@@ -105,11 +105,11 @@ void rpl_created(struct client_data *client) // 003
 }
 void rpl_myinfo(struct client_data *client) // 004
 {
-       copy_strf(&databuf, ":%s 004 %s PatchyIRCD 0.0.1 iworZ beIqklPimnst\n", hostname, client->nick);
+       copy_strf(&databuf, ":%s 004 %s PatchyIRCD 0.0.1 iworZ beIqwklPimnst\n", hostname, client->nick);
 }
 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=beIq,k,l,Pimnst CHANTYPES=#& PREFIX=(ov)@+ STATUSMSG=@+ :are supported by this server\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=@+ :are supported by this server\n", hostname, client->nick, MAX_NICKLEN-1);
 
 }
 #if 0