youtube links in /me messages work now (or other ctcp messages)
This commit is contained in:
parent
93c00542d5
commit
5f78254e63
|
@ -104,14 +104,14 @@ class Command:
|
|||
command = "dbg"
|
||||
elif cmd == "dbg2" or cmd.startswith("dbg2 "):
|
||||
command = "dbg2"
|
||||
elif cmd.startswith("\x01"):
|
||||
command = "ctcp"
|
||||
elif (
|
||||
"https://www.youtube.com/watch?v="
|
||||
or "https://m.youtube.com/watch?v="
|
||||
or "https://youtu.be/"
|
||||
) in cmd or cmd.startswith("yt "):
|
||||
command = "yt"
|
||||
elif cmd.startswith("\x01") or self.is_ctcp:
|
||||
command = "ctcp"
|
||||
else:
|
||||
# self.mesg(cmd)
|
||||
return
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class config:
|
||||
class self:
|
||||
nick = "bot6"
|
||||
username = "jan6_bot"
|
||||
username = "jan6_bot" #you can set it to your username
|
||||
realname = "jan6's bot"
|
||||
source = "https://tildegit.org/jan6/bot6"
|
||||
|
||||
|
@ -11,7 +11,7 @@ class config:
|
|||
port = 6697
|
||||
ssl = True
|
||||
channel = "##jan6"
|
||||
autojoin = ["##sharing"]
|
||||
autojoin = ["##share","#1337331"]
|
||||
|
||||
class admin:
|
||||
accounts = ["jan6"]
|
||||
|
@ -19,7 +19,7 @@ class config:
|
|||
|
||||
class cmd:
|
||||
prefixes = ["6", "'"]
|
||||
# disabled commands, won't run via normal means
|
||||
# disabled commands, won't run via normal means, probably
|
||||
disabled = []
|
||||
# admin-only override,
|
||||
# useful for testing broken commands which should still be normal-user accessible
|
||||
|
|
40
stuff.py
40
stuff.py
|
@ -20,6 +20,7 @@ def stuff(bot, sock):
|
|||
wanted_caps = config.capabilities
|
||||
chan = config.server.channel # main channel
|
||||
autojoin_done = False
|
||||
is_ctcp = False
|
||||
is_pm = False
|
||||
mode = "init"
|
||||
|
||||
|
@ -43,9 +44,16 @@ def stuff(bot, sock):
|
|||
admin_only,
|
||||
)
|
||||
|
||||
command, command.util, config, util, prefixes, admin_accounts, admin_users, admin_only = (
|
||||
configure()
|
||||
)
|
||||
(
|
||||
command,
|
||||
command.util,
|
||||
config,
|
||||
util,
|
||||
prefixes,
|
||||
admin_accounts,
|
||||
admin_users,
|
||||
admin_only,
|
||||
) = configure()
|
||||
send = util.send
|
||||
|
||||
send(irctokens.build("NICK", [config.self.nick]).format())
|
||||
|
@ -106,26 +114,28 @@ def stuff(bot, sock):
|
|||
elif line.command == "PRIVMSG":
|
||||
if line.tags == None or "batch" not in line.tags:
|
||||
is_pm = False
|
||||
is_ctcp = False
|
||||
target = line.params[0]
|
||||
if target == self_nick:
|
||||
target = line.source.split("!")[0]
|
||||
is_pm = True
|
||||
util.target = target
|
||||
command.util.target = target
|
||||
cmd = line.params[1]
|
||||
|
||||
if (
|
||||
is_pm
|
||||
or line.params[1].startswith(self_nick)
|
||||
or line.params[1][0] in prefixes
|
||||
or line.params[1].startswith("https://")
|
||||
or cmd.startswith(self_nick)
|
||||
or cmd[0] in prefixes
|
||||
or cmd.startswith("https://")
|
||||
or (
|
||||
"https://www.youtube.com/watch?v="
|
||||
or "https://m.youtube.com/watch?v="
|
||||
or "https://youtu.be/"
|
||||
)
|
||||
in line.params[1]
|
||||
in cmd
|
||||
):
|
||||
try:
|
||||
cmd = line.params[1]
|
||||
# if message in a channel, remove prefixes
|
||||
if is_pm:
|
||||
command.prefix = None
|
||||
|
@ -164,6 +174,7 @@ def stuff(bot, sock):
|
|||
# update command module's info dynamically for line info
|
||||
command.util.target = target
|
||||
command._line = line
|
||||
command.is_ctcp = is_ctcp
|
||||
command.pm = is_pm
|
||||
command.line = cmd
|
||||
command.admin = is_adm
|
||||
|
@ -172,9 +183,16 @@ def stuff(bot, sock):
|
|||
command.prefix = prefix
|
||||
|
||||
if is_adm and cmd.startswith("reload"):
|
||||
command, command.util, config, util, prefixes, admin_accounts, admin_users, admin_only = (
|
||||
configure()
|
||||
)
|
||||
(
|
||||
command,
|
||||
command.util,
|
||||
config,
|
||||
util,
|
||||
prefixes,
|
||||
admin_accounts,
|
||||
admin_users,
|
||||
admin_only,
|
||||
) = configure()
|
||||
util.target = target
|
||||
send = util.send
|
||||
command._line = line
|
||||
|
|
|
@ -33,6 +33,7 @@ class YouTube:
|
|||
return f"{m}m {s}s"
|
||||
|
||||
def yt(self, url):
|
||||
url=url.rstrip("\x01")
|
||||
global y, z
|
||||
y, z = {}, {}
|
||||
p = self.parseprop()
|
||||
|
|
Loading…
Reference in New Issue