+ struct ClientSocket *bot = getChannelBot(chan, BOTID); // prefer backup bot ;)
+ struct ChanUser *chanuser = (bot ? getChanUser(bot->user, chan) : NULL);
+ if(!chanuser || !(chanuser->flags & CHANUSERFLAG_OPPED)) {
+ //search an opped bot
+ for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
+ if((chanuser = getChanUser(bot->user, chan)) && (chanuser->flags & CHANUSERFLAG_OPPED))
+ break;
+ }
+ }
+ if(!bot) //no opped bots present... channel can't be recovered
+ return;
+ struct ClientSocket *target;
+ for(target = getBots(SOCKET_FLAG_READY, NULL); target; target = getBots(SOCKET_FLAG_READY, target)) {
+ if((target->flags & SOCKET_FLAG_REQUEST_OP) && (chanuser = getChanUser(target->user, chan)) && !(chanuser->flags & CHANUSERFLAG_OPPED)) {
+ putsock(bot, "MODE %s +o %s", chan->name, target->user->nick);
+ }
+ }