support WATCH as well as MONITOR nick nick_regain.py

This commit is contained in:
jesopo 2020-01-23 12:50:58 +00:00
parent 022eed84f6
commit 4515cf84e1

View file

@ -6,6 +6,8 @@ class Module(ModuleManager.BaseModule):
if not self._regained(server, target_nick): if not self._regained(server, target_nick):
if "MONITOR" in server.isupport: if "MONITOR" in server.isupport:
server.send_raw("MONITOR + %s" % target_nick) server.send_raw("MONITOR + %s" % target_nick)
elif "WATCH" in server.isupport:
server.send_raw("WATCH +%s" % target_nick)
else: else:
self.timers.add("ison-check", self._ison_check, 30, self.timers.add("ison-check", self._ison_check, 30,
server=server) server=server)
@ -28,6 +30,8 @@ class Module(ModuleManager.BaseModule):
if self._regained(event["server"], target_nick): if self._regained(event["server"], target_nick):
if "MONITOR" in event["server"].isupport: if "MONITOR" in event["server"].isupport:
event["server"].send_raw("MONITOR - %s" % target_nick) event["server"].send_raw("MONITOR - %s" % target_nick)
elif "WATCH" in event["server"].isupport:
event["server"].send_raw("WATCH -%s" % target_nick)
@utils.hook("received.nick") @utils.hook("received.nick")
def nick(self, event): def nick(self, event):
@ -43,12 +47,18 @@ class Module(ModuleManager.BaseModule):
server.send_nick(target_nick) server.send_nick(target_nick)
@utils.hook("received.731") @utils.hook("received.731")
def mon_offline(self, event): def monitor_offline(self, event):
target_nick = self._target(event["server"]) self._offline(event["server"], event["line"].args[1].split(","))
nicks = event["line"].args[1].split(",")
nicks = [event["server"].irc_lower(n) for n in nicks] @utils.hook("received.601")
if event["server"].irc_lower(target_nick) in nicks: def watch_offline(self, event):
event["server"].send_nick(target_nick) self._offline(event["server"], [event["line"].args[1]])
def _offline(self, server, nicks):
target_nick = self._target(server)
nicks = [server.irc_lower(n) for n in nicks]
if server.irc_lower(target_nick) in nicks:
server.send_nick(target_nick)
def _ison_check(self, timer): def _ison_check(self, timer):
server = timer.kwargs["server"] server = timer.kwargs["server"]