aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2019-11-27 17:38:17 +0000
committerGravatar jesopo2019-11-27 17:38:17 +0000
commit747ba5c646d2755cb3ab48bbe98032752723e8c6 (patch)
tree20870d3087aadcbbcb3eda504b301c9401cbfcae
parentshow username when a toot is CWed (diff)
add IRCLine.parse_human() to allow for "!raw /msg jesopo hello"
-rw-r--r--modules/admin.py7
-rw-r--r--src/IRCLine.py9
2 files changed, 15 insertions, 1 deletions
diff --git a/modules/admin.py b/modules/admin.py
index 76b6bb0c..364380d4 100644
--- a/modules/admin.py
+++ b/modules/admin.py
@@ -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:
diff --git a/src/IRCLine.py b/src/IRCLine.py
index 9f120e10..62d9e8b7 100644
--- a/src/IRCLine.py
+++ b/src/IRCLine.py
@@ -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):