3 * argv[0] - nick / *auth
5 static USERAUTH_CALLBACK(neonserv_cmd_wipeinfo_nick_lookup);
6 static void neonserv_cmd_wipeinfo_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nick, char *auth);
8 struct neonserv_cmd_wipeinfo_cache {
9 struct ClientSocket *client, *textclient;
10 struct UserNode *user;
11 struct ChanNode *chan;
16 static CMD_BIND(neonserv_cmd_wipeinfo) {
17 if(argv[0][0] == '*') {
20 neonserv_cmd_wipeinfo_async1(client, getTextBot(), user, chan, event, argv[0], argv[0]);
22 struct UserNode *cuser = getUserByNick(argv[0]);
24 cuser = createTempUser(argv[0]);
25 cuser->flags |= USERFLAG_ISTMPUSER;
27 if(cuser->flags & USERFLAG_ISAUTHED) {
28 neonserv_cmd_wipeinfo_async1(client, getTextBot(), user, chan, event, argv[0], cuser->auth);
30 struct neonserv_cmd_wipeinfo_cache *cache = malloc(sizeof(*cache));
32 perror("malloc() failed");
35 cache->client = client;
36 cache->textclient = getTextBot();
40 cache->nick = strdup(argv[0]);
41 get_userauth(cuser, neonserv_cmd_wipeinfo_nick_lookup, cache);
46 static USERAUTH_CALLBACK(neonserv_cmd_wipeinfo_nick_lookup) {
47 struct neonserv_cmd_wipeinfo_cache *cache = data;
50 reply(cache->textclient, cache->user, "NS_USER_UNKNOWN", cache->nick);
52 else if(!(user->flags & USERFLAG_ISAUTHED)) {
54 reply(cache->textclient, cache->user, "NS_USER_NEED_AUTH", cache->nick);
57 neonserv_cmd_wipeinfo_async1(cache->client, cache->textclient, cache->user, cache->chan, cache->event, user->nick, user->auth);
62 static void neonserv_cmd_wipeinfo_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nick, char *auth) {
63 //we've got a valid auth now...
67 printf_mysql_query("SELECT `user_id` FROM `users` WHERE `user_user` = '%s'", escape_string(auth));
69 if ((row = mysql_fetch_row(res)) != NULL) {
70 userid = atoi(row[0]);
71 //check if the user is already added
72 printf_mysql_query("SELECT `chanuser_access`, `chanuser_id` FROM `chanusers` WHERE `chanuser_cid` = '%d' AND `chanuser_uid` = '%d'", chan->channel_id, userid);
74 if ((row = mysql_fetch_row(res)) != NULL) {
75 if(atoi(row[0]) >= getChannelAccess(user, chan, 0)) {
77 event->flags |= CMDFLAG_OPLOG;
79 reply(textclient, user, "NS_USER_OUTRANKED", nick);
84 printf_mysql_query("UPDATE `chanusers` SET `chanuser_infoline` = '' WHERE `chanuser_id` = '%s'", row[1]);
85 reply(textclient, user, "NS_WIPEINFO_DONE", nick, chan->name);
90 reply(textclient, user, "NS_NOT_ON_USERLIST", nick, chan->name);