Created
September 8, 2022 15:02
-
-
Save 19007361/d5e2d62b362aa5e27387e17e684e5a4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
current_msg_id = "" | |
ro_uuid_list = [] | |
ro_count = 0 | |
current_song_id = None | |
while True: | |
song_id, song_artist, song_name = get_song() | |
if song_id is None and song_artist is None and song_name is None: | |
song_id = current_song_id | |
if current_song_id is not None and current_song_id != song_id: | |
postmsg("π½ β― " + song_artist + " - " + song_name + " π½") | |
ro_count = 0 | |
ro_uuid_list = [] | |
current_song_id = song_id | |
last_msg_user, last_msg_user_uuid, last_msg, last_msg_id = get_messages() | |
get_users_in_room() | |
if current_msg_id != last_msg_id: | |
print(last_msg_user+": "+last_msg) | |
if last_msg[:1] == "/": | |
query = last_msg[1:].split(' ') | |
print("query:", query) | |
cmd = query[0] | |
aliases = {} | |
f = open("vars/aliases", "r") | |
for line in f: | |
arr = line.split("=>=>=>") | |
aliases[arr[0]] = arr[1] | |
if cmd == "alias": | |
if not len(query) == 3: | |
postmsg("π€ Format example: /alias dog https://c.tenor.com/6xwjsmMIAIoAAAAM/happy-happy-dog.gif π€") | |
else: | |
alias = query[1] | |
url = query[2] | |
if alias in aliases: | |
postmsg("π€ Alias already exists! π€") | |
else: | |
f = open("vars/aliases", "a") | |
f.write("\n" + str(alias) + "=>=>=>" + str(url)) | |
f.close() | |
postmsg("π€ Alias added! /" + alias + " π€") | |
elif cmd == "giphy": | |
if not len(query) == 2: | |
postmsg("π€ Format example: /giphy dog π€") | |
else: | |
post_giphy(query[1]) | |
elif cmd == "ro" or cmd == "dope": | |
if last_msg_user_uuid not in ro_uuid_list: | |
ro_count += 1 | |
if ro_count == 1: | |
postmsg("row") | |
elif ro_count == 2: | |
postmsg("row, row") | |
elif ro_count == 3: | |
postmsg("row, row, row your boat gently down the stream π£ββοΈ") | |
ro_count = 0 | |
ro_uuid_list = [] | |
ro_uuid_list.append(last_msg_user_uuid) | |
elif cmd == "aliases": | |
aliases = ", ".join(["/"+x for x in sorted(aliases.keys())]) | |
postmsg("π€ Aliases: " + aliases + " π€") | |
elif cmd == "help": | |
postmsg("π€ Commands: /ro, /giphy [query], /alias [name] [gif], /aliases π€") | |
elif cmd in aliases: | |
postmsg(aliases[cmd], is_image=True) | |
current_msg_id = last_msg_id | |
time.sleep(5) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment