diff options
-rw-r--r-- | notcqst.py | 32 |
1 files changed, 21 insertions, 11 deletions
@@ -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) |