SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 16/04/2012, 09:02 PM   #1
BlueG
Beta Tester
 
Join Date: Sep 2007
Posts: 210
Reputation: 238
Default IRC Bot

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 Code:
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 Code:
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 Code:
// 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
BlueG is offline   Reply With Quote
Old 16/04/2012, 09:22 PM   #2
Richie©
Huge Clucker
 
Richie©'s Avatar
 
Join Date: Feb 2012
Location: Norway
Posts: 204
Reputation: 38
Default Re: IRC Bot

Does it have any benefits compared to the plugin by incognito?
Richie© is offline   Reply With Quote
Old 16/04/2012, 09:37 PM   #3
AndreT
Gangsta
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 940
Reputation: 339
Default Re: IRC Bot

Quote:
Originally Posted by Richie© View Post
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.
AndreT is offline   Reply With Quote
Old 17/04/2012, 01:05 AM   #4
Juninho_Oakley
Huge Clucker
 
Juninho_Oakley's Avatar
 
Join Date: Aug 2011
Location: Fim do Mundo
Posts: 493
Reputation: 25
Default Re: IRC Bot

Good Job...
__________________
Favorite Games





Graphic Card


User

Juninho_Oakley is offline   Reply With Quote
Old 17/04/2012, 10:48 AM   #5
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: INDIA !!! :)) Punjab
Posts: 1,088
Reputation: 107
Default Re: IRC Bot

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 View Post
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 [google , youtube and et.c..] ;
Ideas can never end :P

Last edited by Niko_boy; 17/04/2012 at 11:58 AM.
Niko_boy is offline   Reply With Quote
Old 07/08/2012, 02:36 AM   #6
Luka P.
High-roller
 
Luka P.'s Avatar
 
Join Date: Feb 2009
Posts: 1,621
Reputation: 11
Default Re: IRC Bot

@Niko_boy I don't think you understand what sockets are
http://en.wikipedia.org/wiki/Network_socket
Luka P. is offline   Reply With Quote
Old 07/08/2012, 02:42 AM   #7
2KY
Gangsta
 
2KY's Avatar
 
Join Date: Jan 2012
Location: United States
Posts: 940
Reputation: 126
Default Re: IRC Bot

Quote:
Originally Posted by Luka P. View Post
@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!
__________________
"Teach how to think, not what to think."
2KY is online now   Reply With Quote
Old 20/06/2013, 04:54 AM   #8
richardcor91
Big Clucker
 
Join Date: Apr 2011
Location: Portugal
Posts: 83
Reputation: 30
Default Re: IRC Bot

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!
richardcor91 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 05:00 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.