execute mysql_check only if a query fails.
[NeonServV5.git] / cmd_neonserv_opall.c
1
2 /*
3 * argv[0]    "force"
4 * argv[1]    (optional) nick mask
5 */
6
7 static CMD_BIND(neonserv_cmd_opall) {
8     int done_users = 0;
9     char *nickmask = NULL;
10     struct ChanUser *chanuser;
11     struct ModeBuffer *modeBuf;
12     if(!argc || strcmp(argv[0], "FORCE")) {
13         reply(getTextBot(), user, "NS_OPALL_SECURITY", chan->name);
14         return;
15     }
16     if(argc > 1)
17         nickmask = argv[1];
18     modeBuf = initModeBuffer(client, chan);
19     for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
20         if(nickmask && match(nickmask, chanuser->user->nick)) continue;
21         if(chanuser->flags & CHANUSERFLAG_OPPED) continue;
22         modeBufferOp(modeBuf, chanuser->user->nick);
23         done_users++;
24     }
25     freeModeBuffer(modeBuf);
26     reply(getTextBot(), user, "NS_OPALL_DONE", done_users, chan->name);
27 }