SA-MP Forum
November 20, 2008, 03:08:25 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Login Register  



Pages: [1] 2 3 ... 32
  Print  
Author Topic: [REL] IRC plugin v1.1 (with filterscript)  (Read 32908 times)
Jacob
Big Clucker
**
Posts: 188


View Profile WWW
« on: July 01, 2007, 02:53:40 pm »

Cross-compatible IRC plugin v1.1
With this plugin, you can connect to, send and receive messages to and from IRC servers!


New features of 1.1
  • Dozens of bugs resolved, server crashes fixed
  • Supports multiple connections at the same time (upto 5)
  • Properly supported as a filterscript
  • New native ircGetUserLevel will get any user's level (~, @, etc) in any joined channel
  • New native ircGetUserList will get the entire userlist of any joined channel separated by spaces
  • New native ircSendRawCommand will send any raw IRC command to the server, giving you complete control
  • Callbacks are now called properly (from the same thread), circumventing the majority of Linux crashes

How to install
First, download the package from the link at the bottom of this post.  You may either compile the project yourself (I have provided makefiles for both windows and Linux) or use the already-compiled libraries in the plugins directory.
  • Plugin: copy irc.dll (or irc.so if you're on Linux) to your /plugins directory.
  • Include: copy a_irc.inc to your /pawn/includes directory.
  • Example filterscript: copy ircFS.amx and ircFS.pwn to your /filterscripts directory.

How to use
  • Natives: these are functions you can call from PAWN.
    • ircConnect(server[], port, user[]) - connects to an IRC server. This will return a connection ID.  You will use this ID as the first parameter of all the other natives. Password parameter was removed in 1.1.
    • ircSay(connection, channel[], message[]) - sends a message to an IRC channel.
    • ircJoinChan(connection, channel[]) - joins an IRC channel.
    • ircPartChan(connection, channel[]) - parts a joined IRC channel.
    • ircGetUserList(connection, channel[], dest[], size) - places the userlist of the requested channel into 'dest' parameter
    • ircGetUserLevel(connection, channel[], user[], dest[]) - places the user level of the requested user into 'dest' parameter
    • ircSendRawCommand(connection, cmd[]) - sends a raw command to the IRC server (i.e: 'NICK :jacob123' will change your bot's name to jacob123
    • ircSetMode(connection, channel[], modes[], users[]) - set channel modes (providing server is an op)
    • ircDisconnect(connection) - disconnects from the requested IRC server (must use connection ID
    • ircPollEvents() - you must call this function every 500ms if you want the callbacks below to be executed. See example filterscript.


  • Callbacks: these are functions called by the plugin.
    • ircOnConnect(connection) - called when a connection is established.
    • ircOnUserSay(connection, channel[], user[], message[]) - called when a user says something in an active channel.
    • ircOnUserPart(connection, channel[], user[]) - called when a user parts an active channel.
    • ircOnUserJoin(connection, channel[], user[]) - called when a user joins an active channel.

1.1 release notes
  • 1.1 uses callbacks in a totally different way that has resolved crashes. For you to take advantage of the new callback system, you must call the native ircPollEvents in a 500ms timer.  See the example filterscript.
  • The password parameter from 1.0 has been removed in 1.1 due to a crash it was causing.  To identify your bot with NickServ, use ircSendRawCommand.  See the example filterscript.
  • When calling ircGetUserLevel, the size of dest[] must be 4.  The following levels are supported by the plugin:
    • ~ owner
    • @ op
    • & admin
    • % halfop
    • + voice
    • - normal user

Download 1.1


« Last Edit: April 27, 2008, 08:54:13 am by Towlies » Logged
Nissandrifter
Big Clucker
**
Posts: 197


View Profile WWW
« Reply #1 on: July 01, 2007, 03:18:10 pm »

Nice script. I was wondering, is it possible whether to make it detect whether the person in the IRC channel has an admin status or higher. Cause I was thinking of adding stuff like .ban and .kick, and I dont really want anyone to be able to use them commands
Logged

TRSA Website, Forums and Online Server Registration
Server IP:83.133.125.167:6600

Sneaky!
High-roller
*****
Posts: 2714


View Profile
« Reply #2 on: July 01, 2007, 04:18:31 pm »

aw nice script ya got there Cool
Logged

Jacob
Big Clucker
**
Posts: 188


View Profile WWW
« Reply #3 on: July 01, 2007, 04:51:40 pm »

Nice script. I was wondering, is it possible whether to make it detect whether the person in the IRC channel has an admin status or higher. Cause I was thinking of adding stuff like .ban and .kick, and I dont really want anyone to be able to use them commands
It is now!  I have updated both the Windows and Linux IRC libraries with the following PAWN natives:

  • ircIsOp(channel[], user[]) - returns true if user is an op in the specified channel.
  • ircSetMode(channel[], modes[], users[]) - set channel modes (providing server is an op)

I have also added Nickserv compatibility. This means the 'password' parameter of ircConnect can also identify you with Nickserv!
Logged
Ramjet.
Gangsta
****
Posts: 614


View Profile WWW
« Reply #4 on: July 01, 2007, 06:43:19 pm »

Very nice Jacob!

I can already see a new era of SA-MP IRC Echo tools Smiley.

Cheers,
Ramjet.
Logged

Visit my website!




Quote from: #cp.clan
<&dugi> i thought that my signature would be original
<&dugi> but i noticed that simon has the same
yom
High-roller
*****
Posts: 3949



View Profile
« Reply #5 on: July 01, 2007, 06:53:29 pm »

Nice work! thanks i will test it and learn from it Smiley
Logged

Filterscripts:           
Speedometer
AFK
Rcon Addon
InGame Buttons
Includes:                
Properties
Frame Creator
Apps/Tools:              
Server Restarter
Screenshots Mover
Mods Switcher

Boylett
High-roller
*****
Posts: 1578



View Profile WWW
« Reply #6 on: July 01, 2007, 11:53:57 pm »

I was trying to make one of these but couldnt work out how to use strtok in C++ (and my reference site went down). Well done Smiley
Logged

PM me if you want a domain name like: yourclan.clan.sg for free
Don't learn me how to speak english.
The Azer
Beta Tester
Gangsta
**********
Posts: 666


View Profile WWW
« Reply #7 on: July 01, 2007, 11:54:49 pm »

Very nice Jacob Smiley this is a good example of how plugins are a great addition to SA:MP <3
Logged

...
Sypher
Big Clucker
**
Posts: 64


View Profile WWW
« Reply #8 on: July 02, 2007, 12:26:18 am »

The Plugin-man strikes again. Nice! I turned it into a filterscript for easy editing, and it works perfectly.
It connects really fast.

I'd like to request some expanded functionality, if possible: sending & receiving private messages.
Do you think that's possible? It would be really useful Smiley
I saw some of the code already in your plugin but its currently not in a_irc.inc..

Also, getting the IRC userlist into an array would be a nice feature as well.
« Last Edit: July 02, 2007, 01:14:19 am by Sypher » Logged
Static
Big Clucker
**
Posts: 184


View Profile WWW
« Reply #9 on: July 02, 2007, 01:04:55 am »

I was trying to make one of these but couldnt work out how to use strtok in C++ (and my reference site went down). Well done Smiley

I know I probably shouldn't but http://www.cplusplus.com/reference/clibrary/cstring/strtok.html Wink

Nice work jacob, will come in useful for a number of reasons.
Logged

Jacob
Big Clucker
**
Posts: 188


View Profile WWW
« Reply #10 on: July 02, 2007, 02:14:19 am »

I'd like to request some expanded functionality, if possible: sending & receiving private messages.
Do you think that's possible? It would be really useful Smiley
It's already possible; using ircSay, you can also send private messages to users.  Just insert the username as the channel[] parameter and you're good to go.  This is the same case for ircOnUserSay.

Server admins: previously, using format() in ircOnUserSay would be dangerous as users could crash the server by typing the % character.  This has been fixed in the Windows version, please re-download! I will update the Linux library tomorrow when I have more time. (6/02/07)
« Last Edit: July 02, 2007, 02:39:55 am by Jacob » Logged
Simon
High-roller
*****
Posts: 1824


View Profile
« Reply #11 on: July 02, 2007, 02:43:09 am »

Woah. Awesome, easy to set up and easy to use. I'm gonna have a good fun with this Smiley.
Logged
d.wine
Huge Clucker
***
Posts: 489


View Profile
« Reply #12 on: July 02, 2007, 03:46:22 am »

Amazing! First nice plugin I see.
Logged

My works:
Filterscripts: [Bad Commandtext Checker] [Temporary Ban System]
Gamemodes: [GangFighting RPG] (coming soon)





Rapidshare sucks!
MaXx001
Big Clucker
**
Posts: 112


View Profile WWW
« Reply #13 on: July 02, 2007, 05:55:52 am »

Really nice plugin! Easy to use and  it just works!

I have one question: How do i send commands?

if i send "/join #meh" with ircSay then it is just displayed as a message and is not registered as a command.

Maybe an ircCommand(channel[], command[]) would do the trick Smiley


Logged

Author of GTA:Online
Simon
High-roller
*****
Posts: 1824


View Profile
« Reply #14 on: July 02, 2007, 06:06:36 am »

Maybe an ircCommand(channel[], command[]) would do the trick Smiley

Yes, something like that would be nice.

Also things like in mIRC when you can type /msg %#chan and it will send the message to halfops and higher (without beeping).

Maybe a ircIsLevel(channel[], user[], level); or maybe even a ircGetLevel(channel[], user[]) to check if a user is a certain level.


« Last Edit: July 02, 2007, 06:13:02 am by Simon » Logged
Pages: [1] 2 3 ... 32
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF one | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!