- 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 && force) {
+ 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[0] = callback;
+ entry->module_id[0] = module_id;
+ int i;
+ for(i = 1; i < MAXCALLBACKS; i++)
+ entry->callback[i] = NULL;
+ entry->data[0] = data;
+ for(i = 1; i < MAXCALLBACKS; i++)
+ entry->data[i] = NULL;
+ putsock(bot, "WHO %s,%d d%%tuihnaf,%d", chan->name, entry->whoid, entry->whoid);
+ } else
+ callback(bot, chan, data);