[Include] IRC Bot
#1

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[]);
Callbacks
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[]);
Sample
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;
}
Downloads
Reply
#2

Does it have any benefits compared to the plugin by incognito?
Reply
#3

Quote:
Originally Posted by Richie©
Посмотреть сообщение
Does it have any benefits compared to the plugin by incognito?
No. It is just to demonstrate the abilities of the sockets plugin. And perhaps someone who is interested in the IRC protocol can learn a few things from this (if they cannot bother to open up the IRC plugin source).

The sockets plugin can be used for a bunch of great ideas.
Reply
#4

Good Job...
Reply
#5

AHahaha saved my work i was gonna work on making IRC shit with socket plugin but i have to learn it first
and thanks BlueG for this release...
EDIT:
Quote:
Originally Posted by AndreT
Посмотреть сообщение
The sockets plugin can be used for a bunch of great ideas.
YEAH:!
i wanna try to get Radio info with socket's i have seen some PHP and mIRC [msl] scripts usin sockets to get radio info like current song , radio name , listeners and other stuff
but unsure how to use socket i wishh any tutorial be there
++ Idea like using socket to search online stuff [****** , ******* and et.c..] ;
Ideas can never end :P
Reply
#6

@Niko_boy I don't think you understand what sockets are
http://en.wikipedia.org/wiki/Network_socket
Reply
#7

Quote:
Originally Posted by Luka P.
Посмотреть сообщение
@Niko_boy I don't think you understand what sockets are
http://en.wikipedia.org/wiki/Network_socket
4 month bump.

None the less, this is a really cool include that makes this soooo much easier. Thank you!
Reply
#8

10 months bump

I'm creating a IRC filterscript with sockets plugin, but I still didn't figure out how to create a "IRC_GetUserChannelMode" function, from the official IRC plugin.
Any help would be much appreciated!
Reply
#9

Quote:
Originally Posted by richardcor91
Посмотреть сообщение
10 months bump

I'm creating a IRC filterscript with sockets plugin, but I still didn't figure out how to create a "IRC_GetUserChannelMode" function, from the official IRC plugin.
Any help would be much appreciated!
Why don't you post in THAT topic then? ¬_¬
Reply
#10

Quote:
Originally Posted by MP2
Посмотреть сообщение
Why don't you post in THAT topic then? ¬_¬
Man, my problem is related with both topics, so there's no big deal. Furthermore, I was trying to revive this topic, because it's a good piece of code to learn about sockets and IRC and, unfortunately, few people use it.

Anyway, I will ask there later if that doesn't happen...

Update: Solved with /whois command in an hardcore way lol

Update 2: I'm trying to connect to IRC with this filterscript but when I start the server I get a segmentation fault:

Код:
[05:45:37] Filterscripts
[05:45:37] ---------------
[05:45:37]   Loading filterscript 'irc_script.amx'...
[05:45:37] Starting irc_script...

[05:45:37] [debug] Server crashed while executing irc_script.amx
[05:45:37] [debug] AMX backtrace:
[05:45:37] [debug] #0 native socket_connect () [b776f440] from socket.so
[05:45:37] [debug] #1 000004cc in ircbot_connect (server[]=@0x000017c8 "foco.us.irc.tl", port=6667, nickname[]=@0x00001804 "iTestBot", username[]=@0x00001828 "iTestBot", realname[]=@0x0000184c "iTest van Bot") at E:\Programas\l\MWR 294 0.3er4\pawno\include\irc_bot.inc:49
[05:45:37] [debug] #2 00003658 in public OnFilterScriptInit () at E:\Programas\l\MWR 294 0.3er4\filterscripts\irc_script.pwn:14
[05:45:37] [debug] System backtrace:
[05:45:37] [debug] #0 b746535b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[05:45:37] [debug] #1 b745e389 in _ZN11crashdetect20PrintSystemBacktraceEPv () from plugins/crashdetect.so
[05:45:37] [debug] #2 b74608ed in _ZN11crashdetect11OnExceptionEPv () from plugins/crashdetect.so
[05:45:37] [debug] #3 b7464e68 in ?? () from plugins/crashdetect.so
[05:45:37] [debug] #4 b777a600 in ?? ()
[05:45:37] [debug] #5 b7770083 in _ZN7CSocket14connect_socketEiPci () from plugins/socket.so
[05:45:37] [debug] #6 b776f4a0 in _Z16n_connect_socketP6tagAMXPi () from plugins/socket.so
[05:45:37] [debug] #7 08093c94 in ?? () from ./samp_test
[05:45:37] [debug] #8 b7460ea7 in _ZN11crashdetect13DoAmxCallbackEiPiS0_ () from plugins/crashdetect.so
[05:45:37] [debug] #9 b746341e in ?? () from plugins/crashdetect.so
[05:45:37] [debug] #10 b746706e in amx_Exec () from plugins/crashdetect.so
[05:45:37] [debug] #11 b7460dab in _ZN11crashdetect9DoAmxExecEPii () from plugins/crashdetect.so
[05:45:37] [debug] #12 b7463457 in ?? () from plugins/crashdetect.so
[05:45:37] [debug] #13 080a9726 in ?? () from ./samp_test
[05:45:37] [debug] #14 080b2821 in ?? () from ./samp_test
[05:45:37] [debug] #15 080b2b2a in ?? () from ./samp_test
[05:45:37] [debug] #16 080b1407 in ?? () from ./samp_test
[05:45:37] [debug] #17 b7497ce6 in __libc_start_main () from /lib/libc.so.6
[05:45:37] [debug] #18 0804b521 in ?? () from ./samp_test
Any suggestion for the problem?

Notes: I'm running the script in a VPS. I tested it in a normal sa-mp host company and it worked fine. Any guesses? :/

Update 3: Solved. /etc/resolv.conf nameservers were missing.
Reply
#11

Socket plugin v0.2b update http://pastebin.com/m0mtmR4t

Changelog:

Код:
Function 'is_bot_connected' -> ircbot_isconnected
Added IRC_ prefix to all callbacks
Changed the global enum to irc* to remove conflicts with gamemodes
Added 'key' parameter to ircbot_join -> (ircbot_join(botid, channel[], key[]))
Fixed all 'socket_send' functions missing len arguments
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)