🎨 - Some cleaning here and there

This commit is contained in:
Florian SYLVAIN
2021-02-08 09:15:54 +01:00
parent 573cc4fb6e
commit 8c132a3bef
2 changed files with 19 additions and 16 deletions
+9 -6
View File
@@ -5,7 +5,6 @@ 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
import gc
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)
@@ -51,9 +50,12 @@ class ChatObj(object):
pass pass
@twitch.after_loop @twitch.after_loop
async def after_slow_count(): async def after_twitch():
self.sock.shutdown(1) self.sock.shutdown(1)
self.sock.close() try:
self.sock.close()
except OSError:
pass
def check_user(name): def check_user(name):
user = twitch_client.users.translate_usernames_to_ids([name]) user = twitch_client.users.translate_usernames_to_ids([name])
@@ -89,9 +91,10 @@ async def chat_stop(ctx):
if chan in list(chats): if chan in list(chats):
chats[chan].twitch.stop() chats[chan].twitch.stop()
del chats[chan] del chats[chan]
await ctx.send('```The chat was successfully stopped !```') message = '```The chat was successfully stopped !```'
else: else:
await ctx.send('```There is no active chat in this channel.```') message = '```There is no active chat in this channel.```'
await ctx.send(message)
@bot.command() @bot.command()
async def rank(ctx, arg, argF=None): async def rank(ctx, arg, argF=None):
@@ -126,7 +129,7 @@ async def issou(ctx, arg1:discord.User=None):
voice_channel = None voice_channel = None
channel = None channel = None
if voice_channel != None: if voice_channel is not None:
channel = voice_channel.name channel = voice_channel.name
vc = await voice_channel.connect() vc = await voice_channel.connect()
vc.play(discord.FFmpegPCMAudio('issou.mp3')) vc.play(discord.FFmpegPCMAudio('issou.mp3'))
+10 -10
View File
@@ -1,20 +1,20 @@
from riotwatcher import LolWatcher from riotwatcher import LolWatcher
from private import token_riot from private import token_riot
# import pandas as pd
watcher = LolWatcher(token_riot) watcher = LolWatcher(token_riot)
region = 'EUW1' region = 'EUW1'
def rank_track(player): def rank_track(player):
ranked_stats = watcher.league.by_summoner(region, player['id']) ranked_stats = watcher.league.by_summoner(region, player['id'])
if not ranked_stats: if not ranked_stats:
return 'Unranked cette saison.' return 'Unranked cette saison.'
else:
liste = [] liste = []
for infos in ranked_stats: for infos in ranked_stats:
if infos['queueType'] == 'RANKED_SOLO_5x5': if infos['queueType'] == 'RANKED_SOLO_5x5':
what_rank = 'Solo Queue' what_rank = 'Solo Queue'
elif infos['queueType'] == 'RANKED_FLEX_SR': elif infos['queueType'] == 'RANKED_FLEX_SR':
what_rank = 'Flexible' what_rank = 'Flexible'
liste.append([what_rank, infos['tier'], infos['rank'], infos['leaguePoints'], infos['wins'], infos['losses']]) liste.append([what_rank, infos['tier'], infos['rank'], infos['leaguePoints'], infos['wins'], infos['losses']])
return liste return liste