11.03.2016, 23:23
Hey guys,
I'm using IRC bots to log my server but for some reason some of the bots do not login into the channel.
I'm using 6 bots at the moment when only 2 are online at a time. Here are some of the scripts
Publics and whatnot:
Defines:
+REPing the helpers
I'm using IRC bots to log my server but for some reason some of the bots do not login into the channel.
I'm using 6 bots at the moment when only 2 are online at a time. Here are some of the scripts
PHP код:
OnGameModeInit()
{
echo_Init();
/...
PHP код:
forward echo_Init();
public echo_Init()
{
if(TEST_MODE == 0)
{
SetTimerEx("9Delay", 500, 0, "d", 1); // Connect the first bot with a delay of 2 seconds
SetTimerEx("IRC_ConnectDelay", 750, 0, "d", 2); // Connect the second bot with a delay of 3 seconds
SetTimerEx("IRC_ConnectDelay", 1000, 0, "d", 3);
SetTimerEx("IRC_ConnectDelay", 1250, 0, "d", 4);
SetTimerEx("IRC_ConnectDelay", 1500, 0, "d", 5);
SetTimerEx("IRC_ConnectDelay", 1750, 0, "d", 6); // Connect the second bot with a delay of 4 seconds
}
gGroupID = IRC_CreateGroup(); // Create a group (the bots will be added to it upon connect)
}
forward echo_Exit();
public echo_Exit()
{
IRC_Quit(gBotID[0], "TEST->> www.TEST.com"); // Disconnect the first bot
IRC_Quit(gBotID[1], "TEST->> www.TEST.com"); // Disconnect the second bot
IRC_Quit(gBotID[2], "TEST->> www.TEST.com"); // Disconnect the second bot
IRC_Quit(gBotID[3], "TEST->> www.TEST.com");
IRC_Quit(gBotID[4], "TEST->> www.TEST.com");
IRC_Quit(gBotID[5], "TEST->> www.TEST.com");
IRC_DestroyGroup(gGroupID); // Destroy the group
}
forward IRC_ConnectDelay(tempid);
public IRC_ConnectDelay(tempid)
{
switch (tempid)
{
case 1:
{
gBotID[0] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_1_MAIN_NICKNAME, BOT_1_REALNAME, BOT_1_USERNAME);
}
case 2:
{
gBotID[1] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_2_MAIN_NICKNAME, BOT_2_REALNAME, BOT_2_USERNAME);
}
case 3:
{
gBotID[2] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_3_NICKNAME, BOT_3_REALNAME, BOT_3_USERNAME);
}
case 4:
{
gBotID[3] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_4_NICKNAME, BOT_4_REALNAME, BOT_4_USERNAME);
}
case 5:
{
gBotID[4] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_5_NICKNAME, BOT_5_REALNAME, BOT_5_USERNAME);
}
case 6:
{
gBotID[5] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_6_NICKNAME, BOT_6_REALNAME, BOT_6_USERNAME);
}
}
return 1;
}
/*
The IRC callbacks are below. Many of these are simply derived from parsed
raw messages received from the IRC server. They can be used to inform the
bot of new activity in any of the channels it has joined.
*/
public IRC_OnConnect(botid)
{
printf("*** IRC_OnConnect: Bot ID %d connected!", botid);
SetTimerEx("IRC_JoinDelay", 1000, 0, "d", botid);
IRC_JoinChannel(botid, IRC_CHANNEL, "TEST");
IRC_JoinChannel(botid, IRC_IDLE);
IRC_JoinChannel(botid, IRC_LIVE, "TEST");
IRC_JoinChannel(botid, IRC_CMD, "TEST");
IRC_JoinChannel(botid, IRC_DMG, "TEST");
IRC_AddToGroup(gGroupID, botid); // Add the IRC bot to the group
return 1;
}
forward IRC_JoinDelay(botid);
public IRC_JoinDelay(botid)
{
IRC_JoinChannel(botid, IRC_CHANNEL, "TEST");
IRC_JoinChannel(botid, IRC_IDLE);
IRC_JoinChannel(botid, IRC_LIVE, "TEST");
IRC_JoinChannel(botid, IRC_CMD, "TEST");
IRC_JoinChannel(botid, IRC_DMG, "TEST");
}
/*
Note that this callback is executed whenever a current connection is closed
OR whenever a connection attempt fails. Reconnecting too fast can flood the
IRC server and possibly result in a ban. It is recommended to set up
connection reattempts on a timer, as demonstrated here.
*/
public IRC_OnDisconnect(botid)
{
// printf("*** IRC_OnDisconnect: Bot ID %d disconnected!", botid);
if (botid == gBotID[0])
{
SetTimerEx("IRC_ConnectDelay", 1000, 0, "d", 1); // Wait 10 seconds for the first bot
}
else if (botid == gBotID[1])
{
SetTimerEx("IRC_ConnectDelay", 1500, 0, "d", 2); // Wait 15 seconds for the second bot
}
else if (botid == gBotID[2])
{
SetTimerEx("IRC_ConnectDelay", 2000, 0, "d", 3); // Wait 15 seconds for the third bot
}
else if (botid == gBotID[3])
{
SetTimerEx("IRC_ConnectDelay", 2500, 0, "d", 4); // Wait 15 seconds for the third bot
}
else if (botid == gBotID[4])
{
SetTimerEx("IRC_ConnectDelay", 3000, 0, "d", 5); // Wait 15 seconds for the third bot
}
else if (botid == gBotID[5])
{
SetTimerEx("IRC_ConnectDelay", 3500, 0, "d", 6); // Wait 15 seconds for the third bot
}
// printf("*** IRC_OnDisconnect: Bot ID %d attempting to reconnect...", botid);
IRC_RemoveFromGroup(gGroupID, botid); // Remove the IRC bot from the group
return 1;
}
public IRC_OnJoinChannel(botid, channel[])
{
printf("*** IRC_OnJoinChannel: Bot ID %d joined channel %s!", botid, channel);
return 1;
}
PHP код:
#define BOT_1_MAIN_NICKNAME "[1]TEST"
#define BOT_1_NICKNAME "[1]TEST"
#define BOT_1_REALNAME "[1]TEST" // This is the name that will only be visible in a whois
#define BOT_1_USERNAME "[1]TEST" // This will be in front of the hostname (username@hostname)
#define BOT_1_ALTERNATE_NICKNAME "[1]TEST"
#define BOT_2_MAIN_NICKNAME "[2]TEST"
#define BOT_2_REALNAME "[2]TEST"
#define BOT_2_USERNAME "[2]TEST"
#define BOT_2_ALTERNATE_NICKNAME "[2]TEST"
#define BOT_2_NICKNAME "[2]TEST"
#define BOT_3_MAIN_NICKNAME "[3]TEST"
#define BOT_3_NICKNAME "[3]TEST"
#define BOT_3_REALNAME "[3]TEST"
#define BOT_3_USERNAME "[3]TEST"
#define BOT_3_ALTERNATE_NICKNAME "[3]TEST"
#define BOT_4_MAIN_NICKNAME "[4]TEST"
#define BOT_4_NICKNAME "[4]TEST"
#define BOT_4_REALNAME "[4]TEST"
#define BOT_4_USERNAME "[4]TEST"
#define BOT_4_ALTERNATE_NICKNAME "[4]TEST"
#define BOT_5_MAIN_NICKNAME "[5]TEST"
#define BOT_5_NICKNAME "[5]TEST"
#define BOT_5_REALNAME "[5]TEST"
#define BOT_5_USERNAME "[5]TEST"
#define BOT_5_ALTERNATE_NICKNAME "[5]TEST"
#define BOT_6_MAIN_NICKNAME "[6]TEST"
#define BOT_6_NICKNAME "[6]TEST"
#define BOT_6_REALNAME "[6]TEST"
#define BOT_6_USERNAME "[6]TEST"
#define BOT_6_ALTERNATE_NICKNAME "[6]TEST"
#define IRC_SERVER "irc.opera.com"
#define IRC_PORT 6667
#define IRC_CHANNEL "#TEST.echo"
#define IRC_IDLE "#TEST"
#define IRC_LIVE "#TEST.live"
#define IRC_CMD "#TEST.cmd"
#define IRC_DMG "#TEST.dmg"