better import
This commit is contained in:
parent
b9393a87e0
commit
7c1c34272a
4 changed files with 14 additions and 18 deletions
|
@ -1,9 +1,7 @@
|
|||
import discord
|
||||
import re
|
||||
import os
|
||||
from re import findall
|
||||
from discord.ext import commands
|
||||
from random import choice
|
||||
customTimezone = os.environ['TIMEZONE']
|
||||
from utils.core import userOrNick
|
||||
from utils.time import nowCustom, intToDatetime, nowUTC, timestampScreen
|
||||
from cogs.internet import Internet
|
||||
|
@ -79,7 +77,7 @@ class ConfrerieDuKassoulait(commands.Cog):
|
|||
if not (
|
||||
message.content.startswith(f"{prefix}note") or
|
||||
message.content.startswith(f"{prefix}memo") or
|
||||
len(re.findall(".com/channels/", message.content)) != 0 or
|
||||
len(findall(".com/channels/", message.content)) != 0 or
|
||||
self.client.user.id is message.author.id
|
||||
):
|
||||
user_suppressed = None
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import discord
|
||||
import re
|
||||
from re import findall
|
||||
from discord.ext import commands
|
||||
from random import randint, choice
|
||||
from datetime import timedelta
|
||||
|
@ -161,7 +161,7 @@ class Fun(commands.Cog):
|
|||
final_message = message.content
|
||||
suite_auteur = message.author
|
||||
|
||||
urls = re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', final_message)
|
||||
urls = findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', final_message)
|
||||
for i in range (0, len(urls)):
|
||||
final_message = final_message.replace(urls[i], '')
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import discord
|
||||
import feedparser
|
||||
import os
|
||||
from os import environ
|
||||
from discord.ext import commands
|
||||
from random import choice
|
||||
from asyncpraw import Reddit
|
||||
|
@ -37,7 +37,7 @@ class Internet(commands.Cog):
|
|||
'2meirl4meirl', 'AdviceAnimals', 'weirdmemes'])
|
||||
|
||||
try:
|
||||
async with Reddit(client_id = os.environ['TOKEN_REDDIT_CLIENT_ID'], client_secret = os.environ['TOKEN_REDDIT_CLIENT_SECRET'], user_agent = f"disreddit /u/{os.environ['TOKEN_REDDIT_USER_AGENT']}, http://localhost:8080") as reddit:
|
||||
async with Reddit(client_id = environ['TOKEN_REDDIT_CLIENT_ID'], client_secret = environ['TOKEN_REDDIT_CLIENT_SECRET'], user_agent = f"disreddit /u/{environ['TOKEN_REDDIT_USER_AGENT']}, http://localhost:8080") as reddit:
|
||||
subreddit = await reddit.subreddit(subredditchoix) # récupération du subreddit
|
||||
hot = subreddit.top(limit = 20) # récupération des memes avec une limite aux 10 premiers memes
|
||||
all_subs = [item async for item in hot] # liste des memes
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import discord
|
||||
import os
|
||||
import re
|
||||
from os import environ, path
|
||||
from re import findall
|
||||
from discord.ext import commands, tasks
|
||||
from random import randint, shuffle
|
||||
from pytz import timezone
|
||||
from discord_slash import cog_ext
|
||||
from utils.reminder import Reminder
|
||||
from utils.core import map_list_among_us, getURLsInString, getMentionInString, cleanCodeStringWithMentionAndURLs
|
||||
from utils.core import cleanUser, userOrNick
|
||||
from utils.core import map_list_among_us, getURLsInString, getMentionInString, cleanCodeStringWithMentionAndURLs, cleanUser, userOrNick
|
||||
from utils.time import stringTempsVersSecondes, nowUTC, intToDatetime, timedeltaToString, timestampScreen, getAge, ageLayout, nowCustom
|
||||
|
||||
def setup(client):
|
||||
|
@ -17,7 +16,7 @@ class Utils(commands.Cog):
|
|||
"""Commandes essentielles."""
|
||||
def __init__(self, client):
|
||||
self.client = client
|
||||
self.customTimezone = os.environ['TIMEZONE']
|
||||
self.customTimezone = environ['TIMEZONE']
|
||||
self._reminderLoop.start()
|
||||
|
||||
@commands.command(name='ping')
|
||||
|
@ -260,9 +259,8 @@ class Utils(commands.Cog):
|
|||
voice = len(voice_channels)
|
||||
nombreServeur = len(self.client.guilds)
|
||||
|
||||
with open(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "README.md"), "r") as file:
|
||||
for versionNumber in re.findall(r'https://img.shields.io/badge/version-(\d+\.\d+)', file.readlines()[2]):
|
||||
version = versionNumber
|
||||
with open(path.join(path.dirname(path.dirname(path.dirname(__file__))), "README.md"), "r") as file:
|
||||
version = findall(r'https://img.shields.io/badge/version-(\d+\.\d+)', file.readlines()[2])[0]
|
||||
|
||||
embed.add_field(name = "Dev", value = f"[{appinfo.owner}](https://github.com/Mylloon)")
|
||||
embed.add_field(name = f"Serveur{'s' if nombreServeur > 1 else ''}", value = f"`{nombreServeur}`")
|
||||
|
@ -398,7 +396,7 @@ class Utils(commands.Cog):
|
|||
args = list(args)
|
||||
if len(args) > 2:
|
||||
question = args[0]
|
||||
for i in re.findall(r'\d+', question):
|
||||
for i in findall(r'\d+', question):
|
||||
question = cleanUser(ctx, question, i)
|
||||
propositions = args[1:]
|
||||
if len(propositions) <= 20:
|
||||
|
@ -465,7 +463,7 @@ class Utils(commands.Cog):
|
|||
titre = "Nouveau vote"
|
||||
else: # si titre défini
|
||||
titre = args[0]
|
||||
for findedId in re.findall(r'\d+', titre): # récupération mention dans titre
|
||||
for findedId in findall(r'\d+', titre): # récupération mention dans titre
|
||||
titre = cleanUser(ctx, titre, findedId)
|
||||
args = args[1:]
|
||||
embed = discord.Embed(title = titre, description = cleanCodeStringWithMentionAndURLs(args[0]), color = discord.Colour.random()).set_footer(text = f"Sondage de {userOrNick(ctx.author)}", icon_url = ctx.author.avatar_url)
|
||||
|
|
Reference in a new issue