added general notice support, switched to libera.chat, handle messages without tags
This commit is contained in:
parent
5bc9edd5c6
commit
5412493052
20
commands.py
20
commands.py
|
@ -1,4 +1,6 @@
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
from irctokens import build
|
||||||
|
|
||||||
from youtube import YouTube
|
from youtube import YouTube
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +12,9 @@ class Command:
|
||||||
def mesg(self, msg):
|
def mesg(self, msg):
|
||||||
self.util.mesg(msg)
|
self.util.mesg(msg)
|
||||||
|
|
||||||
|
def notice(self, msg):
|
||||||
|
self.util.notice(msg)
|
||||||
|
|
||||||
def send(self, msg):
|
def send(self, msg):
|
||||||
self.util.send(msg)
|
self.util.send(msg)
|
||||||
|
|
||||||
|
@ -113,19 +118,16 @@ class Command:
|
||||||
@cmd
|
@cmd
|
||||||
def ctcp(self, prefix, cmd, pm, line, admin, mesg):
|
def ctcp(self, prefix, cmd, pm, line, admin, mesg):
|
||||||
"""CTCP responses"""
|
"""CTCP responses"""
|
||||||
|
notice=self.notice
|
||||||
ctcp = cmd[1:]
|
ctcp = cmd[1:]
|
||||||
if ctcp.startswith("PING"):
|
if ctcp.startswith("PING"):
|
||||||
if not ctcp.endswith("\x01"):
|
if not ctcp.endswith("\x01"): ctcp=ctcp+"\x01"
|
||||||
ctcp = ctcp + "\x01"
|
print(ctcp)
|
||||||
self.send(f"NOTICE {self.util.target} \x01" + ctcp)
|
self.notice(ctcp)
|
||||||
elif ctcp.startswith("SOURCE"):
|
elif ctcp.startswith("SOURCE"):
|
||||||
self.send(
|
self.notice("\x01SOURCE "+self.config.self.source+"\x01")
|
||||||
f"NOTICE {self.util.target} \x01SOURCE "
|
|
||||||
+ self.config.self.source
|
|
||||||
+ "\x01"
|
|
||||||
)
|
|
||||||
elif ctcp.startswith("CLIENTINFO"):
|
elif ctcp.startswith("CLIENTINFO"):
|
||||||
self.send(f"NOTICE {self.util.target} \x01CLIENTINFO PING SOURCE\x01")
|
self.notice("\x01CLIENTINFO PING SOURCE\x01")
|
||||||
|
|
||||||
@adm
|
@adm
|
||||||
def quit(self, prefix, cmd, pm, line, admin, mesg):
|
def quit(self, prefix, cmd, pm, line, admin, mesg):
|
||||||
|
|
|
@ -6,11 +6,11 @@ class config:
|
||||||
source = "https://tildegit.org/jan6/bot6"
|
source = "https://tildegit.org/jan6/bot6"
|
||||||
|
|
||||||
class server:
|
class server:
|
||||||
name = "tilde.chat"
|
name = "libera"
|
||||||
host = "tilde.chat"
|
host = "irc.libera.chat"
|
||||||
port = 6697
|
port = 6697
|
||||||
ssl = True
|
ssl = True
|
||||||
channel = "#botsix"
|
channel = "##jan6"
|
||||||
|
|
||||||
capabilities = [
|
capabilities = [
|
||||||
"message-tags",
|
"message-tags",
|
||||||
|
|
2
stuff.py
2
stuff.py
|
@ -95,7 +95,7 @@ def stuff(bot, sock):
|
||||||
if line.command == "INVITE":
|
if line.command == "INVITE":
|
||||||
send(irctokens.build("JOIN", [line.params[1]]).format())
|
send(irctokens.build("JOIN", [line.params[1]]).format())
|
||||||
elif line.command == "PRIVMSG":
|
elif line.command == "PRIVMSG":
|
||||||
if not "batch" in line.tags:
|
if line.tags == None or "batch" not in line.tags:
|
||||||
is_pm = False
|
is_pm = False
|
||||||
target = line.params[0]
|
target = line.params[0]
|
||||||
if target == self_nick:
|
if target == self_nick:
|
||||||
|
|
11
util.py
11
util.py
|
@ -61,11 +61,16 @@ class Util:
|
||||||
else:
|
else:
|
||||||
self.send("NICK " + nick)
|
self.send("NICK " + nick)
|
||||||
|
|
||||||
def mesg(self, msg: str, t=None):
|
def _m(self, msg: str, t=None):
|
||||||
if t == None:
|
if t == None: t = self.target
|
||||||
t = self.target
|
|
||||||
msg = str(msg).partition("\n")[0]
|
msg = str(msg).partition("\n")[0]
|
||||||
if len(msg) >= 900:
|
if len(msg) >= 900:
|
||||||
msg = msg[:900]
|
msg = msg[:900]
|
||||||
self.mesg("message too long!")
|
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())
|
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())
|
||||||
|
|
Loading…
Reference in New Issue