IRCCore
— IRC protocol client¶
A simple and generic class for interacting with the IRC protocol.
-
class
pyircbot.irccore.
IRCCore
(servers, loop, rate_limit=True, rate_max=5.0, rate_int=1.1)[source]¶ Bases:
object
-
act_JOIN
(channel, priority=3)[source]¶ Use the /join command
Parameters: channel (str) – the channel to attempt to join
-
act_KICK
(channel, who, comment='', priority=2)[source]¶ Use the /kick <user> <message> command
Parameters:
-
act_NICK
(newNick, priority=2)[source]¶ Use the /nick command
Parameters: newNick (str) – new nick for the bot
-
act_PONG
(data, priority=1)[source]¶ Use the /pong command - respond to server pings
Parameters: data (str) – the string or number the server sent with it’s ping
-
act_QUIT
(message, priority=2)[source]¶ Use the /quit command
Parameters: message (str) – quit message
-
act_USER
(username, hostname, realname, priority=2)[source]¶ Use the USER protocol command. Used during connection
Parameters:
-
alive
= None¶ True if we should try to stay connected
-
bind_addr
= None¶ Optionally bind to a specific address. This should be a (host, port) tuple.
-
buffer
= None¶ cStringIO used as a buffer
-
connected
= None¶ If we’re connected or not
-
connection_family
= None¶ Socket family. 0 will auto-detect ipv4 or v6. Change this to socket.AF_INET or socket.AF_INET6 force use of ipv4 or ipv6.
-
static
decodePrefix
(prefix)[source]¶ Given a prefix like nick!username@hostname, return an object with these properties
Parameters: prefix (str) – the prefix to disassemble Returns: object – an UserPrefix object with the properties nick, username, hostname or a ServerPrefix object with the property hostname
-
fire_hook
(command, args=None, prefix=None, trailing=None)[source]¶ Run any listeners for a specific hook
Parameters:
-
kill
(message='Help! Another thread is killing me :(', forever=True)[source]¶ Send quit message, flush queue, and close the socket
Parameters: message (str) – Quit message to send before disconnecting
-
log
= None¶ Reference to logger object
-
packetAsObject
(command, args, prefix, trailing)[source]¶ Given an irc message’s args, prefix, and trailing data return an object with these properties
Parameters: - args (list) – list of args from the IRC packet
- prefix (ServerPrefix or UserPrefix) – prefix object parsed from the IRC packet
- trailing (str) – trailing data from the IRC packet
Returns: object – a IRCEvent object with the
args
,prefix
,trailing
-
port
= None¶ Server port
-
removeHook
(command, method)[source]¶ Internal. Disable (disconnect) a single hook of a module
Parameters:
-
sendRaw
(data, priority=None)[source]¶ Send data on the wire. Lower priorities are sent first. :param data: unicode data to send. will be converted to utf-8 :param priority: numerical priority value. If not None, the message will likely be sent first. Otherwise, an
ever-increasing sequence number is used to maintain order. For a minimum priority message, use a priority value of sys.maxsize.
-
server
= None¶ Current server index
-
servers
= None¶ List of server address
-