diff --git a/.gitignore b/.gitignore
index 8f60678..90bc23f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -129,4 +129,7 @@ dmypy.json
.pyre/
# Tokens and IDs
-private.py
\ No newline at end of file
+private.py
+
+# Generated JPEG File
+acc.jpeg
diff --git a/README.md b/README.md
index 480fb39..304ba88 100644
--- a/README.md
+++ b/README.md
@@ -15,19 +15,23 @@
-
+
-
+
-
+
-
+
+
+
+
+
@@ -67,14 +71,21 @@ This command will display a message with the current League of Legend rank of th
```
$osu_profile {osu_username}
```
-This command will display a message with all the (basics) stats from the Osu! profile you ask for.
+This command will display a message with all the (basics) stats from the Osu! profile you ask for. Make sure to use quotes if there is spaces in the username.
### **osu_lastgame**
```
$osu_lastgame {osu_username}
```
-This command will display a message with all the stats from the last Osu! game the player you asked for played.
+This command will display a message with all the stats from the last Osu! game the player you asked for played. Make sure to use quotes if there is spaces in the username.
+
+
+### **osu_acc**
+```
+$osu_acc {osu_username}
+```
+This command will display the Accuracy of the player you asked for on his last games (with a maximum of 10 games).
diff --git a/assets/chat_record1.gif b/assets/chat.gif
similarity index 100%
rename from assets/chat_record1.gif
rename to assets/chat.gif
diff --git a/assets/osu_acc.png b/assets/osu_acc.png
new file mode 100644
index 0000000..ede10d9
Binary files /dev/null and b/assets/osu_acc.png differ
diff --git a/assets/osu_lastgame.png b/assets/osu_lastgame.png
new file mode 100644
index 0000000..7b3cf30
Binary files /dev/null and b/assets/osu_lastgame.png differ
diff --git a/assets/osu_profile.png b/assets/osu_profile.png
new file mode 100644
index 0000000..7110ca2
Binary files /dev/null and b/assets/osu_profile.png differ
diff --git a/assets/osu_record.gif b/assets/osu_record.gif
deleted file mode 100644
index b75cda6..0000000
Binary files a/assets/osu_record.gif and /dev/null differ
diff --git a/assets/osu_record1.gif b/assets/osu_record1.gif
deleted file mode 100644
index 8b8f28e..0000000
Binary files a/assets/osu_record1.gif and /dev/null differ
diff --git a/assets/rank.png b/assets/rank.png
new file mode 100644
index 0000000..8c78a85
Binary files /dev/null and b/assets/rank.png differ
diff --git a/assets/rank_record.gif b/assets/rank_record.gif
deleted file mode 100644
index f0b1b2a..0000000
Binary files a/assets/rank_record.gif and /dev/null differ
diff --git a/python/main.py b/python/main.py
index bec07d4..fddfdb2 100644
--- a/python/main.py
+++ b/python/main.py
@@ -121,7 +121,6 @@ async def chat_stop(ctx):
@bot.command()
async def rank(ctx, arg, argf=None):
- await del_message(ctx)
if argf is None:
try:
player = WATCHER.summoner.by_name(REGION, arg)
@@ -142,7 +141,7 @@ async def rank(ctx, arg, argf=None):
except ApiError:
await ctx.send('The username you entered is unknown.')
else:
- await ctx.send('If you are trying to use a username you entered with spaces, please surround it with quotes.')
+ await ctx.send('If you are trying to use a username with spaces, please surround it with quotes.')
@bot.command()
@@ -168,59 +167,75 @@ async def issou(ctx, arg1: discord.User = None):
@bot.command()
-async def osu_profile(ctx, arg):
- await del_message(ctx)
- lst = await ask_osu_profile(arg)
- if lst == 1:
- await ctx.send('The username you entered is unknown.')
+async def osu_profile(ctx, arg, argF=None):
+ if argF is None:
+ lst = await ask_osu_profile(arg)
+ if lst == 1:
+ await ctx.send('The username you entered is unknown.')
+ else:
+ embed = discord.Embed(title=arg, url='https://osu.ppy.sh/users/' + str(lst[0]))
+ embed.set_author(name='Osu!', url='https://osu.ppy.sh/home',
+ icon_url=r'https://upload.wikimedia.org/wikipedia/commons/4/44/Osu%21Logo_%282019%29.png')
+ embed.set_thumbnail(url='https://a.ppy.sh/' + str(lst[0]))
+ embed.add_field(name='Global Ranking', value='#'+str('{:,}'.format(lst[8])))
+ embed.add_field(name='Total Play Time', value=
+ str("%.0f" % ((lst[6] % (86400 * 30)) / 86400))+'d '+
+ str("%.0f" % ((lst[6] % 86400) / 3600))+'h '+
+ str("%.0f" % ((lst[6] % 3600) / 60))+'m ')
+ embed.add_field(name='|', value='|')
+ embed.add_field(name='Level', value=str("%.0f" % lst[7]))
+ embed.add_field(name='Ranked Score', value=str('{:,}'.format(lst[1])))
+ embed.add_field(name='Hit Accuracy', value=str("%.2f" % lst[2])+'%')
+ embed.add_field(name='Play Count', value=str('{:,}'.format(lst[3])))
+ embed.add_field(name='Total Score', value=str('{:,}'.format(lst[4])))
+ embed.add_field(name='Total Hits', value=str('{:,}'.format(lst[5])))
+ await ctx.send(embed=embed)
else:
- embed = discord.Embed(title=arg, url='https://osu.ppy.sh/users/' + str(lst[0]))
- embed.set_author(name='Osu!', url='https://osu.ppy.sh/home',
- icon_url=r'https://upload.wikimedia.org/wikipedia/commons/4/44/Osu%21Logo_%282019%29.png')
- embed.set_thumbnail(url='https://a.ppy.sh/' + str(lst[0]))
- embed.add_field(name='Global Ranking', value='#'+str('{:,}'.format(lst[8])))
- embed.add_field(name='Total Play Time', value=
- str("%.0f" % ((lst[6] % (86400 * 30)) / 86400))+'d '+
- str("%.0f" % ((lst[6] % 86400) / 3600))+'h '+
- str("%.0f" % ((lst[6] % 3600) / 60))+'m ')
- embed.add_field(name='|', value='|')
- embed.add_field(name='Level', value=str("%.0f" % lst[7]))
- embed.add_field(name='Ranked Score', value=str('{:,}'.format(lst[1])))
- embed.add_field(name='Hit Accuracy', value=str("%.2f" % lst[2])+'%')
- embed.add_field(name='Play Count', value=str('{:,}'.format(lst[3])))
- embed.add_field(name='Total Score', value=str('{:,}'.format(lst[4])))
- embed.add_field(name='Total Hits', value=str('{:,}'.format(lst[5])))
- await ctx.send(embed=embed)
+ await ctx.send('If you are trying to use a username with spaces, please surround it with quotes.')
@bot.command()
-async def osu_lastgame(ctx, arg):
- await del_message(ctx)
- lst = await ask_osu_last_game(arg)
- if lst == 1:
- await ctx.send('The player you entered is unknown or didn\'t played any game recently.')
+async def osu_lastgame(ctx, arg, argF=None):
+ if argF is None:
+ lst = await ask_osu_last_game(arg)
+ if lst == 1:
+ await ctx.send('The player you entered is unknown or didn\'t played any game recently.')
+ else:
+ embed = discord.Embed(title=str(lst[1]) + ' by ' + str(lst[2]), url='https://osu.ppy.sh/beatmapsets/' + str(lst[0]),
+ description='BPM: ' + str("%.0f" % lst[3]) + ' ; Stars: ' + str("%.1f" % lst[4]) +
+ ' ; CS: ' + str(lst[5]) + ' ; AR: ' + str(lst[7]) +
+ ' ; OD: ' + str(lst[6]) + ' ; HP: ' + str(lst[8]))
+ embed.set_author(name='Osu!', url='https://osu.ppy.sh/home',
+ icon_url=r'https://upload.wikimedia.org/wikipedia/commons/4/44/Osu%21Logo_%282019%29.png')
+ embed.set_thumbnail(url='https://b.ppy.sh/thumb/' + str(lst[0]) + 'l.jpg')
+ embed.add_field(name='Rank', value=str(lst[11]))
+ embed.add_field(name='Score', value=str('{:,}'.format(lst[9])))
+ embed.add_field(name='Max Combo', value=str(lst[10]))
+ embed.add_field(name='300', value=str(lst[12]))
+ embed.add_field(name='Geki', value=str(lst[17]))
+ embed.add_field(name='Accuracy',
+ value=str("%.2f" % (((lst[12]*300)+(lst[13]*100)+(lst[14]*50))/(sum(lst[12:16])*300)*100) + '%'))
+ embed.add_field(name='100', value=str(lst[13]))
+ embed.add_field(name='Katu', value=str(lst[16]))
+ embed.add_field(name='Player :', value=str(arg))
+ embed.add_field(name='50', value=str(lst[14]))
+ embed.add_field(name='Miss', value=str(lst[15]))
+ embed.add_field(name='|', value='|')
+ await ctx.send(embed=embed)
else:
- embed = discord.Embed(title=str(lst[1]) + ' by ' + str(lst[2]), url='https://osu.ppy.sh/beatmapsets/' + str(lst[0]),
- description='BPM: ' + str("%.0f" % lst[3]) + ' ; Stars: ' + str("%.1f" % lst[4]) +
- ' ; CS: ' + str(lst[5]) + ' ; AR: ' + str(lst[7]) +
- ' ; OD: ' + str(lst[6]) + ' ; HP: ' + str(lst[8]))
- embed.set_author(name='Osu!', url='https://osu.ppy.sh/home',
- icon_url=r'https://upload.wikimedia.org/wikipedia/commons/4/44/Osu%21Logo_%282019%29.png')
- embed.set_thumbnail(url='https://b.ppy.sh/thumb/' + str(lst[0]) + 'l.jpg')
- embed.add_field(name='Rank', value=str(lst[11]))
- embed.add_field(name='Score', value=str('{:,}'.format(lst[9])))
- embed.add_field(name='Max Combo', value=str(lst[10]))
- embed.add_field(name='300', value=str(lst[12]))
- embed.add_field(name='Geki', value=str(lst[17]))
- embed.add_field(name='Accuracy',
- value=str("%.2f" % (((lst[12]*300)+(lst[13]*100)+(lst[14]*50))/(sum(lst[12:16])*300)*100) + '%'))
- embed.add_field(name='100', value=str(lst[13]))
- embed.add_field(name='Katu', value=str(lst[16]))
- embed.add_field(name='Player :', value=str(arg))
- embed.add_field(name='50', value=str(lst[14]))
- embed.add_field(name='Miss', value=str(lst[15]))
- embed.add_field(name='|', value='|')
- await ctx.send(embed=embed)
+ await ctx.send('If you are trying to use a username with spaces, please surround it with quotes.')
+
+
+@bot.command()
+async def osu_acc(ctx, arg, argF=None):
+ if argF is None:
+ test_acc = await ask_osu_acc(arg)
+ if test_acc:
+ await ctx.send(file=discord.File('acc.jpeg'))
+ else:
+ await ctx.send('The player you entered is unknown or didn\'t played any game recently.')
+ else:
+ await ctx.send('If you are trying to use a username with spaces, please surround it with quotes.')
bot.run(TOKEN_BOT)
diff --git a/python/osu_api.py b/python/osu_api.py
index 03661a8..04389ab 100644
--- a/python/osu_api.py
+++ b/python/osu_api.py
@@ -1,6 +1,6 @@
from osuapi import OsuApi, ReqConnector
from private import TOKEN_OSU
-import requests
+import matplotlib.pyplot as plt
api = OsuApi(TOKEN_OSU, connector=ReqConnector())
@@ -25,3 +25,30 @@ async def ask_osu_last_game(username):
lm.diff_approach, lm.diff_drain, lg.score,
lg.maxcombo, lg.rank, lg.count300, lg.count100,
lg.count50, lg.countmiss, lg.countkatu, lg.countgeki]
+
+
+async def ask_osu_acc(username):
+ last_game = api.get_user_recent(username)
+ if not last_game:
+ return 0
+
+ lst = []
+ for game in last_game:
+ total = game.count300 + game.count100 + game.count50 + game.countmiss
+ lst.append((float("%.2f" %(((game.count300 * 300) + (game.count100 * 100) + (game.count50 * 50)) / (total * 300) * 100))))
+
+ nb_games = len(lst)+1
+ min_games = int(min(lst))
+
+ plt.figure(figsize=(9, 5))
+ plt.plot(list(range(1, nb_games)), lst)
+ plt.scatter(list(range(1, nb_games)), lst, color='red')
+ plt.axis([1, nb_games-1, min_games, 100])
+ plt.title('Accuracy of ' + username + ' on his last ' + str(nb_games-1) + ' games.')
+ plt.xticks(range(1, nb_games))
+ plt.yticks(range(min_games, 100, 5))
+ plt.grid(linewidth=0.5)
+ plt.ylabel('Accuracy (%)')
+ plt.xlabel('Games (from recent to oldest)')
+ plt.savefig('acc.jpeg')
+ return 1