Skip to content

Commit a915cc4

Browse files
authored
Merge pull request #1 from RedCokeDevelopment/0.0.1.4
0.0.1.4 Update
2 parents 231ac92 + f6c60bf commit a915cc4

File tree

15 files changed

+243
-145
lines changed

15 files changed

+243
-145
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121

2222
Teapot.py is an open source Discord bot that aims to be as customisable as possible as well as providing essential tools for server administrators to run their Discord server!
2323

24-
If you want to try it out by yourself, feel free to invite it to your Discord server by clicking [Here](https://discordapp.com/api/oauth2/authorize?client_id=669880564270104586&permissions=0&scope=bot)!
24+
If you want to try it out by yourself, feel free to invite it to your Discord server by clicking [Here](https://discordapp.com/oauth2/authorize?client_id=669880564270104586&permissions=8&scope=bot)!
2525

2626
## ⌨ Planned Features
2727
- Music Player
2828
- Moderation Tools
2929
- Localization
30-
- Storage Type Support
30+
- Fun Commands
3131

3232

3333
## 📖 Wiki

Teapot.py

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,44 @@
11
import os
22
import time
33
from os.path import join, dirname
4+
import json
5+
import requests
46

57
import discord
68
from discord.ext import commands as dcmd
79
from dotenv import load_dotenv
810

911
import teapot
1012

11-
print("""
13+
print(f"""
1214
_____ _
1315
|_ _|__ __ _ _ __ ___ | |_
14-
| |/ _ \/ _` | '_ \ / _ \| __|
16+
| |/ _ \\/ _` | '_ \\ / _ \\| __|
1517
| | __/ (_| | |_) | (_) | |_
16-
|_|\___|\__,_| .__/ \___/ \__|
18+
|_|\\___|\\__,_| .__/ \\___/ \\__|
1719
by ColaIan |_| & RedTea
20+
21+
Running Teapot.py {teapot.version()}
1822
""")
1923

24+
req = requests.get(f'https://api.github.com/repos/RedCokeDevelopment/Teapot.py/tags')
25+
response = json.loads(req.text)
26+
if req.status_code == 200:
27+
if response[0]['name'] == teapot.version():
28+
print("You are currently running the latest version of Teapot.py!\n")
29+
else:
30+
versionlisted = False
31+
for x in response:
32+
if x['name'] == teapot.version():
33+
versionlisted = True
34+
print("You are not using our latest version! :(\n")
35+
if not versionlisted:
36+
print("You are currently using an unlisted version!\n")
37+
elif req.status_code == 404:
38+
print("Unable to fetch the latest Teapot.py version from GitHub!\n")
39+
else:
40+
print("An unknown error has occurred when fetching the latest version of Teapot.py\n")
41+
2042
load_dotenv(join(dirname(__file__), '.env'))
2143

2244
if os.getenv('CONFIG_VERSION') != teapot.config_version():
@@ -31,10 +53,24 @@
3153
time_start = time.perf_counter()
3254
database = teapot.managers.database.__init__()
3355
db = teapot.managers.database.db(database)
34-
db.execute('CREATE TABLE IF NOT EXISTS `guilds` (`guild_id` BIGINT, `guild_name` TINYTEXT)')
35-
db.execute('CREATE TABLE IF NOT EXISTS `channels` (`channel_id` BIGINT, `channel_name` TINYTEXT)')
36-
db.execute("CREATE TABLE IF NOT EXISTS `users` (`user_id` BIGINT, `user_name` TINYTEXT, `user_discriminator` INT)")
37-
print(f"Connected to database ({teapot.config.db_host()}) in {round(time.perf_counter() - time_start, 2)}s")
56+
db.execute('ALTER DATABASE teapot CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci')
57+
db.execute(
58+
'CREATE TABLE IF NOT EXISTS `guilds` (`guild_id` BIGINT, `guild_name` TINYTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci')
59+
db.execute(
60+
'CREATE TABLE IF NOT EXISTS `channels` (`channel_id` BIGINT, `channel_name` TINYTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci')
61+
db.execute(
62+
"CREATE TABLE IF NOT EXISTS `users` (`user_id` BIGINT, `user_name` TINYTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, `user_discriminator` INT) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci")
63+
db.execute(
64+
"CREATE TABLE IF NOT EXISTS `bot_logs` (`timestamp` TEXT, `type` TINYTEXT, `class` TINYTEXT, `message` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci")
65+
teapot.managers.database.create_table(
66+
"CREATE TABLE IF NOT EXISTS `guild_logs` (`timestamp` TEXT, `guild_id` BIGINT, `channel_id` BIGINT, `message_id` BIGINT, `user_id` BIGINT, `action_type` TINYTEXT, `message` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci")
67+
68+
print(
69+
f"Connected to database ({teapot.config.db_host()}:{teapot.config.db_port()}) in {round(time.perf_counter() - time_start, 2)}s")
70+
71+
db.execute("INSERT INTO `bot_logs`(timestamp, type, class, message) VALUES(%s, %s, %s, %s)",
72+
(teapot.time(), "BOT_START", __name__, "Initialized bot"))
73+
database.commit()
3874

3975
bot = dcmd.Bot(command_prefix=teapot.config.bot_prefix())
4076

@@ -53,41 +89,18 @@ async def on_ready():
5389
if teapot.config.storage_type() == "mysql":
5490
for guild in bot.guilds:
5591
teapot.managers.database.create_guild_table(guild)
56-
elif teapot.config.storage_type() == "flatfile":
57-
print("[!] Flatfile storage has not been implemented yet. MySQL database is recommended")
92+
elif teapot.config.storage_type() == "sqlite":
93+
print("[!] SQLite storage has not been implemented yet. MySQL database is recommended")
5894
print(f"Registered commands and events in {round(time.perf_counter() - time_start, 2)}s")
5995
await bot.change_presence(status=discord.Status.online, activity=discord.Game(teapot.config.bot_status()))
6096

6197

62-
@bot.event
63-
async def on_message(message):
64-
guild = message.guild
65-
if teapot.config.storage_type() == "mysql":
66-
try:
67-
db.execute("SELECT * FROM `users` WHERE user_id = '" + str(message.author.id) + "'")
68-
if db.rowcount == 0:
69-
db.execute("INSERT INTO `users`(user_id, user_name, user_discriminator) VALUES(%s, %s, %s)",
70-
(message.author.id, message.author.name, message.author.discriminator.zfill(4)))
71-
database.commit()
72-
73-
db.execute("SELECT * FROM `channels` WHERE channel_id = '" + str(message.channel.id) + "'")
74-
if db.rowcount == 0:
75-
db.execute("INSERT INTO `channels`(channel_id, channel_name) VALUES(%s, %s)",
76-
(message.channel.id, message.channel.name))
77-
database.commit()
78-
db.execute("INSERT INTO `" + str(
79-
guild.id) + "_logs" + "`(timestamp, guild_id, channel_id, message_id, user_id, action_type, message) VALUES(%s, %s, %s, %s, %s, %s, %s)",
80-
(teapot.time(), message.guild.id, message.channel.id, message.id, message.author.id,
81-
"MESSAGE_SEND", message.content))
82-
database.commit()
83-
except Exception as e:
84-
print(e)
85-
await bot.process_commands(message)
86-
8798

8899
try:
89100
discord_time_start = time.perf_counter()
90101
bot.run(teapot.config.bot_token())
91102
except Exception as e:
92-
print(e)
93-
print("[/!\] Failed to connect to DiscordAPI. Please check your bot token!")
103+
print(f"[/!\\] Failed to connect to DiscordAPI. Please check your bot token!\n{e}")
104+
if teapot.config.storage_type() == "mysql":
105+
db.execute("INSERT INTO `bot_logs`(timestamp, type, class, message) VALUES(%s, %s, %s, %s)",
106+
(teapot.time(), "ERROR", __name__, e))

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
aiohttp==3.5.4
1+
aiohttp==3.6.2
22
async-timeout==3.0.1
33
attrs==19.3.0
44
beautifulsoup4==4.8.2
55
bs4==0.0.1
66
certifi==2019.11.28
77
chardet==3.0.4
8-
discord.py==1.2.5
8+
discord.py==1.3.0
99
idna==2.8
1010
lavalink==3.0.0
1111
multidict==4.7.4

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 "0.0.1"
11+
return "v0.0.1.4"
1212

1313

1414
def config_version():

teapot/cogs/cat.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class Cat(commands.Cog):
12-
""" Cat Module"""
12+
""" Cat and dog command"""
1313

1414
def __init__(self, bot):
1515
""" Initialize Cat Class"""
@@ -18,7 +18,7 @@ def __init__(self, bot):
1818

1919
@commands.command(pass_context=True, aliases=['meow'])
2020
async def cat(self, ctx):
21-
""" When User Types ~meow, return a cat link """
21+
""" Get a cat image """
2222
req = requests.get('https://api.thecatapi.com/v1/images/search')
2323
if req.status_code != 200:
2424
print("Could not get a meow")
@@ -30,6 +30,7 @@ async def cat(self, ctx):
3030

3131
@commands.command(pass_context=True, aliases=['woof'])
3232
async def dog(self, ctx):
33+
""" Get a dog image """
3334
req = requests.get('http://random.dog/')
3435
if req.status_code != 200:
3536
print("Could not get a woof")

teapot/cogs/cmds.py

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(bot):
99
helpcmd(bot)
1010
info(bot)
1111
ping(bot)
12-
purge(bot)
12+
prune(bot)
1313
kick(bot)
1414
ban(bot)
1515
admin(bot)
@@ -19,35 +19,61 @@ def helpcmd(bot):
1919
bot.remove_command('help')
2020

2121
@bot.command(aliases=['?'])
22-
async def help(ctx):
23-
embed = discord.Embed(title="Command List", description="List of commands that you can use",
24-
color=0x7400FF)
25-
embed.set_author(name=f"Teapot.py | {teapot.version()}",
26-
icon_url="https://cdn.discordapp.com/avatars/612634758744113182/7fe078b5ea6b43000dfb7964e3e4d21d.png?size=512")
27-
embed.set_thumbnail(url="https://avatars2.githubusercontent.com/u/60006969?s=200&v=4")
28-
embed.add_field(name="General", value="``help``, ``info``", inline=False)
29-
embed.add_field(name="Music",
30-
value="``play``, ``pause``, ``resume``, ``stop``, ``repeat``, ``seek``, ``skip``, ``remove``, ``now``, ``queue``, ``volume``, ``shuffle``, ``find``, ``disconnect``",
31-
inline=False)
32-
embed.add_field(name="Tools", value="``github``, ``osu``", inline=False)
33-
embed.add_field(name="Fun", value="``cat``, ``dog``, ``neko``, ``hentai [NSFW]``", inline=False)
34-
embed.add_field(name="Staff", value="``purge``, ``ping``, ``kick``, ``ban``", inline=False)
35-
embed.add_field(name="Links",
36-
value="[Support Discord](https://discord.gg/7BRGs6F) | [Add bot to server](https://discordapp.com/api/oauth2/authorize?client_id=669880564270104586&permissions=0&scope=bot) | [Repository](https://github.com/RedCokeDevelopment/Teapot.py)",
37-
inline=False)
38-
39-
embed.set_image(
40-
url="https://user-images.githubusercontent.com/43201383/72987537-89830a80-3e25-11ea-95ef-ecfa0afcff7e.png")
41-
embed.set_footer(text=f"{teapot.copyright()} | Code licensed under the MIT License")
42-
await ctx.send(embed=embed)
22+
async def help(ctx, *cog):
23+
if not cog:
24+
embed = discord.Embed(description="📖 Help", color=0x7400FF,
25+
icon_url="https://cdn.discordapp.com/avatars/612634758744113182/7fe078b5ea6b43000dfb7964e3e4d21d.png?size=512")
26+
embed.set_thumbnail(url="https://avatars2.githubusercontent.com/u/60006969?s=200&v=4")
27+
cogs_desc = ""
28+
for x in bot.cogs:
29+
cogs_desc += f'**{x}** - {bot.cogs[x].__doc__}\n'
30+
embed.add_field(name='Modules', value=cogs_desc[0:len(cogs_desc) - 1])
31+
embed.set_footer(text=f"{teapot.copyright()} | Code licensed under the MIT License")
32+
await ctx.send(embed=embed)
33+
await ctx.message.add_reaction(emoji='✅')
34+
else:
35+
if len(cog) > 1:
36+
await ctx.send(embed=teapot.messages.toomanyarguments())
37+
await ctx.message.add_reaction(emoji='🛑')
38+
else:
39+
found = False
40+
for x in bot.cogs:
41+
for y in cog:
42+
if x == y:
43+
embed = discord.Embed(color=0x7400FF)
44+
cog_info = ''
45+
for c in bot.get_cog(y).get_commands():
46+
if not c.hidden:
47+
cog_info += f"**{c.name}** - {c.help}\n"
48+
embed.add_field(name=f"{cog[0]} Module", value=cog_info)
49+
await ctx.send(embed=embed)
50+
await ctx.message.add_reaction(emoji='✅')
51+
found = True
52+
if not found:
53+
for x in bot.cogs:
54+
for c in bot.get_cog(x).get_commands():
55+
if c.name.lower() == cog[0].lower():
56+
embed = discord.Embed(title=f"Command: {c.name.lower().capitalize()}",
57+
description=f"**Description:** {c.help}\n**Syntax:** {c.qualified_name} {c.signature}",
58+
color=0x7400FF)
59+
embed.set_author(name=f"Teapot.py {teapot.version()}",
60+
icon_url="https://cdn.discordapp.com/avatars/612634758744113182/7fe078b5ea6b43000dfb7964e3e4d21d.png?size=512")
61+
await ctx.message.add_reaction(emoji='✅')
62+
found = True
63+
if not found:
64+
embed = teapot.messages.notfound("Module")
65+
await ctx.message.add_reaction(emoji='🛑')
66+
await ctx.send(embed=embed)
67+
else:
68+
await ctx.message.add_reaction(emoji='✅')
4369

4470

4571
def info(bot):
4672
@bot.command(aliases=['about'])
4773
async def info(ctx):
4874
embed = discord.Embed(title="Developers: ColaIan, RedTea", description="Multi-purpose Discord Bot",
4975
color=0x7400FF)
50-
embed.set_author(name=f"Teapot.py | {teapot.version()}",
76+
embed.set_author(name=f"Teapot.py {teapot.version()}",
5177
icon_url="https://cdn.discordapp.com/avatars/612634758744113182/7fe078b5ea6b43000dfb7964e3e4d21d.png?size=512")
5278
embed.set_thumbnail(url="https://avatars2.githubusercontent.com/u/60006969?s=200&v=4")
5379
embed.add_field(name="Bot User:", value=bot.user, inline=True)
@@ -61,6 +87,9 @@ async def info(ctx):
6187
embed.add_field(name="Bug Report:", value="[Issues](https://github.com/RedCokeDevelopment/Teapot.py/issues)",
6288
inline=True)
6389
embed.add_field(name="Discussion:", value="[Forums](https://forum.redtea.red)", inline=True)
90+
embed.add_field(name="Links",
91+
value="[Support Discord](https://discord.gg/7BRGs6F) | [Add bot to server](https://discordapp.com/oauth2/authorize?client_id=669880564270104586&permissions=8&scope=bot) | [Repository](https://github.com/RedCokeDevelopment/Teapot.py)",
92+
inline=False)
6493
embed.set_footer(text=f"{teapot.copyright()} | Code licensed under the MIT License")
6594
embed.set_image(
6695
url="https://user-images.githubusercontent.com/43201383/72987537-89830a80-3e25-11ea-95ef-ecfa0afcff7e.png")
@@ -73,10 +102,10 @@ async def ping(ctx):
73102
await ctx.send(f'Pong! {round(bot.latency * 1000)} ms')
74103

75104

76-
def purge(bot):
77-
@bot.command(aliases=['clear', 'cls'])
105+
def prune(bot):
106+
@bot.command(aliases=['purge', 'clear', 'cls'])
78107
@cmd.has_permissions(kick_members=True)
79-
async def purge(ctx, amount=0):
108+
async def prune(ctx, amount=0):
80109
if amount == 0:
81110
await ctx.send("Please specify the number of messages you want to delete!")
82111
else:

teapot/cogs/github.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99

1010

1111
class GitHub(commands.Cog):
12+
"""Get repository info"""
1213

1314
def __init__(self, bot):
1415
self.bot = bot
1516

1617
@commands.command(pass_context=True, aliases=['gh'])
1718
async def github(self, ctx, arg):
19+
"""Fetch repository info"""
1820
req = requests.get(f'https://api.github.com/repos/{arg}')
1921
apijson = json.loads(req.text)
2022
if req.status_code == 200:
@@ -48,9 +50,9 @@ async def github(self, ctx, arg):
4850

4951
await ctx.send(embed=em)
5052
elif req.status_code == 404:
51-
ctx.send(embed=teapot.messages.notfound("repository"))
53+
await ctx.send(embed=teapot.messages.notfound("repository"))
5254
else:
53-
ctx.send(embed=teapot.messages.error("repository"))
55+
await ctx.send(embed=teapot.messages.error("repository"))
5456

5557

5658
def setup(bot):

teapot/cogs/music.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212

1313
class Music(commands.Cog):
14+
"""Music Time"""
15+
1416
def __init__(self, bot):
1517
self.bot = bot
1618

teapot/cogs/neko.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Module for generating a random cat picture"""
1+
""" Module for generating random neko pictures"""
22
import io
33
import json
44

@@ -12,10 +12,10 @@
1212

1313

1414
class Neko(commands.Cog):
15-
""" Cat Module"""
15+
"""Neko!!! :3"""
1616

1717
def __init__(self, bot):
18-
""" Initialize Cat Class"""
18+
""" Initialize neko class"""
1919

2020
self.bot = bot
2121

@@ -51,10 +51,6 @@ async def wallpaper(self, ctx):
5151
async def tickle(self, ctx):
5252
await ctx.send(embed=self.neko_api(ctx, "tickle"))
5353

54-
@commands.command(pass_context=True)
55-
async def ngif(self, ctx):
56-
await ctx.send(embed=self.neko_api(ctx, "ngif"))
57-
5854
@commands.command(pass_context=True)
5955
async def poke(self, ctx):
6056
await ctx.send(embed=self.neko_api(ctx, "poke"))
@@ -90,7 +86,7 @@ async def gox_girl(self, ctx):
9086
@commands.command(pass_context=True)
9187
async def hentai(self, ctx, type=""):
9288
if ctx.message.channel.nsfw:
93-
api_types = ['femdom', 'classic', 'erofeet', 'erok', 'les',
89+
api_types = ['femdom', 'classic', 'ngif', 'erofeet', 'erok', 'les',
9490
'hololewd', 'lewdk', 'keta', 'feetg', 'nsfw_neko_gif', 'eroyuri',
9591
'tits', 'pussy_jpg', 'cum_jpg', 'pussy', 'lewdkemo', 'lewd', 'cum', 'spank',
9692
'smallboobs', 'Random_hentai_gif', 'nsfw_avatar', 'hug', 'gecg', 'boobs', 'pat',

0 commit comments

Comments
 (0)