+#include "cmd_neonserv.h"
+
/*
-* argv[0] nick[,*auth[,*!*@mask[...]]]
-* argv[1-*] reason
+* argv[0-*] nick[,*auth[,*!*@mask[...]]]
*/
static USERLIST_CALLBACK(neonserv_cmd_ban_userlist_lookup);
-static void neonserv_cmd_ban_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, char *masks);
+static void neonserv_cmd_ban_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *masks);
struct neonserv_cmd_ban_cache {
struct ClientSocket *client, *textclient;
struct UserNode *user;
+ struct Event *event;
char *masks;
};
-static CMD_BIND(neonserv_cmd_ban) {
+CMD_BIND(neonserv_cmd_ban) {
struct neonserv_cmd_ban_cache *cache = malloc(sizeof(*cache));
if (!cache) {
perror("malloc() failed");
cache->client = client;
cache->textclient = getTextBot();
cache->user = user;
+ cache->event = event;
cache->masks = strdup(merge_argv_char(argv, 0, argc, ','));
- get_userlist(chan, neonserv_cmd_ban_userlist_lookup, cache);
+ get_userlist_with_invisible(chan, neonserv_cmd_ban_userlist_lookup, cache);
}
static USERLIST_CALLBACK(neonserv_cmd_ban_userlist_lookup) {
struct neonserv_cmd_ban_cache *cache = data;
- neonserv_cmd_ban_async1(cache->client, cache->textclient, cache->user, chan, cache->masks);
+ neonserv_cmd_ban_async1(cache->client, cache->textclient, cache->user, chan, cache->event, cache->masks);
free(cache->masks);
free(cache);
}
-static void neonserv_cmd_ban_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, char *masks) {
+static void neonserv_cmd_ban_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *masks) {
int done_masks = 0, provided_masks = 0, skip, match_count, total_match;
char *mask, *nextmask;
char hostmask_buffer[NICKLEN+USERLEN+HOSTLEN+3];
struct ModeBuffer *modeBuf;
modeBuf = initModeBuffer(client, chan);
nextmask = masks;
- check_mysql();
while((mask = nextmask)) {
nextmask = strstr(mask, ",");
if(nextmask) {
reply(getTextBot(), user, "NS_BAN_DONE", done_masks, chan->name, total_match);
else
reply(getTextBot(), user, "NS_BAN_FAIL", client->user->nick);
+ if(done_masks)
+ logEvent(event);
}