diff options
author | cqst <cqst@cqstia.com> | 2025-08-22 18:21:30 -0700 |
---|---|---|
committer | cqst <cqst@cqstia.com> | 2025-08-22 18:21:30 -0700 |
commit | 90ec23ae26af49c167e9bbe000eeb40520db95c3 (patch) | |
tree | 62e038412c3c0fc2ca4166ef436c7deaa395574d | |
parent | f77c2dfda255a78274471bb3bed6663a878b2d66 (diff) |
better chooser
-rw-r--r-- | notcqst.py | 32 |
1 files changed, 22 insertions, 10 deletions
@@ -1,8 +1,12 @@ import socket import random -from time import sleep +import time from yt_dlp import YoutubeDL + +# TODO eradicate global variables +# TODO add SSL support + reconnect = 0 text_str = 0 server = "irc.libera.chat" @@ -16,10 +20,23 @@ channel_string = ("JOIN " + channel + "\n") send_to_channel_str = ("PRIVMSG " + channel + " :Hello " + "\r\n") +def ping(): + if "PING" in text_str: + split_str = text_str.split(" ") + print(split_str) + print(split_str) + print(split_str) + print(split_str) + print(split_str) + print("PONG\n") + irc.send((bytes("PONG :" + split_str[1] + "\r\n", 'utf-8'))) + + def check_youtube(): if "https://youtube.com" in text_str or "https://www.youtube.com" in text_str: split_str = text_str.split('https://') - vid_url = split_str[1].strip() + 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) @@ -33,13 +50,7 @@ def check_youtube(): def command_choose(split_spaces): - print(split_spaces) - arr_hack = len(split_spaces) - arr_hack -= 2 - choices = [] - for x in range(arr_hack): - choices.append(split_spaces[x+2]) - print(choices) + choices = split_spaces[2:] decision = random.choice(choices) irc.send((bytes("PRIVMSG " + channel + " :" + decision + "\r\n", 'utf-8'))) @@ -64,6 +75,7 @@ def command_flag(): def parse_cmd(): + ping() command_flag() check_youtube() @@ -92,7 +104,7 @@ def connect_loop(): irc.close() global reconnect reconnect += 1 - sleep(10) + time.sleep(10) connect_checked() |