summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcqst <cqst@cqstia.com>2025-08-28 15:48:49 -0700
committercqst <cqst@cqstia.com>2025-08-28 15:48:49 -0700
commitcff41844ba688d45c31040dd149d7e586ef8a406 (patch)
tree54e406040f4e4d1f798506f2105084dfe07c241c
parent6c3c15f9188fcd8dcb5683e23b6351fdd38e2bf0 (diff)
handle buggy video linksHEADmaster
-rw-r--r--notcqst.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/notcqst.py b/notcqst.py
index 01422e1..c58b085 100644
--- a/notcqst.py
+++ b/notcqst.py
@@ -39,6 +39,14 @@ def d20_roll(irc):
irc.send((bytes("PRIVMSG " + channel + " :" + str(roll) + "\r\n", 'utf-8')))
+def coin_flip(irc):
+ roll = random.randint(0, 1)
+ if (roll):
+ irc.send((bytes("PRIVMSG " + channel + " :" + "heads" + "\r\n", 'utf-8')))
+ else:
+ irc.send((bytes("PRIVMSG " + channel + " :" + "tails" + "\r\n", 'utf-8')))
+
+
def ping(irc):
if "PING" in text_str:
split_str = text_str.split(" ")
@@ -52,20 +60,20 @@ def ping(irc):
def check_youtube(irc):
- if "https://youtube.com" in text_str or "https://www.youtube.com" in text_str:
- split_str = text_str.split('http://')
+ if "https://youtube.com/" in text_str or "https://www.youtube.com/" in text_str:
+ split_str = text_str.split('https://')
vid_url_www = split_str[1].strip()
vid_url = ''.join(("https://", vid_url_www))
with YoutubeDL() as ydl:
- info_dict = ydl.extract_info(vid_url, download=False)
- # video_url = info_dict.get("url", None)
- # video_id = info_dict.get("id", None)
- video_title = info_dict.get('title', None)
- channel_name = info_dict.get('channel', None)
- irc.send((bytes("PRIVMSG " + channel + " :" + channel_name + ": " + video_title + "\r\n", 'utf-8')))
- return 1
- else:
- return 0
+ try:
+ info_dict = ydl.extract_info(vid_url, download=False)
+ video_title = info_dict.get('title', None)
+ channel_name = info_dict.get('channel', None)
+ irc.send((bytes("PRIVMSG " + channel + " :" + channel_name + ": " + video_title + "\r\n", 'utf-8')))
+ return 0
+ except:
+ print("noop")
+ return 1
def command_choose(split_spaces, irc):
@@ -93,6 +101,8 @@ def command_flag(irc):
case "hello": command_hello(irc)
case "d6": d6_roll(irc)
case "d20": d20_roll(irc)
+ case "flip": coin_flip(irc)
+ case "h": irc.send((bytes("PRIVMSG " + channel + " :" + "choose hello d6 d20 flip h" + "\r\n", 'utf-8')))
case _: unknown_command(irc)