1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00

Messo a posto alcune cose in /cv

This commit is contained in:
Steffo 2016-09-21 16:39:27 +02:00
parent bd4b6502d1
commit 46b1ba1511

25
bot.py
View file

@ -285,15 +285,17 @@ def roll():
def cv(): def cv():
print("@" + username + ": /cv") print("@" + username + ": /cv")
# Elenco di tutte le persone online su Discord # Ottieni i dati dal server della Royal Games
tosend = "*Su Discord ora:*\n"
r = discord.getwidgetdata("176353500710699008") r = discord.getwidgetdata("176353500710699008")
musicstatus = str() # Elenco di tutte le persone online su Discord
tosend = "*Online su Discord, nel server {servername}:*\n".format(servername=r['name'])
# Qui inizia il codice peggiore di sempre
for member in r['members']: for member in r['members']:
m = dict() m = dict()
if 'bot' not in member or not member['bot']: if 'bot' not in member or not member['bot']:
# Credo di aver scritto il peggior algoritmo di sempre. gg me # Se una persona è connessa in chat vocale
if 'channel_id' in member: if 'channel_id' in member:
# Controlla il suo stato (esclusa, mutata, normale) e scegli l'emoji appropriata
if member['deaf'] or member['self_deaf']: if member['deaf'] or member['self_deaf']:
m['emoji'] = chr(128263) m['emoji'] = chr(128263)
elif member['mute'] or member['self_mute']: elif member['mute'] or member['self_mute']:
@ -301,16 +303,21 @@ def cv():
else: else:
m['emoji'] = chr(128266) m['emoji'] = chr(128266)
m['channelname'] = discord.getchannelname(r, member['channel_id']) m['channelname'] = discord.getchannelname(r, member['channel_id'])
# Altrimenti
else: else:
# Controlla il suo stato (online, in gioco, afk) e scegli l'emoji appropriata
if member['status'] == "online": if member['status'] == "online":
if 'game' in member: # Qui giace il pallino rosso se uno era in game, propongo di metterlo per quando uno sta streamando
m['emoji'] = chr(128308)
else:
m['emoji'] = chr(128309) m['emoji'] = chr(128309)
elif member['status'] == "idle": elif member['status'] == "idle":
m['emoji'] = chr(9899) m['emoji'] = chr(9899)
# Aggiungi il nome del gioco a destra del nome
if 'game' in member: if 'game' in member:
m['gamename'] = member['game']['name'] m['gamename'] = member['game']['name']
# Visualizza il nickname se presente, altrimenti visualizza l'username
if 'nick' in m:
member['username'] = m['nick']
else:
m['name'] = member['username'] m['name'] = member['username']
if 'gamename' in m and 'channelname' in m: if 'gamename' in m and 'channelname' in m:
tosend += "{emoji} *{channelname}* {name} | _{gamename}_\n".format(**m) tosend += "{emoji} *{channelname}* {name} | _{gamename}_\n".format(**m)
@ -323,11 +330,9 @@ def cv():
# Controlla se l'utente è royal music # Controlla se l'utente è royal music
elif member['id'] == "176358898851250176": elif member['id'] == "176358898851250176":
if 'game' in member: if 'game' in member:
musicstatus = "{emoji} *{channelname}* {songname}\n" \ tosend += "{emoji} *{channelname}* {songname}\n" \
.format(emoji="\U0001F3B5", channelname=discord.getchannelname(r, member['channel_id']), .format(emoji="\U0001F3B5", channelname=discord.getchannelname(r, member['channel_id']),
songname=member['game']['name']) songname=member['game']['name'])
if musicstatus != "":
tosend += musicstatus
telegram.sendmessage(tosend, sentin, source) telegram.sendmessage(tosend, sentin, source)