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 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):
|
||||
|
|
|
@ -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",
|
||||
|
|
2
stuff.py
2
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:
|
||||
|
|
11
util.py
11
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())
|
||||
|
|
Loading…
Reference in New Issue