mirror of
https://github.com/Floriansylvain/Risitas_BOT.git
synced 2026-08-19 11:43:16 +02:00
✨ - New command $osu_profile <username> ! + Massive file tree reorganization + Updated the readme
This commit is contained in:
@@ -15,11 +15,15 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
@@ -54,6 +58,13 @@ $rank {lol_username}
|
|||||||
```
|
```
|
||||||
This command will display a message with the current League of Legend rank of the EUW account you ask for. Make sure to use quotes if there is spaces in the LoL username.
|
This command will display a message with the current League of Legend rank of the EUW account you ask for. Make sure to use quotes if there is spaces in the LoL username.
|
||||||
|
|
||||||
|
|
||||||
|
### **osu_profile**
|
||||||
|
```
|
||||||
|
$osu_profile {osu_username}
|
||||||
|
```
|
||||||
|
This command will display a message with all the (basics) stats from the Osu! profile you ask for.
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
# ⚙ Configuration
|
# ⚙ Configuration
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 226 KiB After Width: | Height: | Size: 226 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
+41
-11
@@ -8,6 +8,7 @@ from riot_api import rank_track, WATCHER, REGION
|
|||||||
from riotwatcher import ApiError
|
from riotwatcher import ApiError
|
||||||
from emoji import demojize
|
from emoji import demojize
|
||||||
from twitch import TwitchClient
|
from twitch import TwitchClient
|
||||||
|
from osu_api import ask_osu
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix='$')
|
bot = commands.Bot(command_prefix='$')
|
||||||
twitch_client = TwitchClient(client_id=ID_TWITCH, oauth_token=TOKEN_TWITCH)
|
twitch_client = TwitchClient(client_id=ID_TWITCH, oauth_token=TOKEN_TWITCH)
|
||||||
@@ -24,8 +25,8 @@ class ChatObj:
|
|||||||
def chat_init(self):
|
def chat_init(self):
|
||||||
try:
|
try:
|
||||||
self.sock.connect((SERVER, PORT))
|
self.sock.connect((SERVER, PORT))
|
||||||
self.sock.send(f"PASS {TOKEN_TWITCH}\n".encode('utf-8'))
|
self.sock.send(f'PASS {TOKEN_TWITCH}\n'.encode('utf-8'))
|
||||||
self.sock.send(f"NICK {NICKNAME}\n".encode('utf-8'))
|
self.sock.send(f'NICK {NICKNAME}\n'.encode('utf-8'))
|
||||||
self.sock.send(f"JOIN {'#' + self.twitch_user}\n".encode('utf-8'))
|
self.sock.send(f"JOIN {'#' + self.twitch_user}\n".encode('utf-8'))
|
||||||
self.sock.settimeout(0.0)
|
self.sock.settimeout(0.0)
|
||||||
self.sock.setblocking(False)
|
self.sock.setblocking(False)
|
||||||
@@ -42,14 +43,14 @@ class ChatObj:
|
|||||||
resp = ''
|
resp = ''
|
||||||
|
|
||||||
if resp.startswith('PING'):
|
if resp.startswith('PING'):
|
||||||
self.sock.send("PONG\n".encode('utf-8'))
|
self.sock.send('PONG\n'.encode('utf-8'))
|
||||||
|
|
||||||
elif len(resp) > 0:
|
elif len(resp) > 0:
|
||||||
try:
|
try:
|
||||||
chain = re.search(r':(.*)\!.*@.*\.tmi\.twitch\.tv PRIVMSG #(.*) :(.*)', demojize(resp))
|
chain = re.search(r':(.*)\!.*@.*\.tmi\.twitch\.tv PRIVMSG #(.*) :(.*)', demojize(resp))
|
||||||
username = chain.group(1)
|
username = chain.group(1)
|
||||||
message = chain.group(3)
|
message = chain.group(3)
|
||||||
msg = f"**__{username}__ :** {message}"
|
msg = f'**__{username}__ :** {message}'
|
||||||
await self.discord_channel.send(msg)
|
await self.discord_channel.send(msg)
|
||||||
except discord.DiscordException:
|
except discord.DiscordException:
|
||||||
pass
|
pass
|
||||||
@@ -81,7 +82,7 @@ async def del_message(ctx):
|
|||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
default_activity = discord.Activity(type=discord.ActivityType.listening, name="$help")
|
default_activity = discord.Activity(type=discord.ActivityType.listening, name='$help')
|
||||||
await bot.change_presence(activity=default_activity)
|
await bot.change_presence(activity=default_activity)
|
||||||
print('We have logged in as {0.user}'.format(bot))
|
print('We have logged in as {0.user}'.format(bot))
|
||||||
|
|
||||||
@@ -125,9 +126,12 @@ async def rank(ctx, arg, argf=None):
|
|||||||
try:
|
try:
|
||||||
player = WATCHER.summoner.by_name(REGION, arg)
|
player = WATCHER.summoner.by_name(REGION, arg)
|
||||||
ranks = rank_track(player)
|
ranks = rank_track(player)
|
||||||
embed = discord.Embed(title=arg, url="https://www.youtube.com/watch?v=dQw4w9WgXcQ")
|
embed = discord.Embed(title=arg, url='https://www.youtube.com/watch?v=dQw4w9WgXcQ')
|
||||||
embed.set_thumbnail(url="http://ddragon.leagueoflegends.com/cdn/11.2.1/img/profileicon/" + str(
|
embed.set_thumbnail(url='http://ddragon.leagueoflegends.com/cdn/11.2.1/img/profileicon/' + str(
|
||||||
player['profileIconId']) + ".png")
|
player['profileIconId']) + '.png')
|
||||||
|
embed.set_author(name='League Of Legend', url='https://euw.leagueoflegends.com/en-gb/',
|
||||||
|
icon_url='https://static.wikia.nocookie.net/leagueoflegends/images/0/07/' +
|
||||||
|
'League_of_Legends_icon.png/revision/latest?cb=20191018194326')
|
||||||
if isinstance(ranks, list):
|
if isinstance(ranks, list):
|
||||||
for rank_s in ranks:
|
for rank_s in ranks:
|
||||||
embed.add_field(name=rank_s[0], value=str(rank_s[1]) + ' ' + str(rank_s[2]) + ' ' + str(
|
embed.add_field(name=rank_s[0], value=str(rank_s[1]) + ' ' + str(rank_s[2]) + ' ' + str(
|
||||||
@@ -136,9 +140,9 @@ async def rank(ctx, arg, argf=None):
|
|||||||
embed.description = ranks
|
embed.description = ranks
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
except ApiError:
|
except ApiError:
|
||||||
await ctx.send("The nickname is unknown.")
|
await ctx.send('The username you entered is unknown.')
|
||||||
else:
|
else:
|
||||||
await ctx.send("If you are trying to use a nickname with spaces, please surround it with quotes.")
|
await ctx.send('If you are trying to use a username you entered with spaces, please surround it with quotes.')
|
||||||
|
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
@@ -155,7 +159,7 @@ async def issou(ctx, arg1: discord.User = None):
|
|||||||
|
|
||||||
if voice_channel is not None:
|
if voice_channel is not None:
|
||||||
voice = await voice_channel.connect()
|
voice = await voice_channel.connect()
|
||||||
voice.play(discord.FFmpegPCMAudio('issou.mp3'))
|
voice.play(discord.FFmpegPCMAudio('../assets/issou.mp3'))
|
||||||
if voice.is_playing():
|
if voice.is_playing():
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
await voice.disconnect()
|
await voice.disconnect()
|
||||||
@@ -163,4 +167,30 @@ async def issou(ctx, arg1: discord.User = None):
|
|||||||
await ctx.send('You or the targeted person are not connected to any channel.')
|
await ctx.send('You or the targeted person are not connected to any channel.')
|
||||||
|
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
async def osu_profile(ctx, arg):
|
||||||
|
await del_message(ctx)
|
||||||
|
lst = await ask_osu(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_thumbnail(url='https://a.ppy.sh/' + 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.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='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)
|
||||||
|
|
||||||
|
|
||||||
bot.run(TOKEN_BOT)
|
bot.run(TOKEN_BOT)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
from osuapi import OsuApi, ReqConnector
|
||||||
|
from private import TOKEN_OSU
|
||||||
|
import requests
|
||||||
|
|
||||||
|
api = OsuApi(TOKEN_OSU, connector=ReqConnector())
|
||||||
|
|
||||||
|
async def ask_osu(username):
|
||||||
|
results = api.get_user(username)
|
||||||
|
if not results:
|
||||||
|
return 1
|
||||||
|
r = results[0]
|
||||||
|
liste = [r.user_id, r.ranked_score, r.accuracy, r.playcount,
|
||||||
|
r.total_score, (r.count300 + r.count100 + r.count50),
|
||||||
|
r.total_seconds_played, r.level, r.pp_rank]
|
||||||
|
return liste
|
||||||
Reference in New Issue
Block a user