Skip to content

Commit ea277c2

Browse files
committed
Merge branch 'master' into dev
# Conflicts: # Teapot.py # requirements.txt
2 parents 3be2ca5 + d2288a7 commit ea277c2

File tree

5 files changed

+46
-7
lines changed

5 files changed

+46
-7
lines changed

Teapot.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from discord.ext import commands as dcmd
99
from dotenv import load_dotenv
1010

11-
import teapot # import teapot.py core
11+
import teapot
1212

1313
print(f"""
1414
_____ _
@@ -57,10 +57,10 @@
5757
print("Missing environment variables. Please backup and delete .env, then run Teapot.py again.")
5858
quit(2)
5959
print("Unable to find required environment variables. Running setup.py...") # if .env not found
60-
teapot.setup.__init__() # run setup.py
60+
teapot.setup.__init__() # run setup.py
6161

6262
print("Initializing bot...")
63-
if teapot.config.storage_type() == "mysql": # if .env use mysql, create the table if table not exists
63+
if teapot.config.storage_type() == "mysql": # if .env use mysql, create the table if table not exists
6464
time_start = time.perf_counter()
6565
database = teapot.managers.database.__init__()
6666
db = teapot.managers.database.db(database)
@@ -96,12 +96,13 @@ async def on_ready():
9696
teapot.cogs.osu.setup(bot)
9797
teapot.cogs.github.setup(bot)
9898
teapot.cogs.cat.setup(bot)
99+
teapot.cogs.eightball.setup(bot)
99100
teapot.cogs.neko.setup(bot)
100101
if teapot.config.storage_type() == "mysql":
101102
for guild in bot.guilds:
102103
teapot.managers.database.create_guild_table(guild)
103104
elif teapot.config.storage_type() == "sqlite":
104-
print("[!] Warning: SQLite storage has not been implemented yet. MySQL database is recommended") # WIP
105+
print("[!] Warning: SQLite storage has not been implemented yet. MySQL is recommended") # WIP
105106
print(f"Registered commands and events in {round(time.perf_counter() - time_start, 2)}s")
106107
await bot.change_presence(status=discord.Status.online,
107108
activity=discord.Game(teapot.config.bot_status())) # Update Bot status

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
aiohttp>=3.6.2
32
async-timeout>=3.0.1
43
attrs>=19.3.0
@@ -19,4 +18,4 @@ typing-extensions>=3.7.4.2
1918
urllib3>=1.25.10
2019
websockets>=8.1
2120
yarl>=1.5.1
22-
mysql-connector-python>=8.0.21
21+
mysql-connector-python>=8.0.21

teapot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
def version():
11-
return "v0.0.1.6"
11+
return "v0.0.1.7"
1212

1313

1414
def config_version():

teapot/cogs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .cat import *
22
from .cmds import *
3+
from .eightball import *
34
from .github import *
45
from .music import *
56
from .neko import *

teapot/cogs/eightball.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
""" Module for generating random neko pictures"""
2+
import io
3+
import json
4+
5+
import aiohttp
6+
import discord
7+
import requests
8+
from discord.ext import commands
9+
10+
import teapot
11+
import teapot.tools.embed as dmbd
12+
13+
14+
class EightBall(commands.Cog):
15+
"""8 Ball"""
16+
17+
def __init__(self, bot):
18+
""" Initialize 8ball class"""
19+
self.bot = bot
20+
21+
def eightball_api(self, ctx):
22+
try:
23+
req = requests.get(f'https://nekos.life/api/v2/8ball/{x}')
24+
if req.status_code != 200:
25+
print("Could not get a response")
26+
apijson = json.loads(req.text)
27+
em = dmbd.newembed().set_image(url=apijson["url"])
28+
return em
29+
except:
30+
return teapot.messages.error(f"obtaining 8ball image ({req.status_code})")
31+
32+
@commands.command(pass_context=True)
33+
async def eightball(self, ctx):
34+
await ctx.send(embed=self.eightball_api(ctx))
35+
36+
def setup(bot):
37+
""" Setup Eight Ball Module"""
38+
bot.add_cog(EightBall(bot))

0 commit comments

Comments
 (0)