-/* bot_NeonBackup.c - NeonServ v5.4
+/* bot_NeonBackup.c - NeonServ v5.5
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
};
static void neonbackup_bot_ready(struct ClientSocket *client) {
+ if(client->botid != BOTID)
+ return;
MYSQL_RES *res;
MYSQL_ROW row;
client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0);
- client->flags |= SOCKET_FLAG_REQUEST_INVITE;
+ client->flags |= SOCKET_FLAG_REQUEST_INVITE | SOCKET_FLAG_REQUEST_OP;
client->botid = BOTID;
client->clientid = atoi(row[7]);
connect_socket(client);
}
void neonbackup_recover_chan(struct ChanNode *chan) {
-
+ 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;
+ struct ModeBuffer *modeBuf;
+ modeBuf = initModeBuffer(bot, chan);
+ 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)) {
+ modeBufferOp(modeBuf, target->user->nick);
+ }
+ }
+ freeModeBuffer(modeBuf);
}
static void neonbackup_event_join(struct ChanUser *chanuser) {
register_default_language_table(msgtab);
}
-void loop_NeonBackup() {
-
-}
-
void free_NeonBackup(int type) {
unbind_allcmd(BOTID);
if(type == MODSTATE_STARTSTOP) {