-/* bots.c - NeonServ v5.5
+/* bots.c - NeonServ v5.6
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
#include "modcmd.h"
#include "DBHelper.h"
#include "IRCEvents.h"
+#include "tools.h"
+#include "log.h"
struct cmd_bot_alias {
int botid;
struct ChanUser *chanuser;
for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
if(botid && bot->botid != botid) continue;
- if((chanuser = getChanUser(bot->user, chan)) != NULL) {
- if((chanuser->flags & CHANUSERFLAG_OPPED)) {
+ if(!chan || (chanuser = getChanUser(bot->user, chan)) != NULL) {
+ if(chan && (chanuser->flags & CHANUSERFLAG_OPPED)) {
use_bot = bot;
if(bot->flags & SOCKET_FLAG_PREFERRED) break;
} else if(bot->flags & SOCKET_FLAG_PREFERRED)
}
void requestInvite(struct UserNode *user, struct ChanNode *chan) {
- struct ClientSocket *bot, *userbot = NULL;
+ struct ClientSocket *bot;
struct ChanUser *chanuser = getChanUser(user, chan);
char invited = 0;
if(chanuser) return;
invited = 1;
putsock(bot, "INVITE %s %s", user->nick, chan->name);
}
- if(bot->user == user) {
- userbot = bot;
- }
}
}
}
botalias = malloc(sizeof(*botalias));
if (!botalias) {
- perror("malloc() failed");
+ printf_log("main", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__);
return;
}
botalias->botid = botid;