Skip to content

Instantly share code, notes, and snippets.

@19007361
Created September 8, 2022 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 19007361/d5e2d62b362aa5e27387e17e684e5a4a to your computer and use it in GitHub Desktop.
Save 19007361/d5e2d62b362aa5e27387e17e684e5a4a to your computer and use it in GitHub Desktop.
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