unescape incoming messages

This commit is contained in:
cynic 2022-08-02 22:35:52 -04:00
parent 54d2281452
commit 448aa9d411
1 changed files with 3 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import requests, websockets, asyncio, json, re, threading, time
from ircked.bot import irc_bot from ircked.bot import irc_bot
from ircked.message import * from ircked.message import *
import traceback import traceback
import html
class bird_inst(): class bird_inst():
def __init__(self, endpoint, httpendpoint, config): def __init__(self, endpoint, httpendpoint, config):
@ -49,6 +50,7 @@ class bird_inst():
except Exception as e: print("hey buddy your shits fucked thought you might want to know", e) except Exception as e: print("hey buddy your shits fucked thought you might want to know", e)
def handle_message(self, ctx): def handle_message(self, ctx):
print("btw i just got this", ctx["data"]["message"]["text"]) print("btw i just got this", ctx["data"]["message"]["text"])
ctx["data"]["message"]["text"] = html.unescape(ctx["data"]["message"]["text"])
if ctx["data"]["message"]["name"] == self.config["deek_user"]: return if ctx["data"]["message"]["name"] == self.config["deek_user"]: return
mesg = ctx["data"]["message"]["text"].replace("\n", " ") mesg = ctx["data"]["message"]["text"].replace("\n", " ")
chunks = list(mesg[0+i:400+i] for i in range(0, len(mesg), 400)) chunks = list(mesg[0+i:400+i] for i in range(0, len(mesg), 400))
@ -56,6 +58,7 @@ class bird_inst():
self.irc.sendraw(privmsg.build(self.config["irc_nick"], self.config["irc_chan"], ctx["data"]["message"]["name"]+": "+m).msg) self.irc.sendraw(privmsg.build(self.config["irc_nick"], self.config["irc_chan"], ctx["data"]["message"]["name"]+": "+m).msg)
def handle_avatar(self, ctx): pass def handle_avatar(self, ctx): pass
def handle_files(self, ctx): def handle_files(self, ctx):
ctx["data"]["message"]["text"] = html.unescape(ctx["data"]["message"]["text"])
self.irc.sendraw(privmsg.build(self.config["irc_nick"], self.config["irc_chan"], ctx["data"]["message"]["name"]+": "+ctx["data"]["message"]["text"]).msg) self.irc.sendraw(privmsg.build(self.config["irc_nick"], self.config["irc_chan"], ctx["data"]["message"]["name"]+": "+ctx["data"]["message"]["text"]).msg)
for f in ctx["data"]["files"]: for f in ctx["data"]["files"]:
self.irc.sendraw(privmsg.build(self.config["irc_nick"], self.config["irc_chan"], f"({ctx['name']} uploaded file: {self.httpendpoint}/storage/files/{f['name']})").msg) self.irc.sendraw(privmsg.build(self.config["irc_nick"], self.config["irc_chan"], f"({ctx['name']} uploaded file: {self.httpendpoint}/storage/files/{f['name']})").msg)