diff --git a/commands.py b/commands.py index 9f4c39f..768a98c 100644 --- a/commands.py +++ b/commands.py @@ -1,4 +1,6 @@ from functools import wraps +from irctokens import build + from youtube import YouTube @@ -10,6 +12,9 @@ class Command: def mesg(self, msg): self.util.mesg(msg) + def notice(self, msg): + self.util.notice(msg) + def send(self, msg): self.util.send(msg) @@ -113,19 +118,16 @@ class Command: @cmd def ctcp(self, prefix, cmd, pm, line, admin, mesg): """CTCP responses""" + notice=self.notice ctcp = cmd[1:] if ctcp.startswith("PING"): - if not ctcp.endswith("\x01"): - ctcp = ctcp + "\x01" - self.send(f"NOTICE {self.util.target} \x01" + ctcp) + if not ctcp.endswith("\x01"): ctcp=ctcp+"\x01" + print(ctcp) + self.notice(ctcp) elif ctcp.startswith("SOURCE"): - self.send( - f"NOTICE {self.util.target} \x01SOURCE " - + self.config.self.source - + "\x01" - ) + self.notice("\x01SOURCE "+self.config.self.source+"\x01") elif ctcp.startswith("CLIENTINFO"): - self.send(f"NOTICE {self.util.target} \x01CLIENTINFO PING SOURCE\x01") + self.notice("\x01CLIENTINFO PING SOURCE\x01") @adm def quit(self, prefix, cmd, pm, line, admin, mesg): diff --git a/config.py b/config.py index 2e00309..8937baa 100644 --- a/config.py +++ b/config.py @@ -6,11 +6,11 @@ class config: source = "https://tildegit.org/jan6/bot6" class server: - name = "tilde.chat" - host = "tilde.chat" + name = "libera" + host = "irc.libera.chat" port = 6697 ssl = True - channel = "#botsix" + channel = "##jan6" capabilities = [ "message-tags", diff --git a/stuff.py b/stuff.py index d415f86..54220ee 100755 --- a/stuff.py +++ b/stuff.py @@ -95,7 +95,7 @@ def stuff(bot, sock): if line.command == "INVITE": send(irctokens.build("JOIN", [line.params[1]]).format()) elif line.command == "PRIVMSG": - if not "batch" in line.tags: + if line.tags == None or "batch" not in line.tags: is_pm = False target = line.params[0] if target == self_nick: diff --git a/util.py b/util.py index ebb9f72..ef1f51e 100644 --- a/util.py +++ b/util.py @@ -61,11 +61,16 @@ class Util: else: self.send("NICK " + nick) - def mesg(self, msg: str, t=None): - if t == None: - t = self.target + def _m(self, msg: str, t=None): + if t == None: t = self.target msg = str(msg).partition("\n")[0] if len(msg) >= 900: msg = msg[:900] self.mesg("message too long!") + return t,msg + def mesg(self, msg: str, t=None): + t,msg=self._m(msg,t) self.send(irctokens.build("PRIVMSG", [t, str(msg)]).format()) + def notice(self, msg: str, t=None): + t,msg=self._m(msg,t) + self.send(irctokens.build("NOTICE", [t, str(msg)]).format())