mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
possible new page
This commit is contained in:
parent
a2ee4c304e
commit
ab31249100
4 changed files with 80 additions and 7 deletions
|
@ -69,7 +69,7 @@ song_special_messages = {
|
|||
"updog": ":arrow_forward: What's up, dog? {song}!",
|
||||
"sayo-nara": ":arrow_forward: I gently open the door. {song} awaits me inside.",
|
||||
"monika": ":arrow_forward: Just Monika. Just Monika. Just {song}.",
|
||||
"take me home": ":arrow_forward: Take me home, to {song}, the place I belong!",
|
||||
"country road": ":arrow_forward: Take me home, to {song}, the place I belong!",
|
||||
"never gonna give you up": ":arrow_forward: Rickrolling in 2018. Enjoy {song}!",
|
||||
"september": ":arrow_forward: Do you remember? {song}.",
|
||||
"homestuck": ":arrow_forward: > Enter song name. {song}",
|
||||
|
@ -89,10 +89,15 @@ song_special_messages = {
|
|||
"persona": ":arrow_forward: You'll never see {song} comiiiiing!",
|
||||
"flamingo": ":arrow_forward: How many {song} do you have to eat?",
|
||||
"linkin park": ":arrow_forward: Crawling in my {song}!",
|
||||
"magicite": "⚠️ Warning: {song} contiene numerosi bug.",
|
||||
"magicite": "⚠️ Warning: {song} contiene numerosi bug. E' ora in riproduzione.",
|
||||
"papers please": ":arrow_forward: Glory to Arstotzka! {song}!",
|
||||
"we are number one": ":arrow_forward: Now paying respect to Robbie Rotten: {song}",
|
||||
"jump up superstar": ":arrow_forward: Is {song} the Tengen Toppa Guren Lagann opening?"
|
||||
"jump up superstar": ":arrow_forward: Is {song} the Tengen Toppa Guren Lagann opening?",
|
||||
"the world revolving": ":arrow_forward: CHAOS! CHAOS! I CAN DO {song}!",
|
||||
"deltarune": ":arrow_forward: You hug Ralsei. A strange music starts playing: {song}",
|
||||
"song of unhealing": ":arrow_forward: BEN {song}",
|
||||
"police academy": ":arrow_forward: {song} - freedom.png",
|
||||
"super smash bros. ultimate": ":arrow_forward: Re-awaken the undying light with {song}!"
|
||||
}
|
||||
|
||||
# FFmpeg settings
|
||||
|
@ -301,6 +306,7 @@ class RoyalDiscordBot(discord.Client):
|
|||
"!file": self.cmd_play,
|
||||
"!skip": self.cmd_skip,
|
||||
"!s": self.cmd_skip,
|
||||
"!next": self.cmd_skip,
|
||||
"!remove": self.cmd_remove,
|
||||
"!r": self.cmd_remove,
|
||||
"!cancel": self.cmd_remove,
|
||||
|
@ -453,9 +459,11 @@ class RoyalDiscordBot(discord.Client):
|
|||
message += f" | 🎮 {member.activity.name}"
|
||||
# Rich presence
|
||||
try:
|
||||
if member.activity.state is not None:
|
||||
message += f" ({member.activity.state})"
|
||||
except AttributeError:
|
||||
try:
|
||||
if member.activity.details is not None:
|
||||
message += f" ({member.activity.details})"
|
||||
except AttributeError:
|
||||
pass
|
||||
|
@ -546,7 +554,7 @@ class RoyalDiscordBot(discord.Client):
|
|||
voice_client.play(audio_source)
|
||||
del self.video_queue[0]
|
||||
activity = discord.Activity(name=now_playing.plain_text(),
|
||||
type=discord.ActivityType.playing)
|
||||
type=discord.ActivityType.listening)
|
||||
logger.debug(f"Updated bot presence to {now_playing.plain_text()}.")
|
||||
await self.change_presence(status=discord.Status.online, activity=activity)
|
||||
if now_playing.enqueuer is not None:
|
||||
|
@ -581,6 +589,7 @@ class RoyalDiscordBot(discord.Client):
|
|||
if voice_client.is_connected():
|
||||
logger.info("Disconnecting due to inactivity.")
|
||||
await voice_client.disconnect()
|
||||
await self.change_presence(status=discord.Status.online, activity=None)
|
||||
await self.main_channel.send("💤 Mi sono disconnesso dalla cv per inattività.")
|
||||
|
||||
async def add_video_from_url(self, url, index: typing.Optional[int] = None, enqueuer: discord.Member = None):
|
||||
|
|
|
@ -118,3 +118,14 @@ LEFT JOIN
|
|||
) last_play_times ON playedmusic.timestamp = last_play_times.last_play_time
|
||||
) last_songs ON last_songs.discord_id = discord.discord_id
|
||||
WHERE discord.royal_id = :royal;"""
|
||||
|
||||
top_songs = """SELECT playedmusic.filename, COUNT(*) c
|
||||
FROM playedmusic
|
||||
GROUP BY playedmusic.filename
|
||||
ORDER BY c DESC;"""
|
||||
|
||||
single_top_songs = """SELECT playedmusic.filename, COUNT(*) c
|
||||
FROM playedmusic
|
||||
WHERE playedmusic.enqueuer_id = :discordid
|
||||
GROUP BY playedmusic.filename
|
||||
ORDER BY c DESC;"""
|
||||
|
|
27
templates/topsongs.html
Normal file
27
templates/topsongs.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block pagetitle %}
|
||||
File più ascoltati {% if discord %}di {{ discord }}{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>
|
||||
File più ascoltati {% if discord %}di {{ discord }}{% endif %}
|
||||
</h1>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>File</th>
|
||||
<th>Conteggio</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for song in songs %}
|
||||
<tr>
|
||||
<td>{{ song[0] }}</td>
|
||||
<td>{{ song[1] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
26
webserver.py
26
webserver.py
|
@ -334,6 +334,32 @@ def page_diario():
|
|||
return render_template("diario.html", g=fl_g, entries=diario_entries)
|
||||
|
||||
|
||||
@app.route("/music")
|
||||
def page_music():
|
||||
db_session = db.Session()
|
||||
songs = db_session.execute(query_discord_music.top_songs)
|
||||
db_session.close()
|
||||
return render_template("topsongs.html", songs=songs)
|
||||
|
||||
|
||||
@app.route("/music/<name>")
|
||||
def page_music_individual(name: str):
|
||||
db_session = db.Session()
|
||||
user = db_session.query(db.Royal).filter_by(username=name).one_or_none()
|
||||
if user is None:
|
||||
db_session.close()
|
||||
abort(404)
|
||||
return
|
||||
discord = db_session.query(db.Discord).filter_by(royal=user).one_or_none()
|
||||
if discord is None:
|
||||
db_session.close()
|
||||
abort(404)
|
||||
return
|
||||
songs = db_session.execute(query_discord_music.single_top_songs, {"discordid": discord.id})
|
||||
db_session.close()
|
||||
return render_template("topsongs.html", songs=songs, discord=discord)
|
||||
|
||||
|
||||
@app.route("/api/token")
|
||||
def api_token():
|
||||
username = request.form.get("username", "")
|
||||
|
|
Loading…
Reference in a new issue