|
14 | 14 | class Neko(commands.Cog):
|
15 | 15 | """ Cat Module"""
|
16 | 16 |
|
17 |
| - # api_options = ['femdom', 'tickle', 'classic', 'ngif', 'erofeet', 'meow', 'erok', 'poke', 'les', 'v3', |
18 |
| - # 'hololewd', 'nekoapi_v3.1', 'lewdk', 'keta', 'feetg', 'nsfw_neko_gif', 'eroyuri', 'kiss', '8ball', 'kuni', |
19 |
| - # 'tits', 'pussy_jpg', 'cum_jpg', 'pussy', 'lewdkemo', 'lizard', 'slap', 'lewd', 'cum', 'cuddle', 'spank', |
20 |
| - # 'smallboobs', 'goose', 'Random_hentai_gif', 'avatar', 'fox_girl', 'nsfw_avatar', 'hug', 'gecg', 'boobs', 'pat', |
21 |
| - # 'feet', 'smug', 'kemonomimi', 'solog', 'holo', 'wallpaper', 'bj', 'woof', 'yuri', 'trap', 'anal', 'baka', |
22 |
| - # 'blowjob', 'holoero', 'feed', 'neko', 'gasm', 'hentai', 'futanari', 'ero', 'solo', 'waifu', 'pwankg', 'eron', |
23 |
| - # 'erokemo'] |
24 |
| - |
25 | 17 | def __init__(self, bot):
|
26 | 18 | """ Initialize Cat Class"""
|
27 | 19 |
|
28 | 20 | self.bot = bot
|
29 | 21 |
|
| 22 | + def neko_api(self, ctx, x): |
| 23 | + try: |
| 24 | + req = requests.get(f'https://nekos.life/api/v2/img/{x}') |
| 25 | + if req.status_code != 200: |
| 26 | + print("Could not get a neko") |
| 27 | + apijson = json.loads(req.text) |
| 28 | + url = apijson["url"] |
| 29 | + em = dmbd.newembed().set_image(url=url) |
| 30 | + return em |
| 31 | + except: |
| 32 | + return teapot.messages.error(f"obtaining image ({req.status_code})") |
| 33 | + |
30 | 34 | @commands.command(pass_context=True)
|
31 | 35 | async def neko(self, ctx):
|
32 |
| - """ When User Types ~neko, return a neko link """ |
33 |
| - req = requests.get('https://nekos.life/api/v2/img/neko') |
34 |
| - if req.status_code != 200: |
35 |
| - print("Could not get a neko") |
36 |
| - nekolink = json.loads(req.text) |
37 |
| - rngneko = nekolink["url"] |
38 |
| - em = dmbd.newembed() |
39 |
| - em.set_image(url=rngneko) |
40 |
| - await ctx.send(embed=em) |
| 36 | + await ctx.send(embed=self.neko_api(ctx, "neko")) |
41 | 37 |
|
42 | 38 | @commands.command(pass_context=True)
|
43 | 39 | async def waifu(self, ctx):
|
44 |
| - """ When User Types ~waifu, return a waifu link """ |
45 |
| - req = requests.get('https://nekos.life/api/v2/img/waifu') |
46 |
| - if req.status_code != 200: |
47 |
| - print("Could not get a waifu") |
48 |
| - waifulink = json.loads(req.text) |
49 |
| - rngwaifu = waifulink["url"] |
50 |
| - em = dmbd.newembed() |
51 |
| - em.set_image(url=rngwaifu) |
52 |
| - await ctx.send(embed=em) |
53 |
| - |
54 |
| - @commands.command(pass_context=True, aliases=['manofculture']) |
| 40 | + await ctx.send(embed=self.neko_api(ctx, "waifu")) |
| 41 | + |
| 42 | + @commands.command(pass_context=True) |
| 43 | + async def avatar(self, ctx): |
| 44 | + await ctx.send(embed=self.neko_api(ctx, "avatar")) |
| 45 | + |
| 46 | + @commands.command(pass_context=True) |
| 47 | + async def wallpaper(self, ctx): |
| 48 | + await ctx.send(embed=self.neko_api(ctx, "wallpaper")) |
| 49 | + |
| 50 | + @commands.command(pass_context=True) |
| 51 | + async def tickle(self, ctx): |
| 52 | + await ctx.send(embed=self.neko_api(ctx, "tickle")) |
| 53 | + |
| 54 | + @commands.command(pass_context=True) |
| 55 | + async def ngif(self, ctx): |
| 56 | + await ctx.send(embed=self.neko_api(ctx, "ngif")) |
| 57 | + |
| 58 | + @commands.command(pass_context=True) |
| 59 | + async def poke(self, ctx): |
| 60 | + await ctx.send(embed=self.neko_api(ctx, "poke")) |
| 61 | + |
| 62 | + @commands.command(pass_context=True) |
| 63 | + async def kiss(self, ctx): |
| 64 | + await ctx.send(embed=self.neko_api(ctx, "kiss")) |
| 65 | + |
| 66 | + @commands.command(pass_context=True, aliases=['8ball']) |
| 67 | + async def eightball(self, ctx): |
| 68 | + await ctx.send(embed=self.neko_api(ctx, "8ball")) |
| 69 | + |
| 70 | + @commands.command(pass_context=True) |
| 71 | + async def lizard(self, ctx): |
| 72 | + await ctx.send(embed=self.neko_api(ctx, "lizard")) |
| 73 | + |
| 74 | + @commands.command(pass_context=True) |
| 75 | + async def slap(self, ctx): |
| 76 | + await ctx.send(embed=self.neko_api(ctx, "slap")) |
| 77 | + |
| 78 | + @commands.command(pass_context=True) |
| 79 | + async def cuddle(self, ctx): |
| 80 | + await ctx.send(embed=self.neko_api(ctx, "cuddle")) |
| 81 | + |
| 82 | + @commands.command(pass_context=True) |
| 83 | + async def goose(self, ctx): |
| 84 | + await ctx.send(embed=self.neko_api(ctx, "goose")) |
| 85 | + |
| 86 | + @commands.command(pass_context=True) |
| 87 | + async def gox_girl(self, ctx): |
| 88 | + await ctx.send(embed=self.neko_api(ctx, "fox_girl")) |
| 89 | + |
| 90 | + @commands.command(pass_context=True) |
55 | 91 | async def hentai(self, ctx, type=""):
|
56 |
| - """ When User Types ~hentai, return a hentai link """ |
57 | 92 | if ctx.message.channel.nsfw:
|
58 |
| - if type.lower() == "ero": |
59 |
| - req = requests.get('https://nekos.life/api/v2/img/ero') |
60 |
| - if req.status_code != 200: |
61 |
| - print("Could not get a hentai image") |
62 |
| - hentailink = json.loads(req.text) |
63 |
| - hentaiimg = hentailink["url"] |
64 |
| - |
65 |
| - message = await ctx.send(embed=teapot.messages.downloading()) |
66 |
| - async with aiohttp.ClientSession() as session: |
67 |
| - async with session.get(hentaiimg) as resp: |
68 |
| - if resp.status != 200: |
69 |
| - return await ctx.send('Could not download file...') |
70 |
| - data = io.BytesIO(await resp.read()) |
71 |
| - await ctx.send(file=discord.File(data, 'SPOILER_HENTAI.gif')) |
72 |
| - await message.delete() |
73 |
| - elif type.lower() == "neko": |
74 |
| - req = requests.get('https://nekos.life/api/v2/img/nsfw_neko_gif') |
75 |
| - if req.status_code != 200: |
76 |
| - print("Could not get a hentai image") |
77 |
| - hentailink = json.loads(req.text) |
78 |
| - hentaiimg = hentailink["url"] |
79 |
| - |
80 |
| - message = await ctx.send(embed=teapot.messages.downloading()) |
81 |
| - async with aiohttp.ClientSession() as session: |
82 |
| - async with session.get(hentaiimg) as resp: |
83 |
| - if resp.status != 200: |
84 |
| - return await ctx.send('Could not download file...') |
85 |
| - data = io.BytesIO(await resp.read()) |
86 |
| - await ctx.send(file=discord.File(data, 'SPOILER_HENTAI.gif')) |
87 |
| - await message.delete() |
88 |
| - elif type.lower() == "random": |
89 |
| - req = requests.get('https://nekos.life/api/v2/img/Random_hentai_gif') |
90 |
| - if req.status_code != 200: |
91 |
| - print("Could not get a hentai image") |
92 |
| - hentailink = json.loads(req.text) |
93 |
| - hentaiimg = hentailink["url"] |
94 |
| - |
95 |
| - message = await ctx.send(embed=teapot.messages.downloading()) |
96 |
| - async with aiohttp.ClientSession() as session: |
97 |
| - async with session.get(hentaiimg) as resp: |
98 |
| - if resp.status != 200: |
99 |
| - return await ctx.send('Could not download file...') |
100 |
| - data = io.BytesIO(await resp.read()) |
101 |
| - await ctx.send(file=discord.File(data, 'SPOILER_HENTAI.gif')) |
102 |
| - await message.delete() |
103 |
| - else: |
| 93 | + api_types = ['femdom', 'classic', 'erofeet', 'erok', 'les', |
| 94 | + 'hololewd', 'lewdk', 'keta', 'feetg', 'nsfw_neko_gif', 'eroyuri', |
| 95 | + 'tits', 'pussy_jpg', 'cum_jpg', 'pussy', 'lewdkemo', 'lewd', 'cum', 'spank', |
| 96 | + 'smallboobs', 'Random_hentai_gif', 'nsfw_avatar', 'hug', 'gecg', 'boobs', 'pat', |
| 97 | + 'feet', 'smug', 'kemonomimi', 'solog', 'holo', 'bj', 'woof', 'yuri', 'trap', 'anal', 'baka', |
| 98 | + 'blowjob', 'holoero', 'feed', 'gasm', 'hentai', 'futanari', 'ero', 'solo', 'pwankg', 'eron', |
| 99 | + 'erokemo'] |
| 100 | + if type in api_types: |
104 | 101 | try:
|
105 | 102 | req = requests.get(f'https://nekos.life/api/v2/img/{type}')
|
106 | 103 | if req.status_code != 200:
|
107 |
| - print("Could not get a hentai image") |
108 |
| - hentailink = json.loads(req.text) |
109 |
| - hentaiimg = hentailink["url"] |
| 104 | + print("Unable to obtain image") |
| 105 | + apijson = json.loads(req.text) |
| 106 | + url = apijson["url"] |
110 | 107 |
|
111 | 108 | message = await ctx.send(embed=teapot.messages.downloading())
|
112 | 109 | async with aiohttp.ClientSession() as session:
|
113 |
| - async with session.get(hentaiimg) as resp: |
| 110 | + async with session.get(url) as resp: |
114 | 111 | if resp.status != 200:
|
| 112 | + print(resp.status) |
| 113 | + print(await resp.read()) |
115 | 114 | return await ctx.send('Could not download file...')
|
116 | 115 | data = io.BytesIO(await resp.read())
|
117 |
| - await ctx.send(file=discord.File(data, 'SPOILER_HENTAI.gif')) |
| 116 | + await ctx.send( |
| 117 | + file=discord.File(data, f'SPOILER_HENTAI.{url.split("/")[-1].split(".")[-1]}')) |
118 | 118 | await message.delete()
|
119 | 119 | except:
|
120 |
| - await ctx.send(embed=teapot.messages.invalidarguments("ero, neko, random")) |
| 120 | + await ctx.send(embed=teapot.messages.error(f"obtaining image ({req.status_code})")) |
| 121 | + else: |
| 122 | + await ctx.send(embed=teapot.messages.invalidargument(", ".join(api_types))) |
121 | 123 | else:
|
122 | 124 | await ctx.send("This command only works in NSFW channels!")
|
123 | 125 |
|
|
0 commit comments