4 * argv[1] (optional) nick mask
6 static USERLIST_CALLBACK(neonserv_cmd_opall_userlist_lookup);
7 static void neonserv_cmd_opall_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nickmask);
9 struct neonserv_cmd_opall_cache {
10 struct ClientSocket *client, *textclient;
11 struct UserNode *user;
16 static CMD_BIND(neonserv_cmd_opall) {
17 if(!argc || strcmp(argv[0], "FORCE")) {
18 reply(getTextBot(), user, "NS_OPALL_SECURITY", chan->name);
21 struct neonserv_cmd_opall_cache *cache = malloc(sizeof(*cache));
23 perror("malloc() failed");
26 cache->client = client;
27 cache->textclient = getTextBot();
31 cache->nickmask = strdup(argv[1]);
33 cache->nickmask = NULL;
34 get_userlist_with_invisible(chan, neonserv_cmd_opall_userlist_lookup, cache);
37 static USERLIST_CALLBACK(neonserv_cmd_opall_userlist_lookup) {
38 struct neonserv_cmd_opall_cache *cache = data;
39 neonserv_cmd_opall_async1(cache->client, cache->textclient, cache->user, chan, cache->event, cache->nickmask);
41 free(cache->nickmask);
45 static void neonserv_cmd_opall_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nickmask) {
47 struct ChanUser *chanuser;
48 struct ModeBuffer *modeBuf;
49 modeBuf = initModeBuffer(client, chan);
50 for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
51 if(nickmask && match(nickmask, chanuser->user->nick)) continue;
52 if(chanuser->flags & CHANUSERFLAG_OPPED) continue;
53 modeBufferOp(modeBuf, chanuser->user->nick);
56 freeModeBuffer(modeBuf);
57 reply(textclient, user, "NS_OPALL_DONE", done_users, chan->name);