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
|
@ -17,7 +17,7 @@ class Server(IRCObject.Object):
|
|||
self.id = id
|
||||
self.alias = alias
|
||||
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.connected = False
|
||||
|
|
|
@ -157,9 +157,9 @@ class Module(ModuleManager.BaseModule):
|
|||
|
||||
@utils.hook("received.server-notice")
|
||||
def server_notice(self, event):
|
||||
line = "-*{~SOURCE}- {MSG}"
|
||||
line = "-*{~NAME}- {MSG}"
|
||||
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")
|
||||
def invite(self, event):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import uuid
|
||||
from src import IRCBuffer, utils
|
||||
from src import IRCBuffer, IRCLine, utils
|
||||
|
||||
def _from_self(server, source):
|
||||
if source:
|
||||
|
@ -20,28 +20,22 @@ def message(events, event):
|
|||
if len(event["line"].args) > 1:
|
||||
message = event["line"].args[1]
|
||||
|
||||
if not from_self and (
|
||||
not event["line"].source or
|
||||
not event["server"].name or
|
||||
event["line"].source.hostmask == event["server"].name or
|
||||
target_str == "*"):
|
||||
if event["line"].source:
|
||||
source = event["line"].source
|
||||
if (not event["server"].nickname
|
||||
or not source
|
||||
or source.hostmask == event["server"].name):
|
||||
if source:
|
||||
event["server"].name = event["line"].source.hostmask
|
||||
|
||||
source = (event["server"].name or
|
||||
event["server"].connection_params.hostname)
|
||||
|
||||
events.on("received.server-notice").call(message=message,
|
||||
message_split=message.split(" "), server=event["server"],
|
||||
source=source)
|
||||
return
|
||||
else:
|
||||
source = IRCLine.parse_hostmask(event["server"].name)
|
||||
target_str = event["server"].nickname or "*"
|
||||
|
||||
if from_self:
|
||||
user = event["server"].get_user(event["server"].nickname)
|
||||
else:
|
||||
user = event["server"].get_user(event["line"].source.nickname,
|
||||
username=event["line"].source.username,
|
||||
hostname=event["line"].source.hostname)
|
||||
user = event["server"].get_user(source.nickname,
|
||||
username=source.username,
|
||||
hostname=source.hostname)
|
||||
|
||||
# strip prefix_symbols from the start of target, for when people use
|
||||
# e.g. 'PRIVMSG +#channel :hi' which would send a message to only
|
||||
|
|
Loading…
Reference in a new issue