17,6 → 17,13 |
# keltus <keltus@users.sourceforge.net> |
# |
# $Id: irclib.py,v 1.47 2008/09/25 22:00:59 keltus Exp $ |
import bisect |
import re |
import select |
import socket |
import string |
import time |
import types |
|
"""irclib -- Internet Relay Chat (IRC) protocol client library. |
|
61,14 → 68,6 |
.. [IRC specifications] http://www.irchelp.org/irchelp/rfc/ |
""" |
|
import bisect |
import re |
import select |
import socket |
import string |
import sys |
import time |
import types |
|
VERSION = 0, 4, 8 |
DEBUG = 0 |
287,7 → 286,7 |
|
arguments -- Arguments to give the function. |
""" |
self.execute_delayed(at-time.time(), function, arguments) |
self.execute_delayed(at - time.time(), function, arguments) |
|
def execute_delayed(self, delay, function, arguments=()): |
"""Execute a function after a specified time. |
300,7 → 299,7 |
|
arguments -- Arguments to give the function. |
""" |
bisect.insort(self.delayed_commands, (delay+time.time(), function, arguments)) |
bisect.insort(self.delayed_commands, (delay + time.time(), function, arguments)) |
if self.fn_to_add_timeout: |
self.fn_to_add_timeout(delay) |
|
341,7 → 340,7 |
def __init__(self, irclibobj): |
self.irclibobj = irclibobj |
|
def _get_socket(): |
def _get_socket(self): |
raise IRCError, "Not overridden" |
|
############################## |
488,9 → 487,9 |
|
try: |
if self.ssl: |
new_data = self.ssl.read(2**14) |
new_data = self.ssl.read(2 ** 14) |
else: |
new_data = self.socket.recv(2**14) |
new_data = self.socket.recv(2 ** 14) |
except socket.error, x: |
# The server hung up. |
self.disconnect("Connection reset by peer") |
845,10 → 844,10 |
"""Send a WHOIS command.""" |
self.send_raw("WHOIS " + ",".join(targets)) |
|
def whowas(self, nick, max="", server=""): |
def whowas(self, nick, maxx="", server=""): |
"""Send a WHOWAS command.""" |
self.send_raw("WHOWAS %s%s%s" % (nick, |
max and (" " + max), |
maxx and (" " + maxx), |
server and (" " + server))) |
|
class DCCConnectionError(IRCError): |
955,7 → 954,7 |
return |
|
try: |
new_data = self.socket.recv(2**14) |
new_data = self.socket.recv(2 ** 14) |
except socket.error, x: |
# The server hung up. |
self.disconnect("Connection reset by peer") |
972,7 → 971,7 |
|
# Save the last, unfinished line. |
self.previous_buffer = chunks[-1] |
if len(self.previous_buffer) > 2**14: |
if len(self.previous_buffer) > 2 ** 14: |
# Bad peer! Naughty peer! |
self.disconnect() |
return |
1228,14 → 1227,14 |
|
messages = [] |
i = 0 |
while i < len(chunks)-1: |
while i < len(chunks) - 1: |
# Add message if it's non-empty. |
if len(chunks[i]) > 0: |
messages.append(chunks[i]) |
|
if i < len(chunks)-2: |
if i < len(chunks) - 2: |
# Aye! CTCP tagged data ahead! |
messages.append(tuple(chunks[i+1].split(" ", 1))) |
messages.append(tuple(chunks[i + 1].split(" ", 1))) |
|
i = i + 2 |
|
1352,8 → 1351,6 |
for ch in mode_part: |
if ch in "+-": |
sign = ch |
elif ch == " ": |
collecting_arguments = 1 |
elif ch in unary_modes: |
if len(args) >= arg_count + 1: |
modes.append([sign, ch, args[arg_count]]) |
1374,7 → 1371,7 |
"002": "yourhost", |
"003": "created", |
"004": "myinfo", |
"005": "featurelist", # XXX |
"005": "featurelist", # XXX |
"200": "tracelink", |
"201": "traceconnecting", |
"202": "tracehandshake", |
1467,7 → 1464,7 |
"374": "endofinfo", |
"375": "motdstart", |
"376": "endofmotd", |
"377": "motd2", # 1997-10-16 -- tkil |
"377": "motd2", # 1997-10-16 -- tkil |
"381": "youreoper", |
"382": "rehashing", |
"384": "myportis", |
1496,7 → 1493,7 |
"432": "erroneusnickname", # Thiss iz how its speld in thee RFC. |
"433": "nicknameinuse", |
"436": "nickcollision", |
"437": "unavailresource", # "Nick temporally unavailable" |
"437": "unavailresource", # "Nick temporally unavailable" |
"441": "usernotinchannel", |
"442": "notonchannel", |
"443": "useronchannel", |
1517,12 → 1514,12 |
"474": "bannedfromchan", |
"475": "badchannelkey", |
"476": "badchanmask", |
"477": "nochanmodes", # "Channel doesn't support modes" |
"477": "nochanmodes", # "Channel doesn't support modes" |
"478": "banlistfull", |
"481": "noprivileges", |
"482": "chanoprivsneeded", |
"483": "cantkillserver", |
"484": "restricted", # Connection is restricted |
"484": "restricted", # Connection is restricted |
"485": "uniqopprivsneeded", |
"491": "nooperhost", |
"492": "noservicehost", |