IRC Plugin Creation Guide

API

Custom Commands

SmallIRC allows for diverting text from IRC's chatbox into IRC commands or other actions. The Plugin class gives a handy feature to make this simple.

def irc_message(self, irc, command, parameters):
    print "%s %s" % (irc, command, parameters)
    if(command.lower() == "hide"):
        irc.ircwidget.get_toplevel().iconify()
        return True #Returning True stops this bieng sent to the server
    return False # Returning False allows other plugins to see it, and if none of them want it
            # then it is sent to the server, assuming it is a command

Methods

smallirc.irc.send

def send(Command, Parameters)

Command Must be a string containing the name of the IRC Command
Parameters Must be a string containing the parameters of the IRC Command

Commands must either be commands according to the IRC protocol, or commands supplied by other plugins
http://www.mirc.com/help/rfc1459.txt
Mostly, this shouldn't be used without a very good knowledge of the internals of IRC

smallirc.irc.msg

def msg(Channel, Message)

Channel Must be a string containing a Username or channel to private message
Message Must be a string containing the message

Sends a PM or Public message to the username or channel given in Channel

smallirc.irc.join

def join(Channel)

Channel Must be a string containing the channel to join

Attempts to join the Channel

smallirc.irc.part

def part(Channel = None, Reason = "")

Channel Must be a string containing a Channel to part from, or None. If None, it assumes the currently viewed Channel
Reason Must be a string containing the reason for parting the Channel

Leaves a Channel, with a message

smallirc.irc.notice

def notice(To, Message)

To Must be a string containing a Channel or Username to send the notice to
Message Must be a string containing the message to notify the recipient(s) with

smallirc.irc.kick

def kick(Channel = None, Victim= "", Reason= "")

Channel Must be a string containing a Channel to kick the victim from, or None. If None, it assumes the currently viewed Channel
Victim Must be a string containing the username of the user you wish to kick from the channel
Reason Must be a string containing the reason you have kicked the user from the channel

Signals

Runewins IRC object is a sub-class of a gobject, making all the IRC messages (PRIVMSG/KICK etc) merely a signal to .connect() to

Please Note : Reading the userlist of a room during a callback that may have changed it could cause Very Unexpected Results.

Here are a list of signals from Runewins IRC:

irc_msg

def callback(IRC, room, from, text, …)

IRC The IRC client main object
room A String containing the channel that the message came from
from A String containing the username of the user who sent the message
text A String containing the message the user sent
User passed parameters

This signal ONLY works for Public room messages, Private messages are sent via "irc_pm"

irc_pm

def callback (IRC, from, text, …)

IRC The IRC client main object
from A String containing the username of the user who sent you the message
text A String containing the message the user sent
User passed parameters

This signal warns of Private Messages from one user directly to this user

irc_me

def callback (IRC, room, from, text, …)

IRC The IRC client main object
room A String containing the channel that the message came from
from A String containing the username of the user who sent you the message
text A String containing the message the user sent
User passed parameters

This signal warns of users using actions, normally done with "/me does action" in clients

irc_notice

def callback (IRC, from, text, …)

IRC The IRC client main object
from A String containing the username of the user who sent you the message
text A String containing the message the user sent
User passed parameters

This signal warns of users sending you a direct notification. This is mostly used by bots and services

irc_mode

def callback (IRC, user, mode, …)

IRC The IRC client main object
user A String containing the username of the user who changed the mode
mode A String containing the modes changed and the channel or user that had its mode changed
User passed parameters

This signal warns of a mode changed on a channel or user. This signal needs work before it becomes usable

irc_join

def callback (IRC, room, user, …)

IRC The IRC client main object
room A String containing the channel the user specified has joined
user A String containing the username of the user who has joined the channel
User passed parameters

This signal warns of yourself or other users joining a channel

irc_quit

def callback (IRC, user, message, …)

IRC The IRC client main object
user A String containing the username of the user who quit
message A String containing the leaving message the user specified, or a blank string
User passed parameters

This signal warns of yourself or other users leaving the whole server

irc_part

def callback (IRC, room, user, message, …)

IRC The IRC client main object
room A String containing the channel the user has left
user A String containing the username of the user who left the channel
message A String containing the leaving message the user specified, or a blank string
User passed parameters

irc_kick

def callback (IRC, room, user, kicker, reason, …)

IRC The IRC client main object
room A String containing the channel the user was kicked from
user A String containing the username of the user who was kicked
kicker A String containing the username of the kicker
reason A String containing the reason the kicker gave for kicking the user
User passed parameters

This signal warns of yourself or others bieng kicked from a channel

irc_nick

def callback (IRC, old_user, new_user, …)

IRC The IRC client main object
old_user A String containing the last known name of this user
new_user A String containing the new name of the user
User passed parameters

This signal warns of a nick name change for you or other users

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License