aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar jesopo2018-11-14 21:28:27 +0000
committerGravatar jesopo2018-11-14 21:28:27 +0000
commit378f4b1f9324b9d04e89410c506779155a5cc355 (patch)
tree77a3a2905c88e3e98fa9e7098feec2f95096022a /src/utils
parentStrip font from the last message in a channel before trying to translate it (diff)
signature
Better parsing of CTCP messages, support raw.send.privmsg/raw.send.notice in
modules/line_handler.py
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/irc.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/utils/irc.py b/src/utils/irc.py
index c39c84bc..c208e9d9 100644
--- a/src/utils/irc.py
+++ b/src/utils/irc.py
@@ -245,3 +245,17 @@ class IRCConnectionParameters(object):
self.username = username
self.realname = realname
self.args = args
+
+class CTCPMessage(object):
+ def __init__(self, command: str, message: str):
+ self.command = command
+ self.message = message
+def parse_ctcp(s: str) -> typing.Optional[CTCPMessage]:
+ ctcp = s.startswith("\x01")
+ if s.startswith("\x01"):
+ ctcp_command, sep, ctcp_message = s[1:].partition(" ")
+ if message.endswith("\x01"):
+ message = message[:-1]
+ return CTCPMessage(ctcp_command, ctcp_message)
+
+ return None