16.04.2012, 21:02
IRC Bot v0.1
This include allows you to easily connect/control multiple IRC bots. It requires the socket plugin to work.PAWN functions:
pawn Код:
stock ircbot_connect(server[], port, nickname[], username[], realname[]);
stock ircbot_reconnect(botid);
stock ircbot_say(botid, receiver[], message[]);
stock ircbot_action(botid, receiver[], message[]);
stock ircbot_kick(botid, channel[], user[], reason[]);
stock ircbot_notice(botid, receiver[], message[]);
stock is_bot_connected(botid);
stock ircbot_join(botid, channel[]);
stock ircbot_part(botid, channel[], message[]);
stock ircbot_quit(botid, message[]);
stock ircbot_setmode(botid, channel[], mode[]);
stock ircbot_raw(botid, raw_cmd[]);
pawn Код:
forward onBotConnect(botid);
forward onBotDisconnect(botid);
forward onCTCPRequest(botid, user[], request_msg[], user_ident[]);
forward onChannelMessage(botid, user[], channel[], message[], user_ident[]);
forward onIRCCommand(botid, user[], channel[], command[], user_ident[]);
forward onPrivateMessage(botid, user[], message[], user_ident[]);
forward onChannelJoin(botid, user[], channel[], user_ident[]);
forward onChannelPart(botid, user[], channel[], part_msg[], user_ident[]);
forward onBotNotice(botid, source[], message[], user_ident);
forward onUserQuit(botid, user[], leaving_msg[], user_ident[]);
forward onNicknameChange(botid, user[], new_name[], user_ident[]);
forward onChannelKick(botid, user[], victim[], channel[], reason[], user_ident[]);
forward onBotInvite(botid, user[], channel[], user_ident[]);
forward onRawCommand(botid, raw_code, raw_data[]);
forward onChannelMode(botid, user[], channel[], mode[], option[], user_ident[]);
forward onTopicChange(botid, user[], channel[], topic[], user_ident[]);
pawn Код:
// simple IRC echo bot
#include <a_samp>
#include <irc_bot>
#define BOT_NICK "TestBot"
#define BOT_USERNAME "TestBot"
#define BOT_REALNAME "Test van Bot"
#define ECHO_CHANNEL "#echo_chan"
new Bot;
public OnFilterScriptInit()
{
Bot = ircbot_connect("foco.us.irc.tl", 6667, BOT_NICK, BOT_USERNAME, BOT_REALNAME); // lets connect to FoCo Net
return 1;
}
public onBotConnect(botid)
{
ircbot_join(botid, ECHO_CHANNEL);
}
public OnPlayerText(playerid, text[])
{
if(is_bot_connected(Bot)) {
new sMessage[256], sName[MAX_PLAYER_NAME];
GetPlayerName(playerid, sName, MAX_PLAYER_NAME);
format(sMessage, sizeof sMessage, "4%s: 1%s", sName, text);
ircbot_say(Bot, ECHO_CHANNEL, sMessage);
}
return 1;
}
public onIRCCommand(botid, user[], channel[], command[], user_ident[])
{
if(!strcmp(command, "!test", true)) {
ircbot_say(botid, MAIN_CHANNEL, "hi");
return 1;
}
- Pastebin: http://pastebin.com/bdCvxxNV
- Mirror: http://files.g-stylezzz.com/irc_bot.inc