add IRCLine.parse_human() to allow for "!raw /msg jesopo hello"

This commit is contained in:
jesopo 2019-11-27 17:38:17 +00:00
parent f62fc8c2a1
commit 747ba5c646
2 changed files with 15 additions and 1 deletions

View file

@ -21,7 +21,12 @@ class Module(ModuleManager.BaseModule):
:usage: <raw line>
:permission: raw
"""
line = event["server"].send_raw(event["args"])
if IRCLine.is_human(event["args"]):
line = IRCLine.parse_human(event["args"])
else:
line = IRCLine.parse_line(event["args"])
line = event["server"].send(line)
if not line == None:
event["stdout"].write("Sent: %s" % line.parsed_line.format())
else:

View file

@ -197,6 +197,15 @@ def parse_line(line: str) -> ParsedLine:
args.append(typing.cast(str, trailing))
return ParsedLine(command, args, source, tags)
def is_human(line: str):
return len(line) > 1 and line[0] == "/"
def parse_human(line: str) -> typing.Optional[ParsedLine]:
command, _, args = line[1:].partition(" ")
if command == "msg":
target, _, message = args.partition(" ")
return ParsedLine("PRIVMSG", [target, message])
return None
class SentLine(IRCObject.Object):
def __init__(self, events: "EventManager.Events",
send_time: datetime.datetime, hostmask: str, line: ParsedLine):