From 1e5ba86fcf01c87b3dfc1ecf35279955301cf4c8 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Thu, 17 Dec 2020 13:55:51 +0530 Subject: major 'performance tweaks' in henti.py --- bot.py | 28 ++++++++++++++++++++++------ henti.py | 32 ++++++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/bot.py b/bot.py index 3b1e971..6cc04d1 100644 --- a/bot.py +++ b/bot.py @@ -1,20 +1,36 @@ import os +import random from dotenv import load_dotenv from discord.ext import commands -import henti as H +from henti import Numbers as n -load_dotenv() +load_dotenv() # load .env file TOKEN = os.getenv('DISCORD_TOKEN') +bot = commands.Bot(command_prefix='z!') # initialise the bot + + -bot = commands.Bot(command_prefix='z!') # get title of henti -@bot.command(name='title', help='Get the title of doujin using the holy numbers') -async def nine_nine(ctx, sauce): - r = H.get_title(sauce) +@bot.command(name='info', help='Get the title of doujin using the holy numbers') +async def getInfo(ctx, sauce): + r = n(sauce).title() await ctx.send(r) +# short for the same +@bot.command(name='i', help='short fot z!title') +async def getInfo(ctx, sauce): + r = n(sauce).title() + await ctx.send(r) + + +# @bot.command(name='', help='') +# async def + + + + bot.run(TOKEN) diff --git a/henti.py b/henti.py index 4d9a629..a6b0738 100644 --- a/henti.py +++ b/henti.py @@ -1,7 +1,31 @@ from hentai import Hentai from hentai import Format -def get_title(sauce): - # get hentai title in readable format - henti_title = str(Hentai(sauce).title(Format.Pretty)) - return henti_title +class Numbers: + def __init__(self, number): + self.sauce = Hentai(number) + + def title(self): + title = self.sauce.title(Format.Pretty) + return title +""" + def artist(self): + artist = str(Hentai(sauce).artist).split(', ')[2] # name='artist' + name = artist[6:-1] # just the artist's name + return name + + def tags(): + # get a henti's tags + pass + + def get_title(sauce): + # get hentai title in readable format + title = str(Hentai(sauce).title(Format.Pretty)) + artist = get_artist(sauce) + r = "{title} ({sauce}) by {artist}\nhttps://nhentai.net/g/{sauce}/".format(title=title, artist=artist, sauce=sauce) + return r +""" +# print(Numbers(177013).title()) +# print(Numbers.title(177013)) +# print(Numbers.title(177013)) +# print(x.title()) -- cgit v1.2.3