🎨 - Massive code cleaning

This commit is contained in:
Florian Sylvain
2021-04-01 23:15:43 +02:00
parent 37115cb362
commit 53ccad4f1e
9 changed files with 102 additions and 100 deletions
+16 -14
View File
@@ -1,6 +1,6 @@
import matplotlib.pyplot as plt
from osuapi import OsuApi, ReqConnector from osuapi import OsuApi, ReqConnector
from private import TOKEN_OSU from private import TOKEN_OSU
import matplotlib.pyplot as plt
api = OsuApi(TOKEN_OSU, connector=ReqConnector()) api = OsuApi(TOKEN_OSU, connector=ReqConnector())
@@ -8,23 +8,23 @@ async def ask_osu_profile(username):
results = api.get_user(username) results = api.get_user(username)
if not results: if not results:
return 1 return 1
r = results[0] res = results[0]
return [r.user_id, r.ranked_score, r.accuracy, r.playcount, return [res.user_id, res.ranked_score, res.accuracy, res.playcount,
r.total_score, (r.count300 + r.count100 + r.count50), res.total_score, (res.count300 + res.count100 + res.count50),
r.total_seconds_played, r.level, r.pp_rank] res.total_seconds_played, res.level, res.pp_rank]
async def ask_osu_last_game(username): async def ask_osu_last_game(username):
last_game = api.get_user_recent(username) last_game = api.get_user_recent(username)
if not last_game: if not last_game:
return 1 return 1
lg = last_game[0] lsg = last_game[0]
lm = api.get_beatmaps(beatmap_id=lg.beatmap_id)[0] lsm = api.get_beatmaps(beatmap_id=lsg.beatmap_id)[0]
return [lm.beatmapset_id, lm.title, lm.creator, return [lsm.beatmapset_id, lsm.title, lsm.creator,
lm.bpm, lm.difficultyrating, lm.diff_size, lm.diff_overall, lsm.bpm, lsm.difficultyrating, lsm.diff_size, lsm.diff_overall,
lm.diff_approach, lm.diff_drain, lg.score, lsm.diff_approach, lsm.diff_drain, lsg.score,
lg.maxcombo, lg.rank, lg.count300, lg.count100, lsg.maxcombo, lsg.rank, lsg.count300, lsg.count100,
lg.count50, lg.countmiss, lg.countkatu, lg.countgeki] lsg.count50, lsg.countmiss, lsg.countkatu, lsg.countgeki]
async def ask_osu_acc(username): async def ask_osu_acc(username):
@@ -35,7 +35,8 @@ async def ask_osu_acc(username):
lst = [] lst = []
for game in last_game: for game in last_game:
total = game.count300 + game.count100 + game.count50 + game.countmiss 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)))) lst.append((float("%.2f" % (((game.count300 * 300) + (game.count100 * 100) +
(game.count50 * 50)) / (total * 300) * 100))))
nb_games = len(lst)+1 nb_games = len(lst)+1
min_games = int(min(lst)) min_games = int(min(lst))
@@ -51,7 +52,8 @@ async def ask_osu_acc(username):
plt.yticks(range(min_games, 100, 3)) plt.yticks(range(min_games, 100, 3))
plt.grid(linewidth=0.5) plt.grid(linewidth=0.5)
plt.title('Accuracy of ' + username + ' on his last ' + str(nb_games-1) + ' games.', fontsize=20) plt.title('Accuracy of ' + username + ' on his last ' +
str(nb_games-1) + ' games.', fontsize=20)
plt.ylabel('Accuracy (%)') plt.ylabel('Accuracy (%)')
plt.xlabel('Games (from recent to oldest)') plt.xlabel('Games (from recent to oldest)')
+15 -12
View File
@@ -1,10 +1,11 @@
from datetime import datetime, timedelta
from riotwatcher import LolWatcher, ApiError from riotwatcher import LolWatcher, ApiError
from private import TOKEN_RIOT from private import TOKEN_RIOT
from datetime import datetime, timedelta
WATCHER = LolWatcher(TOKEN_RIOT) WATCHER = LolWatcher(TOKEN_RIOT)
REGION = 'EUW1' REGION = 'EUW1'
def what_player(name): def what_player(name):
try: try:
return WATCHER.summoner.by_name(REGION, name) return WATCHER.summoner.by_name(REGION, name)
@@ -22,7 +23,8 @@ def rank_track(player):
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
@@ -30,13 +32,14 @@ def last_match(player):
matches = WATCHER.match.matchlist_by_account('EUW1', player['accountId']) matches = WATCHER.match.matchlist_by_account('EUW1', player['accountId'])
recent_match = matches['matches'][0] recent_match = matches['matches'][0]
match_detail = WATCHER.match.by_id('EUW1', recent_match['gameId']) match_detail = WATCHER.match.by_id('EUW1', recent_match['gameId'])
lst = [[],[[],[],[],[]]] lst = [[], [[], [], [], []]]
for x, y in zip(match_detail['participants'], match_detail['participantIdentities']): for participants, details in zip(match_detail['participants'],
lst[0].append([y['player']['summonerName'], match_detail['participantIdentities']):
x['stats']['totalDamageDealtToChampions'], lst[0].append([details['player']['summonerName'],
x['stats']['kills'], participants['stats']['totalDamageDealtToChampions'],
x['stats']['deaths'], participants['stats']['kills'],
x['stats']['assists']]) participants['stats']['deaths'],
participants['stats']['assists']])
for team in match_detail['teams']: for team in match_detail['teams']:
lst[1][0].append(team['win']) lst[1][0].append(team['win'])
@@ -44,10 +47,10 @@ def last_match(player):
lst[1][2].append(team['firstTower']) lst[1][2].append(team['firstTower'])
lst[1][3].append(team['firstDragon']) lst[1][3].append(team['firstDragon'])
ts = str(match_detail['gameCreation'])[:-3] time_stamp = str(match_detail['gameCreation'])[:-3]
dt = datetime.fromtimestamp(int(ts)).date() date_time = datetime.fromtimestamp(int(time_stamp)).date()
lst.append(str(dt)) lst.append(str(date_time))
lst.append(str(timedelta(seconds=match_detail['gameDuration']))) lst.append(str(timedelta(seconds=match_detail['gameDuration'])))
return lst return lst
+15 -16
View File
@@ -1,11 +1,10 @@
import discord import discord
import asyncio
from discord.ext import commands from discord.ext import commands
from discord.ext.commands.cooldowns import BucketType
from api_riot import rank_track, what_player, last_match from api_riot import rank_track, what_player, last_match
CD_LOLRANK = 0 CD_LOLRANK = 0
class LolCmds(commands.Cog, name='League of Legend commands'): class LolCmds(commands.Cog, name='League of Legend commands'):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@@ -17,38 +16,38 @@ class LolCmds(commands.Cog, name='League of Legend commands'):
if player != 0: if player != 0:
ranks = rank_track(player) ranks = rank_track(player)
embed = discord.Embed(title=invocator_name, url='https://bit.ly/3biTekM') embed = discord.Embed(title=invocator_name, url='https://bit.ly/3biTekM')
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/' +
player['profileIconId']) + '.png') str(player['profileIconId']) + '.png')
embed.set_author(name='League Of Legend - Rank', url='https://euw.leagueoflegends.com/en-gb/', embed.set_author(name='League Of Legend - Rank', url='https://euw.leagueoflegends.com/en-gb/',
icon_url='https://static.wikia.nocookie.net/leagueoflegends/images/0/07/' + icon_url='https://static.wikia.nocookie.net/leagueoflegends/images/0/07/' +
'League_of_Legends_icon.png/revision/latest?cb=20191018194326') '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]) + ' ' +
rank_s[3]) + ' LP' + '\n' + str(rank_s[4]) + 'W/' + str(rank_s[5]) + 'L', inline=False) str(rank_s[2]) + ' ' + str(rank_s[3]) + ' LP\n' +
str(rank_s[4]) + 'W/' + str(rank_s[5]) +
'L', inline=False)
else: else:
embed.description = ranks embed.description = ranks
await ctx.send(embed=embed) await ctx.send(embed=embed)
else: else:
await ctx.send('The username you entered is unknown.') await ctx.send('The username you entered is unknown.')
@commands.command(ignore_extra=False) @commands.command(ignore_extra=False)
@commands.cooldown(1, 2, commands.BucketType.user)
async def lol_lastgame(self, ctx, invocator_name): async def lol_lastgame(self, ctx, invocator_name):
player = what_player(invocator_name) player = what_player(invocator_name)
if player != 0: if player != 0:
lst = last_match(player) lst = last_match(player)
lst_p = lst[0] maximum = lst[0][0][1]
maximum = lst_p[0][1] for stat in lst[0]:
for stat in lst_p:
if stat[1] > maximum: if stat[1] > maximum:
maximum = stat[1] maximum = stat[1]
tab, players, kda = [], [], [] tab, players, kda = [], [], []
for stat in lst_p: for stat in lst[0]:
pourcent = round(100*stat[1]/maximum) pourcent = round(100*stat[1]/maximum)
equals = int(round(float(pourcent)/3.3)) equals = int(round(float(pourcent)/3.3))
hyphen = 30 - equals tab.append('[' + '=' * equals + ' ' * (30 - equals) + ']\n')
tab.append('[' + '='*equals + ' '*hyphen +']\n')
players.append(stat[0][:15] + '\n') players.append(stat[0][:15] + '\n')
kda.append(str(stat[2]) + '/' + str(stat[3]) + '/' + str(stat[4]) + '\n') kda.append(str(stat[2]) + '/' + str(stat[3]) + '/' + str(stat[4]) + '\n')
embed = discord.Embed(title=invocator_name, url='https://bit.ly/3biTekM', embed = discord.Embed(title=invocator_name, url='https://bit.ly/3biTekM',
@@ -58,9 +57,9 @@ class LolCmds(commands.Cog, name='League of Legend commands'):
'League_of_Legends_icon.png/revision/latest?cb=20191018194326') 'League_of_Legends_icon.png/revision/latest?cb=20191018194326')
await ctx.send(embed=embed) await ctx.send(embed=embed)
for i in range(0, -2, -1): for i in range(0, -2, -1):
embed = discord.Embed(title='Team 1' if not i else 'Team 2', colour= embed = discord.Embed(title='Team 1' if not i else 'Team 2',
discord.Colour.green() if lst[1][0][i] == 'Win' else discord.Colour.red(), description= colour=discord.Colour.green() if lst[1][0][i] == 'Win' else discord.Colour.red(),
(':drop_of_blood: First blood\n' if len(lst[1][1]) != 0 and lst[1][1][i] else '') + description=(':drop_of_blood: First blood\n' if len(lst[1][1]) != 0 and lst[1][1][i] else '') +
(':tokyo_tower: First tower\n' if len(lst[1][2]) != 0 and lst[1][2][i] else '') + (':tokyo_tower: First tower\n' if len(lst[1][2]) != 0 and lst[1][2][i] else '') +
(':dragon_face: First dragon\n' if len(lst[1][3]) != 0 and lst[1][3][i] else '')) (':dragon_face: First dragon\n' if len(lst[1][3]) != 0 and lst[1][3][i] else ''))
embed.add_field(name='Players', embed.add_field(name='Players',
+16 -13
View File
@@ -1,7 +1,8 @@
import discord import discord
import asyncio
from discord.ext import commands from discord.ext import commands
from api_osu import * from api_osu import (ask_osu_profile,
ask_osu_last_game,
ask_osu_acc)
class OsuCmds(commands.Cog, name='Osu! commands'): class OsuCmds(commands.Cog, name='Osu! commands'):
@@ -19,28 +20,29 @@ class OsuCmds(commands.Cog, name='Osu! commands'):
icon_url=r'https://upload.wikimedia.org/wikipedia/commons/4/44/Osu%21Logo_%282019%29.png') 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.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='Global Ranking', value='#'+str('{:,}'.format(lst[8])))
embed.add_field(name='Total Play Time', value= embed.add_field(name='Total Play Time',
str("%.0f" % ((lst[6] % (86400 * 30)) / 86400))+'d '+ value=str("%.0f" % ((lst[6] % (86400 * 30)) / 86400)) + 'd ' +
str("%.0f" % ((lst[6] % 86400) / 3600))+'h '+ str("%.0f" % ((lst[6] % 86400) / 3600)) + 'h ' +
str("%.0f" % ((lst[6] % 3600) / 60))+'m ') str("%.0f" % ((lst[6] % 3600) / 60)) + 'm ')
embed.add_field(name='|', value='|') embed.add_field(name='|', value='|')
embed.add_field(name='Level', value=str("%.0f" % lst[7])) 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='Ranked Score', value=str('{:,}'.format(lst[1])))
embed.add_field(name='Hit Accuracy', value=str("%.2f" % lst[2])+'%') 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='Play Count', value=str('{:,}'.format(lst[3])))
embed.add_field(name='Total Score', value=str('{:,}'.format(lst[4]))) embed.add_field(name='Total Score', value=str('{:,}'.format(lst[4])))
embed.add_field(name='Total Hits', value=str('{:,}'.format(lst[5]))) embed.add_field(name='Total Hits', value=str('{:,}'.format(lst[5])))
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(ignore_extra=False) @commands.command(ignore_extra=False)
async def osu_lastgame(self, ctx, username): async def osu_lastgame(self, ctx, username):
lst = await ask_osu_last_game(username) lst = await ask_osu_last_game(username)
if lst == 1: if lst == 1:
await ctx.send('The player you entered is unknown or didn\'t played any game recently.') await ctx.send('The player you entered is unknown or didn\'t played any game recently.')
else: else:
embed = discord.Embed(title=str(lst[1]) + ' by ' + str(lst[2]), url='https://osu.ppy.sh/beatmapsets/' + str(lst[0]), embed = discord.Embed(title=str(lst[1]) + ' by ' + str(lst[2]),
description='BPM: ' + str("%.0f" % lst[3]) + ' ; Stars: ' + str("%.1f" % lst[4]) + 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]) + ' ; CS: ' + str(lst[5]) + ' ; AR: ' + str(lst[7]) +
' ; OD: ' + str(lst[6]) + ' ; HP: ' + str(lst[8])) ' ; OD: ' + str(lst[6]) + ' ; HP: ' + str(lst[8]))
embed.set_author(name='Osu! - Last game', url='https://osu.ppy.sh/home', embed.set_author(name='Osu! - Last game', url='https://osu.ppy.sh/home',
@@ -52,7 +54,8 @@ class OsuCmds(commands.Cog, name='Osu! commands'):
embed.add_field(name='300', value=str(lst[12])) embed.add_field(name='300', value=str(lst[12]))
embed.add_field(name='Geki', value=str(lst[17])) embed.add_field(name='Geki', value=str(lst[17]))
embed.add_field(name='Accuracy', embed.add_field(name='Accuracy',
value=str("%.2f" % (((lst[12]*300)+(lst[13]*100)+(lst[14]*50))/(sum(lst[12:16])*300)*100) + '%')) 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='100', value=str(lst[13]))
embed.add_field(name='Katu', value=str(lst[16])) embed.add_field(name='Katu', value=str(lst[16]))
embed.add_field(name='Player :', value=str(username)) embed.add_field(name='Player :', value=str(username))
@@ -61,13 +64,13 @@ class OsuCmds(commands.Cog, name='Osu! commands'):
embed.add_field(name='|', value='|') embed.add_field(name='|', value='|')
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(ignore_extra=False) @commands.command(ignore_extra=False)
async def osu_acc(self, ctx, username): async def osu_acc(self, ctx, username):
test_acc = await ask_osu_acc(username) test_acc = await ask_osu_acc(username)
if test_acc: if test_acc:
embed = discord.Embed() embed = discord.Embed()
embed.set_author(name='Osu! - Accuracy', icon_url=r'https://upload.wikimedia.org/wikipedia/commons/4/44/Osu%21Logo_%282019%29.png') embed.set_author(name='Osu! - Accuracy',
icon_url=r'https://upload.wikimedia.org/wikipedia/commons/4/44/Osu%21Logo_%282019%29.png')
embed.set_image(url="attachment://acc.jpeg") embed.set_image(url="attachment://acc.jpeg")
await ctx.send(embed=embed, file=discord.File('acc.jpeg')) await ctx.send(embed=embed, file=discord.File('acc.jpeg'))
else: else:
+2 -3
View File
@@ -1,7 +1,6 @@
import discord
import asyncio import asyncio
import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands.cooldowns import BucketType
class OtherCmds(commands.Cog, name='Other commands'): class OtherCmds(commands.Cog, name='Other commands'):
@@ -10,7 +9,7 @@ class OtherCmds(commands.Cog, name='Other commands'):
@commands.command(ignore_extra=False) @commands.command(ignore_extra=False)
@commands.cooldown(1, 2, commands.BucketType.guild) @commands.cooldown(1, 2, commands.BucketType.guild)
async def issou(self, ctx, username: discord.User = None): async def issou(self, ctx, username: discord.User=None):
if username is not None: if username is not None:
user = username user = username
else: else:
+4 -7
View File
@@ -1,9 +1,8 @@
from discord.ext import commands import os
from datetime import datetime import sys
from __main__ import startup_date
import os, sys
import discord import discord
import asyncio from discord.ext import commands
from __main__ import startup_date
class OwnerCmds(commands.Cog, name='Owner commands'): class OwnerCmds(commands.Cog, name='Owner commands'):
@@ -16,7 +15,6 @@ class OwnerCmds(commands.Cog, name='Owner commands'):
self.bot.load_extension('ext.' + extension) self.bot.load_extension('ext.' + extension)
await ctx.send("Extension loaded.") await ctx.send("Extension loaded.")
@commands.command(hidden=True, ignore_extra=False) @commands.command(hidden=True, ignore_extra=False)
@commands.is_owner() @commands.is_owner()
async def unloadext(self, ctx, extension): async def unloadext(self, ctx, extension):
@@ -31,7 +29,6 @@ class OwnerCmds(commands.Cog, name='Owner commands'):
if 'Already up to date' not in result: if 'Already up to date' not in result:
os.execl(sys.executable, os.path.abspath(__file__), *sys.argv) os.execl(sys.executable, os.path.abspath(__file__), *sys.argv)
@commands.command(hidden=True) @commands.command(hidden=True)
@commands.is_owner() @commands.is_owner()
async def getlogs(self, ctx): async def getlogs(self, ctx):
+2 -3
View File
@@ -1,16 +1,16 @@
import discord
import asyncio import asyncio
import socket import socket
import re import re
import discord
from private import ID_TWITCH, TOKEN_TWITCH, SERVER, PORT, NICKNAME from private import ID_TWITCH, TOKEN_TWITCH, SERVER, PORT, NICKNAME
from discord.ext import tasks, commands from discord.ext import tasks, commands
from discord.ext.commands.cooldowns import BucketType
from emoji import demojize from emoji import demojize
from twitch import TwitchClient from twitch import TwitchClient
twitch_client = TwitchClient(client_id=ID_TWITCH, oauth_token=TOKEN_TWITCH) twitch_client = TwitchClient(client_id=ID_TWITCH, oauth_token=TOKEN_TWITCH)
chats = dict() chats = dict()
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])
if not user: if not user:
@@ -94,7 +94,6 @@ class TwitchCmds(commands.Cog, name='Twitch commands'):
else: else:
await ctx.send('```This twitch channel doesn\'t seems to exist.```') await ctx.send('```This twitch channel doesn\'t seems to exist.```')
@commands.command() @commands.command()
async def chat_stop(self, ctx): async def chat_stop(self, ctx):
try: try:
+7 -7
View File
@@ -1,11 +1,10 @@
from private import TOKEN_BOT
from time import time from time import time
from datetime import datetime from datetime import datetime
import logging
import discord
from discord.ext import commands from discord.ext import commands
from miscellaneous import spellchecker from miscellaneous import spellchecker
import logging from private import TOKEN_BOT
import os, sys
import discord
print('Loading started') print('Loading started')
@@ -25,6 +24,7 @@ logger.setLevel(logging.INFO)
commandlist = [] commandlist = []
@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')
@@ -36,7 +36,7 @@ async def on_ready():
@bot.event @bot.event
async def on_command_error(ctx, error): async def on_command_error(ctx, error):
logger.info(datetime.now().strftime("[%d-%m-%y][%H:%M:%S]") + logger.info(datetime.now().strftime("[%d-%m-%y][%H:%M:%S]") +
' \'' + str(error) + '\' from ' +str(ctx.author) + ' on ' + ' \'' + str(error) + '\' from ' + str(ctx.author) + ' on ' +
(ctx.message.guild.name if ctx.message.guild is not None else 'DMs') + '.') (ctx.message.guild.name if ctx.message.guild is not None else 'DMs') + '.')
if isinstance(error, commands.CommandNotFound): if isinstance(error, commands.CommandNotFound):
await ctx.send(spellchecker(str(ctx.message.content)[1:], commandlist)) await ctx.send(spellchecker(str(ctx.message.content)[1:], commandlist))
@@ -48,10 +48,10 @@ def init():
for extension in startup_extensions: for extension in startup_extensions:
bot.load_extension('ext.' + extension) bot.load_extension('ext.' + extension)
print('Extension "' + str(extension) + '" loaded.') print('Extension "' + str(extension) + '" loaded.')
ignore = list(map(lambda cmd : cmd.name, bot.cogs["Owner commands"].get_commands())) ignore = list(map(lambda cmd: cmd.name, bot.cogs["Owner commands"].get_commands()))
for command in bot.commands: for command in bot.commands:
name = command.name name = command.name
if not name in ignore: if name not in ignore:
commandlist.append(name) commandlist.append(name)
+3 -3
View File
@@ -13,9 +13,9 @@ def spellchecker(word, lst):
for element in lst: for element in lst:
prob = 0 prob = 0
el_size = len(element) el_size = len(element)
for car in element: for el_car in element:
for c in word: for wo_car in word:
if car == c: if el_car == wo_car:
prob += 1 prob += 1
for i in range(4): for i in range(4):
if el_size == wo_size - i: if el_size == wo_size - i: