#include "ChanNode.h"
#include "UserNode.h"
#include "ChanUser.h"
+#include "ModeNode.h"
#include "ClientSocket.h"
#define WHOQUEUETYPE_ISONQUEUE 0x01
break;
}
if(bot == NULL) return;
- struct WHOQueueEntry* entry = addWHOQueueEntry(bot);
- entry->type = WHOQUEUETYPE_ISONQUEUE | WHOQUEUETYPE_USERLIST;
- entry->chan = chan;
- entry->callback = callback;
- entry->data = data;
- //WHO ".$channel->getName().",".$id." d%tuhnaf,".$id
- putsock(bot, "WHO %s,%d %%tuhnaf,%d", chan->name, entry->type, entry->type);
+ //check if we really need to who the channel
+ int do_who = (!(chan->flags & CHANFLAG_RECEIVED_USERLIST));
+ if(!do_who) {
+ struct ChanUser *chanuser;
+ for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
+ if(!(chanuser->user->flags & (USERFLAG_ISAUTHED | USERFLAG_ISIRCOP | USERFLAG_ISBOT)) && (time(0) - chanuser->user->last_who) > REWHO_TIMEOUT) {
+ do_who = 1;
+ break;
+ }
+ }
+ }
+ if(do_who) {
+ struct WHOQueueEntry* entry = addWHOQueueEntry(bot);
+ entry->type = WHOQUEUETYPE_ISONQUEUE | WHOQUEUETYPE_USERLIST;
+ entry->chan = chan;
+ entry->callback = callback;
+ entry->data = data;
+ putsock(bot, "WHO %s,%d %%tuhnaf,%d", chan->name, entry->type, entry->type);
+ } else
+ callback(bot, chan, data);
}
void get_userlist_with_invisible(struct ChanNode *chan, userlist_callback_t callback, void *data) {
break;
}
if(bot == NULL) return;
- struct WHOQueueEntry* entry = addWHOQueueEntry(bot);
- entry->type = WHOQUEUETYPE_ISONQUEUE | WHOQUEUETYPE_USERLIST;
- entry->chan = chan;
- entry->callback = callback;
- entry->data = data;
- //WHO ".$channel->getName().",".$id." d%tuhnaf,".$id
- putsock(bot, "WHO %s,%d d%%tuhnaf,%d", chan->name, entry->type, entry->type);
+ //check if we really need to who the channel
+ //invisible users can only be present if chanmode +D or +d is set!
+ int do_who = (!(chan->flags & CHANFLAG_RECEIVED_USERLIST)) || (isModeSet(chan->modes, 'd') || isModeSet(chan->modes, 'D'));
+ if(!do_who) {
+ struct ChanUser *chanuser;
+ for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
+ if(!(chanuser->user->flags & (USERFLAG_ISAUTHED | USERFLAG_ISIRCOP | USERFLAG_ISBOT)) && (time(0) - chanuser->user->last_who) > REWHO_TIMEOUT) {
+ do_who = 1;
+ break;
+ }
+ }
+ }
+ if(do_who) {
+ struct WHOQueueEntry* entry = addWHOQueueEntry(bot);
+ entry->type = WHOQUEUETYPE_ISONQUEUE | WHOQUEUETYPE_USERLIST;
+ entry->chan = chan;
+ entry->callback = callback;
+ entry->data = data;
+ putsock(bot, "WHO %s,%d d%%tuhnaf,%d", chan->name, entry->type, entry->type);
+ } else
+ callback(bot, chan, data);
}
void get_userauth(struct UserNode *user, userauth_callback_t callback, void *data) {
break;
}
if(bot == NULL) bot = getBots(SOCKET_FLAG_READY, NULL);
+ //check if we really need to who the user
+ if((user->flags & (USERFLAG_ISAUTHED | USERFLAG_ISIRCOP | USERFLAG_ISBOT | USERFLAG_ISSERVER)) || (time(0) - user->last_who) <= REWHO_TIMEOUT) {
+ callback(bot, user->nick, user, data);
+ return;
+ }
struct WHOQueueEntry* entry = addWHOQueueEntry(bot);
entry->type = WHOQUEUETYPE_ISONQUEUE | WHOQUEUETYPE_USERAUTH;
entry->user = user;
}
}
user->flags = (user->flags & ~USERFLAG_ISIRCOP) | userflags;
+ user->last_who = time(0);
if(!*user->ident)
strcpy(user->ident, argv[2]);
if(!*user->host)
} else if(type & WHOQUEUETYPE_USERAUTH) {
//:OGN2.OnlineGamesNet.net 354 Skynet 1 pk910 2001:41d0:2:1d3b::babe Skynet pk910
entry->type |= WHOQUEUETYPE_FOUND;
+ entry->user->last_who = time(0);
if(strcmp(argv[5], "0") && !(entry->user->flags & USERFLAG_ISAUTHED)) {
strcpy(entry->user->auth, argv[5]);
entry->user->flags |= USERFLAG_ISAUTHED;