simplify snotice detection, handle as normal NOTICE
This commit is contained in:
parent
ab2ed90ef9
commit
d919e5c345
3 changed files with 15 additions and 21 deletions
src
|
@ -17,7 +17,7 @@ class Server(IRCObject.Object):
|
||||||
self.id = id
|
self.id = id
|
||||||
self.alias = alias
|
self.alias = alias
|
||||||
self.connection_params = connection_params
|
self.connection_params = connection_params
|
||||||
self.name = None # type: typing.Optional[str]
|
self.name = connection_params.hostname
|
||||||
self.version = None # type: typing.Optional[str]
|
self.version = None # type: typing.Optional[str]
|
||||||
|
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
|
|
@ -157,9 +157,9 @@ class Module(ModuleManager.BaseModule):
|
||||||
|
|
||||||
@utils.hook("received.server-notice")
|
@utils.hook("received.server-notice")
|
||||||
def server_notice(self, event):
|
def server_notice(self, event):
|
||||||
line = "-*{~SOURCE}- {MSG}"
|
line = "-*{~NAME}- {MSG}"
|
||||||
self._event("server-notice", event["server"], line, None,
|
self._event("server-notice", event["server"], line, None,
|
||||||
formatting={"MSG": event["message"], "~SOURCE": event["source"]})
|
formatting={"MSG": event["message"], "~NAME": event["server"].name})
|
||||||
|
|
||||||
@utils.hook("received.invite")
|
@utils.hook("received.invite")
|
||||||
def invite(self, event):
|
def invite(self, event):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import uuid
|
import uuid
|
||||||
from src import IRCBuffer, utils
|
from src import IRCBuffer, IRCLine, utils
|
||||||
|
|
||||||
def _from_self(server, source):
|
def _from_self(server, source):
|
||||||
if source:
|
if source:
|
||||||
|
@ -20,28 +20,22 @@ def message(events, event):
|
||||||
if len(event["line"].args) > 1:
|
if len(event["line"].args) > 1:
|
||||||
message = event["line"].args[1]
|
message = event["line"].args[1]
|
||||||
|
|
||||||
if not from_self and (
|
source = event["line"].source
|
||||||
not event["line"].source or
|
if (not event["server"].nickname
|
||||||
not event["server"].name or
|
or not source
|
||||||
event["line"].source.hostmask == event["server"].name or
|
or source.hostmask == event["server"].name):
|
||||||
target_str == "*"):
|
if source:
|
||||||
if event["line"].source:
|
|
||||||
event["server"].name = event["line"].source.hostmask
|
event["server"].name = event["line"].source.hostmask
|
||||||
|
else:
|
||||||
source = (event["server"].name or
|
source = IRCLine.parse_hostmask(event["server"].name)
|
||||||
event["server"].connection_params.hostname)
|
target_str = event["server"].nickname or "*"
|
||||||
|
|
||||||
events.on("received.server-notice").call(message=message,
|
|
||||||
message_split=message.split(" "), server=event["server"],
|
|
||||||
source=source)
|
|
||||||
return
|
|
||||||
|
|
||||||
if from_self:
|
if from_self:
|
||||||
user = event["server"].get_user(event["server"].nickname)
|
user = event["server"].get_user(event["server"].nickname)
|
||||||
else:
|
else:
|
||||||
user = event["server"].get_user(event["line"].source.nickname,
|
user = event["server"].get_user(source.nickname,
|
||||||
username=event["line"].source.username,
|
username=source.username,
|
||||||
hostname=event["line"].source.hostname)
|
hostname=source.hostname)
|
||||||
|
|
||||||
# strip prefix_symbols from the start of target, for when people use
|
# strip prefix_symbols from the start of target, for when people use
|
||||||
# e.g. 'PRIVMSG +#channel :hi' which would send a message to only
|
# e.g. 'PRIVMSG +#channel :hi' which would send a message to only
|
||||||
|
|
Loading…
Add table
Reference in a new issue