mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-24 03:54:20 +00:00
sdifjsif
This commit is contained in:
parent
c5e45621f2
commit
3e5afe17aa
4 changed files with 63 additions and 42 deletions
14
db.py
14
db.py
|
@ -251,12 +251,16 @@ class Dota(Base):
|
||||||
steam_id = Column(String, ForeignKey("steam.steam_id"), primary_key=True)
|
steam_id = Column(String, ForeignKey("steam.steam_id"), primary_key=True)
|
||||||
steam = relationship("Steam")
|
steam = relationship("Steam")
|
||||||
|
|
||||||
solo_mmr = Column(Integer)
|
rank_tier = Column(Integer)
|
||||||
party_mmr = Column(Integer)
|
|
||||||
|
|
||||||
wins = Column(Integer, nullable=False)
|
wins = Column(Integer, nullable=False)
|
||||||
losses = Column(Integer, nullable=False)
|
losses = Column(Integer, nullable=False)
|
||||||
|
|
||||||
|
def get_rank_icon_url(self):
|
||||||
|
if self.rank_tier is None or self.rank_tier < 10:
|
||||||
|
f"https://www.opendota.com/assets/images/dota2/rank_icons/rank_icon_0.png"
|
||||||
|
return f"https://www.opendota.com/assets/images/dota2/rank_icons/rank_icon_{self.rank_tier - 10 // 6}.png"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create(session: Session, steam_id: int):
|
def create(session: Session, steam_id: int):
|
||||||
d = session.query(Dota).get(steam_id)
|
d = session.query(Dota).get(steam_id)
|
||||||
|
@ -273,8 +277,7 @@ class Dota(Base):
|
||||||
raise RequestError("OpenDota returned {r.status_code}")
|
raise RequestError("OpenDota returned {r.status_code}")
|
||||||
wl = r.json()
|
wl = r.json()
|
||||||
new_record = Dota(steam_id=steam_id,
|
new_record = Dota(steam_id=steam_id,
|
||||||
solo_mmr=data["solo_competitive_rank"],
|
rank_tier=data["rank_tier"],
|
||||||
party_mmr=data["competitive_rank"],
|
|
||||||
wins=wl["win"],
|
wins=wl["win"],
|
||||||
losses=wl["lose"])
|
losses=wl["lose"])
|
||||||
return new_record
|
return new_record
|
||||||
|
@ -288,8 +291,7 @@ class Dota(Base):
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
raise RequestError("OpenDota returned {r.status_code}")
|
raise RequestError("OpenDota returned {r.status_code}")
|
||||||
wl = r.json()
|
wl = r.json()
|
||||||
self.solo_mmr = data["solo_competitive_rank"]
|
self.rank_tier = data["rank_tier"]
|
||||||
self.party_mmr = data["competitive_rank"]
|
|
||||||
self.wins = wl["win"]
|
self.wins = wl["win"]
|
||||||
self.losses = wl["lose"]
|
self.losses = wl["lose"]
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,7 @@ async def on_message(message: discord.Message):
|
||||||
if voice_player is None:
|
if voice_player is None:
|
||||||
await client.send_message(message.channel, f"ℹ Non c'è nulla in riproduzione al momento.")
|
await client.send_message(message.channel, f"ℹ Non c'è nulla in riproduzione al momento.")
|
||||||
return
|
return
|
||||||
await client.send_message(message.channel, f"ℹ Ora in riproduzione in <#{voice_client.channel.id}>:", embed=voice_playing.create_embed())
|
await client.send_message(message.channel, f"▶️ Ora in riproduzione in <#{voice_client.channel.id}>:", embed=voice_playing.create_embed())
|
||||||
elif message.content.startswith("!queue"):
|
elif message.content.startswith("!queue"):
|
||||||
if voice_player is None:
|
if voice_player is None:
|
||||||
await client.send_message(message.channel, f"ℹ Non c'è nulla in riproduzione al momento.")
|
await client.send_message(message.channel, f"ℹ Non c'è nulla in riproduzione al momento.")
|
||||||
|
|
|
@ -51,8 +51,28 @@ def cmd_register(bot: Bot, update: Update):
|
||||||
def cmd_discord(bot: Bot, update: Update):
|
def cmd_discord(bot: Bot, update: Update):
|
||||||
discord_connection.send("/cv")
|
discord_connection.send("/cv")
|
||||||
server_members = discord_connection.recv()
|
server_members = discord_connection.recv()
|
||||||
|
channels = {0:None}
|
||||||
|
members_in_channels = {0:[]}
|
||||||
message = ""
|
message = ""
|
||||||
|
# Find all the channels
|
||||||
for member in server_members:
|
for member in server_members:
|
||||||
|
if member.voice.voice_channel is not None:
|
||||||
|
channel = members_in_channels.get(member.voice.voice_channel.id)
|
||||||
|
if channel is None:
|
||||||
|
members_in_channels[member.voice.voice_channel.id] = list()
|
||||||
|
channel = members_in_channels[member.voice.voice_channel.id]
|
||||||
|
channels[member.voice.voice_channel.id] = member.voice.voice_channel
|
||||||
|
channel.append(member)
|
||||||
|
else:
|
||||||
|
members_in_channels[0].append(member)
|
||||||
|
# Edit the message, sorted by channel
|
||||||
|
for channel in channels:
|
||||||
|
members_in_channels[channel].sort(key=lambda x: x.nick if x.nick is not None else x.name)
|
||||||
|
if channel == 0:
|
||||||
|
message += "Non in chat vocale:\n"
|
||||||
|
else:
|
||||||
|
message += f"In #{channels[channel].name}:\n"
|
||||||
|
for member in members_in_channels[channel]:
|
||||||
if member.status == DiscordStatus.offline and member.voice.voice_channel is None:
|
if member.status == DiscordStatus.offline and member.voice.voice_channel is None:
|
||||||
continue
|
continue
|
||||||
if member.bot:
|
if member.bot:
|
||||||
|
@ -66,20 +86,20 @@ def cmd_discord(bot: Bot, update: Update):
|
||||||
message += "🔴 "
|
message += "🔴 "
|
||||||
elif member.status == DiscordStatus.offline:
|
elif member.status == DiscordStatus.offline:
|
||||||
message += "⚪️ "
|
message += "⚪️ "
|
||||||
|
# Voice
|
||||||
|
if channel != 0:
|
||||||
|
# Voice status
|
||||||
|
if member.voice.self_deaf:
|
||||||
|
message += f"🔇 "
|
||||||
|
elif member.voice.self_mute:
|
||||||
|
message += f"🔈 "
|
||||||
|
else:
|
||||||
|
message += f"🔊 "
|
||||||
# Nickname
|
# Nickname
|
||||||
if member.nick is not None:
|
if member.nick is not None:
|
||||||
message += member.nick
|
message += member.nick
|
||||||
else:
|
else:
|
||||||
message += member.name
|
message += member.name
|
||||||
# Voice
|
|
||||||
if member.voice.voice_channel is not None:
|
|
||||||
# Voice status
|
|
||||||
if member.voice.self_deaf:
|
|
||||||
message += f" | 🔇 {member.voice.voice_channel.name}"
|
|
||||||
elif member.voice.self_mute:
|
|
||||||
message += f" | 🔈 {member.voice.voice_channel.name}"
|
|
||||||
else:
|
|
||||||
message += f" | 🔊 {member.voice.voice_channel.name}"
|
|
||||||
# Game or stream
|
# Game or stream
|
||||||
if member.game is not None:
|
if member.game is not None:
|
||||||
if member.game.type == 0:
|
if member.game.type == 0:
|
||||||
|
@ -87,6 +107,7 @@ def cmd_discord(bot: Bot, update: Update):
|
||||||
elif member.game.type == 1:
|
elif member.game.type == 1:
|
||||||
message += f" | 📡 [{member.game.name}]({member.game.url})"
|
message += f" | 📡 [{member.game.name}]({member.game.url})"
|
||||||
message += "\n"
|
message += "\n"
|
||||||
|
message += "\n"
|
||||||
bot.send_message(update.message.chat.id, message, disable_web_page_preview=True, parse_mode="Markdown")
|
bot.send_message(update.message.chat.id, message, disable_web_page_preview=True, parse_mode="Markdown")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,7 @@
|
||||||
<th>Royal</th>
|
<th>Royal</th>
|
||||||
<th>Steam</th>
|
<th>Steam</th>
|
||||||
<th>Wins</th>
|
<th>Wins</th>
|
||||||
<th>Solo MMR</th>
|
<th>Rank</th>
|
||||||
<th>Party MMR</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -33,8 +32,7 @@
|
||||||
<td>{{ record.steam.royal.username }}</td>
|
<td>{{ record.steam.royal.username }}</td>
|
||||||
<td><a href="http://steamcommunity.com/profiles/{{ record.steam.steam_id }}"><img src="{{ record.steam.avatar_url() }}"> {{ record.steam.persona_name }}</a></td>
|
<td><a href="http://steamcommunity.com/profiles/{{ record.steam.steam_id }}"><img src="{{ record.steam.avatar_url() }}"> {{ record.steam.persona_name }}</a></td>
|
||||||
<td>{{ record.wins }}</td>
|
<td>{{ record.wins }}</td>
|
||||||
<td>{{ record.solo_mmr if record.solo_mmr is not none}}</td>
|
<td><img src="{{ record.get_rank_icon_url() }}"</td>
|
||||||
<td>{{ record.party_mmr if record.party_mmr is not none}}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in a new issue