diff options
-rw-r--r-- | notcqst.py | 31 |
1 files changed, 26 insertions, 5 deletions
@@ -6,6 +6,7 @@ from yt_dlp import YoutubeDL # TODO eradicate global variables +# TODO setup CertFP/SASL Auth reconnect = 0 text_str = 0 @@ -22,6 +23,22 @@ channel_string = ("JOIN " + channel + "\n") send_to_channel_str = ("PRIVMSG " + channel + " :Hello " + "\r\n") +def check_love(irc): + if "I <3 you notcqst" in text_str: + split_str = text_str.split('!') + irc.send((bytes("PRIVMSG " + channel + " :" + "I love you too, " + split_str[0] + "\r\n", 'utf-8'))) + + +def d6_roll(irc): + roll = random.randint(1, 6) + irc.send((bytes("PRIVMSG " + channel + " :" + str(roll) + "\r\n", 'utf-8'))) + + +def d20_roll(irc): + roll = random.randint(1, 20) + irc.send((bytes("PRIVMSG " + channel + " :" + str(roll) + "\r\n", 'utf-8'))) + + def ping(irc): if "PING" in text_str: split_str = text_str.split(" ") @@ -36,13 +53,13 @@ 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('https://') + split_str = text_str.split('http://') 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_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'))) @@ -62,7 +79,8 @@ def command_hello(irc): def unknown_command(irc): - irc.send((bytes("PRIVMSG " + channel + " :" + "Sorry I don't understand." + "\r\n", 'utf-8'))) + irc.send((bytes("PRIVMSG " + channel + " :" + "Sorry I don't understand." + + "\r\n", 'utf-8'))) def command_flag(irc): @@ -73,13 +91,16 @@ def command_flag(irc): match command: case "choose": command_choose(split_spaces, irc) case "hello": command_hello(irc) - case _: unknown_command() + case "d6": d6_roll(irc) + case "d20": d20_roll(irc) + case _: unknown_command(irc) def parse_cmd(irc): ping(irc) command_flag(irc) check_youtube(irc) + check_love(irc) def connect_checked(): |