+ if((criteria->flags & CMD_SEARCH_FLAG_STATES) || criteria->onchan) {
+ struct ChanNode *channel = getChanByName(row[0]);
+ if(criteria->onchan) {
+ if(!channel) continue;
+ struct ChanUser *chanuser = NULL;
+ for(chanuser = getChannelUsers(channel, NULL); chanuser; chanuser = getChannelUsers(channel, chanuser)) {
+ if(!match(criteria->onchan, chanuser->user->nick)) break;
+ }
+ if(!chanuser) continue;
+ }
+ if((criteria->flags & CMD_SEARCH_FLAG_IS_JOINED) && !channel) continue;
+ if((criteria->flags & CMD_SEARCH_FLAG_NOT_JOINED) && channel) continue;
+ if(channel && (criteria->flags & (CMD_SEARCH_FLAG_IS_OPPED | CMD_SEARCH_FLAG_NOT_OPPED | CMD_SEARCH_FLAG_IS_VOICED | CMD_SEARCH_FLAG_NOT_VOICED))) {
+ int flags = 0;
+ struct ClientSocket *bot;
+ for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
+ if(bot->botid == client->botid) {
+ struct ChanUser *chanuser = getChanUser(bot->user, channel);
+ if(chanuser) {
+ flags = chanuser->flags;
+ break;
+ }
+ }
+ }
+ if((criteria->flags & CMD_SEARCH_FLAG_IS_OPPED) && !(flags & CHANUSERFLAG_OPPED)) continue;
+ if((criteria->flags & CMD_SEARCH_FLAG_NOT_OPPED) && (flags & CHANUSERFLAG_OPPED)) continue;
+ if((criteria->flags & CMD_SEARCH_FLAG_IS_VOICED) && !(flags & CHANUSERFLAG_VOICED)) continue;
+ if((criteria->flags & CMD_SEARCH_FLAG_NOT_VOICED) && (flags & CHANUSERFLAG_VOICED)) continue;
+ }
+ }