implemented handling notices in IRCLineHandler, including server notices
This commit is contained in:
parent
ad68527688
commit
2ea2dd17da
2 changed files with 27 additions and 0 deletions
|
@ -70,6 +70,7 @@ def handle_PING(data):
|
||||||
@handler(description="the first line sent to a registered client", default_event=True)
|
@handler(description="the first line sent to a registered client", default_event=True)
|
||||||
def handle_001(data):
|
def handle_001(data):
|
||||||
server = data.server
|
server = data.server
|
||||||
|
server.name = Utils.remove_colon(data.prefix)
|
||||||
server.set_own_nickname(data.args[0])
|
server.set_own_nickname(data.args[0])
|
||||||
server.send_whois(server.nickname)
|
server.send_whois(server.nickname)
|
||||||
|
|
||||||
|
@ -309,6 +310,28 @@ def handle_PRIVMSG(data):
|
||||||
action=action, server=data.server)
|
action=action, server=data.server)
|
||||||
user.log.add_line(user.nickname, message, action)
|
user.log.add_line(user.nickname, message, action)
|
||||||
|
|
||||||
|
@handler(description="we've received a notice")
|
||||||
|
def handle_NOTICE(data):
|
||||||
|
nickname, username, hostname = Utils.seperate_hostmask(data.prefix)
|
||||||
|
message = "" if len(data.args) < 2 else data.args[1]
|
||||||
|
message_split = message.split(" ")
|
||||||
|
target = data.args[0]
|
||||||
|
if nickname == data.server.name or target == "*":
|
||||||
|
bot.events.on("received.server-notice").call(
|
||||||
|
message=message, message_split=message_split,
|
||||||
|
server=data.server)
|
||||||
|
else:
|
||||||
|
user = data.server.get_user(nickname)
|
||||||
|
if target[0] in data.server.channel_types:
|
||||||
|
channel = data.server.get_channel(target)
|
||||||
|
bot.events.on("received.notice.channel").call(
|
||||||
|
message=message, message_split=message_split,
|
||||||
|
user=user, server=data.server, channel=channel)
|
||||||
|
elif data.server.is_own_nickname(target):
|
||||||
|
bot.events.on("received.notice.private").call(
|
||||||
|
message=message, message_split=message_split,
|
||||||
|
user=user, server=data.server)
|
||||||
|
|
||||||
@handler(description="response to a WHO command for user information", default_event=True)
|
@handler(description="response to a WHO command for user information", default_event=True)
|
||||||
def handle_352(data):
|
def handle_352(data):
|
||||||
user = data.server.get_user(data.args[5])
|
user = data.server.get_user(data.args[5])
|
||||||
|
|
|
@ -33,15 +33,19 @@ class Server(object):
|
||||||
self.last_read = None
|
self.last_read = None
|
||||||
self.attempted_join = {}
|
self.attempted_join = {}
|
||||||
self.ping_sent = False
|
self.ping_sent = False
|
||||||
|
self.name = None
|
||||||
|
|
||||||
if ipv4:
|
if ipv4:
|
||||||
self.socket = socket.socket(socket.AF_INET,
|
self.socket = socket.socket(socket.AF_INET,
|
||||||
socket.SOCK_STREAM)
|
socket.SOCK_STREAM)
|
||||||
else:
|
else:
|
||||||
self.socket = socket.socket(socket.AF_INET6,
|
self.socket = socket.socket(socket.AF_INET6,
|
||||||
socket.SOCK_STREAM)
|
socket.SOCK_STREAM)
|
||||||
|
|
||||||
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
|
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
|
||||||
self.socket.settimeout(5.0)
|
self.socket.settimeout(5.0)
|
||||||
|
|
||||||
if self.tls:
|
if self.tls:
|
||||||
context = ssl.SSLContext(OUR_TLS_PROTOCOL)
|
context = ssl.SSLContext(OUR_TLS_PROTOCOL)
|
||||||
context.options |= ssl.OP_NO_SSLv2
|
context.options |= ssl.OP_NO_SSLv2
|
||||||
|
|
Loading…
Reference in a new issue