clean code for #23
This commit is contained in:
parent
283a3919f0
commit
29de2a539a
1 changed files with 64 additions and 47 deletions
|
@ -46,7 +46,10 @@ logger.addHandler(stream_handler)
|
|||
|
||||
class Mybot(commands.Cog):
|
||||
#Fonctions necesaires pour Kabot.
|
||||
def __init__(self, bot):
|
||||
def __init__(self, bot, gl_url=None, gl_token=None, gif_token=None):
|
||||
self.gl_url = gl_url
|
||||
self.gl_token = gl_token
|
||||
self.gif_token = gif_token
|
||||
self.bot = bot
|
||||
self.sounds = []
|
||||
self.sounds_history = []
|
||||
|
@ -74,8 +77,9 @@ class Mybot(commands.Cog):
|
|||
|
||||
@commands.command(help='list des commits')
|
||||
async def commits(self, ctx, number = 5):
|
||||
if self.gl_url and self.gl_token:
|
||||
number = int(number)
|
||||
gl = gitlab.Gitlab('https://git.0w.tf/', private_token='s-e3HXBUTroL52cNkAbe')
|
||||
gl = gitlab.gitlab(self.gl_url, self.gl_token)
|
||||
gl.auth()
|
||||
projects = gl.projects.list(search='Kabot')[0]
|
||||
commits = projects.commits.list(all=True)[:number]
|
||||
|
@ -97,9 +101,10 @@ class Mybot(commands.Cog):
|
|||
|
||||
@commands.command(help="Interrogation issues \n Args: list, search[mot clé] et add[nom de l'issue]")
|
||||
async def issue(self, ctx, *args):
|
||||
if self.gl_url and self.gl_token:
|
||||
if args:
|
||||
args = list(args)
|
||||
gl = gitlab.Gitlab('https://git.0w.tf/', private_token='s-e3HXBUTroL52cNkAbe')
|
||||
gl = gitlab.gitlab(self.gl_url, self.gl_token)
|
||||
gl.auth()
|
||||
if args[0] == 'list':
|
||||
projects = gl.projects.list(search='Kabot')[0]
|
||||
|
@ -205,8 +210,9 @@ class Mybot(commands.Cog):
|
|||
query = ctx.message.content.replace('!gif ', '')
|
||||
print(query)
|
||||
api_instance = giphy_client.DefaultApi()
|
||||
api_key = "udhL9Rgdme3HpAoFhWVZoYM0l0XwkzLz"
|
||||
api_key = self.gif_token
|
||||
lang = 'fr'
|
||||
if api_key:
|
||||
try:
|
||||
api_response = api_instance.gifs_search_get(api_key, query, lang=lang, limit=15)
|
||||
api_response.to_dict()['data'][0]
|
||||
|
@ -215,6 +221,9 @@ class Mybot(commands.Cog):
|
|||
await ctx.channel.send(get_url['url'])
|
||||
except ApiException as e:
|
||||
await ctx.channel.send("Exception when calling DefaultApi->gifs_search_get: %s\n" % e)
|
||||
else:
|
||||
await ctx.channel.send("Exception : No api key found")
|
||||
|
||||
|
||||
@commands.guild_only()
|
||||
@commands.command()
|
||||
|
@ -526,7 +535,15 @@ def get_word(word_type):
|
|||
def main():
|
||||
logger.info("Initialisation de Kabot")
|
||||
token = "NjI3MTM3NDY1MDA5ODMxOTQ2.Xxl5dg.-eXs6op39SyB1psp4QZIXv7kPuY"
|
||||
bot = commands.Bot(command_prefix='!')
|
||||
gl_url = 'https://git.0w.tf/'
|
||||
gl_token='s-e3HXBUTroL52cNkAbe'
|
||||
gif_token = "udhL9Rgdme3HpAoFhWVZoYM0l0XwkzLz"
|
||||
bot = commands.Bot(
|
||||
command_prefix='!',
|
||||
gl_url=gl_url,
|
||||
gl_token=gl_token,
|
||||
gif_token=git_token
|
||||
)
|
||||
|
||||
test = False
|
||||
if "test" in argv[-1]:
|
||||
|
|
Loading…
Reference in a new issue