diff --git a/bridge.py b/bridge.py index fca680c..51fb03b 100755 --- a/bridge.py +++ b/bridge.py @@ -30,7 +30,7 @@ def handle_irc(m): @shoutbox.on(lambda m: m.channel in channels) def handle_shoutbox(m): author = Shoutbox.normalize(m.author) - shoutbox.irc_clients[author][0].send(f"#{m.channel}", f"{m.text}", bbcode=m.bbcode) + shoutbox.irc_clients[author][0].send(f"#{m.channel}", f"{m.text}") irc.start(f"Shoutbox[{nick}]", password, nick) diff --git a/irc.py b/irc.py index 03032da..55006f1 100644 --- a/irc.py +++ b/irc.py @@ -37,9 +37,6 @@ class IRC(object): self._send(f"USER {nick} * * :{nick}") self._send(f"NICK {nick}") - self._send(f"CAP REQ :message-tags") - self._waitfor(lambda m: "CAP" in m and "ACK" in m) - self._send(f"CAP END") self._waitfor(lambda m: "NOTICE" in m and "/AUTH" in m) for i in range(3): @@ -79,13 +76,9 @@ class IRC(object): logging.info(f"matched {event.__name__}") callback(message) - def send(self, target, message, bbcode=None): + def send(self, target, message): """ Send a message to the specified target (channel or user) """ - if bbcode is not None: - bbcode = self._escapetag(bbcode) - self._send(f"@planet-casio.com/v4-bbcode={bbcode} PRIVMSG {target} :{message}") - else: - self._send(f"PRIVMSG {target} :{message}") + self._send(f"PRIVMSG {target} :{message}") def receive(self): """ Receive a private message """ @@ -163,18 +156,9 @@ class IRC(object): msg = self._recv() return msg - def _escapetag(self, text): - """ Escape text as an IRC tag """ - text = text.replace("\\", "\\\\") - text = text.replace(";", "\\:") - text = text.replace(" ", "\\s") - text = text.replace("\r", "\\r") - text = text.replace("\n", "\\n") - return text - class IRCMessage(object): - r = re.compile("^(?:@[^ ]+ *)?:(?P[\w.~|\[\]]+)(?:!(?P\S+))? PRIVMSG (?P\S+) :(?P.+)") + r = re.compile("^:(?P[\w.~|\[\]]+)(?:!(?P\S+))? PRIVMSG (?P\S+) :(?P.+)") def __init__(self, raw): match = re.search(IRCMessage.r, raw) diff --git a/shoutbox.py b/shoutbox.py index 650c057..689e12f 100644 --- a/shoutbox.py +++ b/shoutbox.py @@ -22,7 +22,7 @@ class Shoutbox(object): self._handler = Thread(target=self._handle) for channel, last_id in self.channels.items(): - messages = json.loads(r.get(f"https://www.planet-casio.com/Fr/shoutbox/api/read?since={last_id}&channel={channel}&format=textbbcode").text)['messages'] + messages = json.loads(r.get(f"https://www.planet-casio.com/Fr/shoutbox/api/read?since={last_id}&channel={channel}&format=text").text)['messages'] for m in messages: self.channels[channel] = m['id'] @@ -82,7 +82,7 @@ class Shoutbox(object): for channel, last_id in self.channels.items(): # Do not spam with logs logging.getLogger().setLevel(logging.INFO) - messages = json.loads(r.get(f"https://www.planet-casio.com/Fr/shoutbox/api/read?since={last_id}&channel={channel}&format=textbbcode").text)['messages'] + messages = json.loads(r.get(f"https://www.planet-casio.com/Fr/shoutbox/api/read?since={last_id}&channel={channel}&format=text").text)['messages'] logging.getLogger().setLevel(logging.DEBUG) for m in messages: logging.debug(m) @@ -134,4 +134,3 @@ class SBMessage(object): self.author = raw['author'] self.channel = channel self.text = raw['content'] - self.bbcode = raw['bbcode']