pyirclib.Irclib Methods
and attributes
Documentation for pyirclib version
0.4.3
class Irclib(host,port)
Creates a new instance
of Irclib class, connecting to the host and port specified.
Returns 0 on success or
an error message describing the problem.
method login(nickname,
username='user', password = None, realname='Anonymous', hostname = 'Unknown',
servername='Server')
Log in
to the server using the specified options.
Returns 0
on success or the according RFC1459 error message
method logout(reason)
Exit
current IRC session.
method
servercmd(command) Send the given command to the server.
Returns
0 on success, 1 if the send method failed or "ERR_NOTLOGGEDIN" if the user
hasn't logged on yet
method
setnick(nickname)
Changes
the client's nick to 'nickname'
method getmessage()
Returns
a dictionary with the following values:
'nickname': the
nickname of the sender
'username': the
username of the sender
'hostname': the
hostname of the sender
'event': ERROR
| RESPONSE | PRIVMSG | JOIN | PART | QUIT | MODE | NOTICE | KILL | UNKNOWN
'recpt': In this
field, the inteded recipient is put 'channel': This field is filled with
the name of the channel in JOIN and PART messages
'text':
In RESPONSE
event, this field contains the RFC error message
In PRIVMSG event, this field contains the text of the message received
In QUIT event,
this field contains the QUIT reason
In MODE event,
this field contains the new MODE options
In NOTICE event,
this field contains the NOTICE text
In KILL event,
this field contains the reason of the kill
In UNKNOWN event,
this field is set to "DO SOMETHING HERE!". You shouldn't receive a message
like this, but if you do, please send me a mail.
In ERROR event,
this field is set to the error message
'responsetype':
The according RFC message for the RESPONSE event is put here
'seqnumber':
A sequencial number put here for future implementations. It increments
by one for each message received
Note: The getmessage()
method automatically answers PING commands
method join(channel, password = None)
Joins 'channel' with 'password' (if specified)
method list(channels = None, server=None)
Returns a list with the channels in the server in the following format:
[channel,users,topic]
method names(channels = None)
Returns a list of users directly accesible by the client in the following
format: [channel, nickname]
method whois(nickname,
server = None)
Returns a dictionary with the following values.
'nickname':
the user's nickname
'username':
the user's username
'hostname':
the user's hostname
'realname':
the user's realname
'error':
Set to 0 on success, 1 on error with the corresponding 'errormessage'
'errormessage':
method error response (ERR_NOSUCHNICK | ERR_NOSUCHSERVER
'server': The server where the user is connected
'serverinfo':
Server's information line
'isoperator':
This field is set to 1 if the user is a Server Operator, else:
0
'idle': Idle
time (in seconds)
'away': 1
if the user is away, otherwise is set to 0
'awaymessage':
Away message
'channels':
List containing the channels where the user is in.
method privmsg(entity, message)
Sends 'message' to entity (it can be a user or a channel)
method notice(entity, message)
Sends a NOTICE event to 'entity' containing 'message'
method oper(nick, password)
Gets OPER privileges using 'nick' and 'password'
method kick(channel, nick, reason)
Channel Opers only: Kicks 'nick' from 'channel' giving 'reason' as kick
message
method part(channel, reason='')
Exits channel using the optional 'reason'
method setmode(entity,mode)
Changes entity's mode to 'mode'
method setchantopic(channel,topic)
Channel Opers only: Changes channel topic
method inviteuser(nickname, channel)
Channel Opers only: Invites 'nickname' to 'channel'
method awayon(message)
Sets AWAY status, using 'message' as away message
method awayoff()
Turns off AWAY status method
method server_rehash()
Server Opers only: Causes the server to re-read its configuration file
method
method server_restart()
Server Opers only: Causes the server to restart, killing all current connections
method wallops(message)
Server Opers only: Sends a message to all connected Server Opers
method kill(nick, reason='')
Server Opers only: Kills the specified user
method getresponsetype(number)
Returns a string with the corresponding response message of the response
numbre given
method getseqnumber()
Returns the next seqnumber for messages [Internal use only]
attribute messages[]
Contains the history of messages received by getmessage()