+ if(userbots) {
+ char tmp[MAXLEN];
+ int sourceid;
+ for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
+ if(check_userbot_rejoin(chanuser->user)) {
+ rejoin_bot = malloc(sizeof(*rejoin_bot));
+ rejoin_bot->is_client = 0;
+ rejoin_bot->bot.userbot = malloc(sizeof(struct OplessRejoinUserbot));
+ rejoin_bot->bot.userbot->nick = strdup(chanuser->user->nick);
+ rejoin_bot->bot.userbot->auth = strdup(chanuser->user->auth);
+ rejoin_bot->next = chan->rejoin_bots;
+ chan->rejoin_bots = rejoin_bot;
+ sprintf(tmp, "General.UserBots.%s.sourcebot", chanuser->user->auth);
+ if(get_string_field(tmp)) {
+ sourceid = resolve_botalias(get_string_field(tmp));
+ if(sourceid == -1)
+ sourceid = 0;
+ } else
+ sourceid = 0;
+ bot = getChannelBot(NULL, sourceid);
+ if(!bot)
+ bot = getChannelBot(NULL, 0);
+ sprintf(tmp, "General.UserBots.%s.opless_part", chanuser->user->auth);
+ putsock(bot, get_string_field(tmp), chanuser->user->nick, chan->name);
+ }
+ }
+ }
+
+ if(botcount == 1) {
+ //we're alone
+ free(chan->rejoin_bots);
+ putsock(chanbot, "PART %s :magic hop", chan->name);
+ putsock(chanbot, "JOIN %s", chan->name);
+ } else {
+ chan->flags |= CHANFLAG_REJOINING;
+ chan->rejoin_timeout = timeq_add(10, 0, full_rejoin_timeout, chan);
+ }