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