Skip to content

Commit 0fc2ee8

Browse files
author
RedTea
authored
Merge pull request #1 from RedCokeDevelopment/master
Updated Upstream
2 parents a915cc4 + f1c6f3d commit 0fc2ee8

File tree

16 files changed

+280
-86
lines changed

16 files changed

+280
-86
lines changed

.github/workflows/python-app.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Teapot.py
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
pull_request:
11+
branches:
12+
- master
13+
- dev
14+
15+
16+
jobs:
17+
build:
18+
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Set up Python 3.8
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: 3.8
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install flake8 pytest
31+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
32+
- name: Lint with flake8
33+
run: |
34+
# stop the build if there are Python syntax errors or undefined names
35+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
36+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
37+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38+
- name: Test with pytest
39+
run: |
40+
pytest

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
![banner](https://user-images.githubusercontent.com/43201383/72987537-89830a80-3e25-11ea-95ef-ecfa0afcff7e.png)
22

33
<p align="center">
4-
<a href="https://github.com/RedCokeDevelopment/Teapot.py/blob/dev/LICENSE"><img src="https://img.shields.io/github/license/redcokedevelopment/teapot.py.svg?style=flat-square" alt="GitHub License"></a>
4+
<a href="https://github.com/RedCokeDevelopment/Teapot.py/blob/master/LICENSE"><img src="https://img.shields.io/github/license/redcokedevelopment/teapot.py.svg?style=flat-square" alt="GitHub License"></a>
55
<a href="https://github.com/RedCokeDevelopment/Teapot.py/issues"><img src="https://img.shields.io/github/issues/redcokedevelopment/teapot.py.svg?color=purple&style=flat-square" alt="GitHub Issues"></a>
66
<a href="https://github.com/RedCokeDevelopment/Teapot.py/pulls"><img src="https://img.shields.io/github/issues-pr/redcokedevelopment/teapot.py.svg?color=purple&style=flat-square" alt="GitHub Pull Requests"></a>
77
<a href="https://github.com/RedCokeDevelopment/Teapot.py/stargazers"><img src="https://img.shields.io/github/stars/redcokedevelopment/teapot.py.svg?style=flat-square" alt="GitHub Stars"></a>
8+
<img src="https://github.com/RedCokeDevelopment/Teapot.py/workflows/Teapot.py/badge.svg" alt="Teapot.py">
89
<br><br>
910
<a href="https://discord.gg/7BRGs6F"><img src="https://discordapp.com/api/guilds/667714189254459414/widget.png?style=banner3" alt="Discord Server"></a>
1011
</p>
@@ -13,13 +14,13 @@
1314
This project is currently in development!<br>
1415
</h2>
1516
<h4 align="center">
16-
If you would like to be notified when we commit, please watch this repository and join our Discord server.
17+
If you would like to be notified when we commit, please watch this repository and join our Discord server.
1718
</h4>
1819

1920

2021
## 👋 About
2122

22-
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!
23+
Teapot.py is an open-source Discord bot that aims to be as customizable as possible as well as providing essential tools for server administrators to run their Discord server!
2324

2425
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)!
2526

@@ -32,10 +33,10 @@ If you want to try it out by yourself, feel free to invite it to your Discord se
3233

3334
## 📖 Wiki
3435

35-
Our wiki is currently work in progreses, please check back later!
36+
Our wiki is currently work in progress, please check back later!
3637

3738
## 🤝 Contributing
38-
Contributions, feedback and bug reports are welcome! Feel free to check out our [issues page](https://github.com/RedCokeDevelopment/Teapot.py/issues) to find out what you could do!
39+
Contributions, feedback, and bug reports are welcome! Feel free to check out our [issues page](https://github.com/RedCokeDevelopment/Teapot.py/issues) to find out what you could do!
3940

4041
Before contributing, we recommend you say hi over in our [Discord server](https://discord.gg/7BRGs6F)! We can provide support with any issues you may have 🙂
4142

@@ -50,10 +51,10 @@ There are two owners for this project. They all contribute massively to the runn
5051
## 📜 Requirements
5152
These are the requirements for the bot, and they will be bundled in future releases.
5253

53-
- [Python 3.7](https://www.python.org/downloads/release/python-376/) (Required packages listed in requirements.txt)
54+
- [Python 3.8](https://www.python.org/downloads/release/python-382/) (Required packages listed in requirements.txt)
5455
- [LavaLink Server](https://github.com/Frederikam/Lavalink) (Java 11 required)
5556

5657
## 💛 Credits
5758
The projects listed in below have provided inspiration, and we thought we'd mention them:
5859

59-
- LavaLink: https://github.com/Frederikam/Lavalink
60+
- LavaLink: https://github.com/Frederikam/Lavalink

Teapot.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,32 @@
3535
if not versionlisted:
3636
print("You are currently using an unlisted version!\n")
3737
elif req.status_code == 404:
38-
print("Unable to fetch the latest Teapot.py version from GitHub!\n")
38+
# 404 Not Found
39+
print("Latest Teapot.py version not found!\n")
40+
elif req.status_code == 500:
41+
# 500 Internal Server Error
42+
print("An error occurred while fetching the latest Teapot.py version. [500 Internal Server Error]\n")
43+
elif req.status_code == 502:
44+
# 502 Bad Gateway
45+
print("An error occurred while fetching the latest Teapot.py version. [502 Bad Gateway]\n")
46+
elif req.status_code == 503:
47+
# 503 Service Unavailable
48+
print("An error occurred while fetching the latest Teapot.py version. [503 Service Unavailable]\n")
3949
else:
40-
print("An unknown error has occurred when fetching the latest version of Teapot.py\n")
50+
print("An unknown error has occurred when fetching the latest Teapot.py version\n")
51+
print("HTML Error Code:" + str(req.status_code))
4152

4253
load_dotenv(join(dirname(__file__), '.env'))
4354

4455
if os.getenv('CONFIG_VERSION') != teapot.config_version():
4556
if os.path.isfile('.env'):
46-
print("Missing environment variables. Please delete .env and run Teapot.py again.")
47-
quit()
48-
print("Unable to find required environment variables. Running setup.py...")
49-
teapot.setup.__init__()
57+
print("Missing environment variables. Please backup and delete .env, then run Teapot.py again.")
58+
quit(2)
59+
print("Unable to find required environment variables. Running setup.py...") # if .env not found
60+
teapot.setup.__init__() # run setup.py
5061

5162
print("Initializing bot...")
52-
if teapot.config.storage_type() == "mysql":
63+
if teapot.config.storage_type() == "mysql": # if .env use mysql, create the table if table not exists
5364
time_start = time.perf_counter()
5465
database = teapot.managers.database.__init__()
5566
db = teapot.managers.database.db(database)
@@ -72,8 +83,10 @@
7283
(teapot.time(), "BOT_START", __name__, "Initialized bot"))
7384
database.commit()
7485

75-
bot = dcmd.Bot(command_prefix=teapot.config.bot_prefix())
76-
86+
intents = discord.Intents.default()
87+
intents.members = True
88+
intents.typing = False
89+
bot = dcmd.Bot(intents=intents, command_prefix=teapot.config.bot_prefix())
7790

7891
@bot.event
7992
async def on_ready():
@@ -90,17 +103,19 @@ async def on_ready():
90103
for guild in bot.guilds:
91104
teapot.managers.database.create_guild_table(guild)
92105
elif teapot.config.storage_type() == "sqlite":
93-
print("[!] SQLite storage has not been implemented yet. MySQL database is recommended")
106+
print("[!] Warning: SQLite storage has not been implemented yet. MySQL is recommended") # WIP
94107
print(f"Registered commands and events in {round(time.perf_counter() - time_start, 2)}s")
95-
await bot.change_presence(status=discord.Status.online, activity=discord.Game(teapot.config.bot_status()))
96-
108+
await bot.change_presence(status=discord.Status.online,
109+
activity=discord.Game(teapot.config.bot_status())) # Update Bot status
97110

98111

99112
try:
100113
discord_time_start = time.perf_counter()
101114
bot.run(teapot.config.bot_token())
102115
except Exception as e:
103-
print(f"[/!\\] Failed to connect to DiscordAPI. Please check your bot token!\n{e}")
116+
print(f"[/!\\] Error: Failed to connect to DiscordAPI. Please check your bot token!\n{e}")
104117
if teapot.config.storage_type() == "mysql":
105118
db.execute("INSERT INTO `bot_logs`(timestamp, type, class, message) VALUES(%s, %s, %s, %s)",
106119
(teapot.time(), "ERROR", __name__, e))
120+
time.sleep(5)
121+
exit(1)

requirements.txt

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
aiohttp==3.6.2
2-
async-timeout==3.0.1
3-
attrs==19.3.0
4-
beautifulsoup4==4.8.2
5-
bs4==0.0.1
6-
certifi==2019.11.28
7-
chardet==3.0.4
8-
discord.py==1.3.0
9-
idna==2.8
10-
lavalink==3.0.0
11-
multidict==4.7.4
12-
mysql-connector==2.2.9
13-
python-dotenv==0.10.5
14-
requests==2.22.0
15-
soupsieve==1.9.5
16-
urllib3==1.25.8
17-
websockets==6.0
18-
yarl==1.4.2
1+
aiohttp>=3.6.2
2+
async-timeout>=3.0.1
3+
attrs>=19.3.0
4+
beautifulsoup4>=4.9.1
5+
bs4>=0.0.1
6+
certifi>=2020.6.20
7+
chardet>=3.0.4
8+
discord.py>=1.5.1
9+
idna>=2.10
10+
lavalink>=3.1.2
11+
multidict>=4.7.6
12+
mysql-connector>=2.2.9
13+
psutil>=5.7.2
14+
python-dotenv>=0.14.0
15+
requests>=2.24.0
16+
soupsieve>=2.0.1
17+
typing-extensions>=3.7.4.2
18+
urllib3>=1.25.10
19+
websockets>=8.1
20+
yarl>=1.5.1
21+
mysql-connector-python>=8.0.21

teapot/__init__.py

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

99

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

1313

1414
def config_version():
15-
return "0.1"
15+
return "0.1" # do not edit this!
1616

1717

1818
def time():

teapot/cogs/cat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,30 @@ async def cat(self, ctx):
2121
""" Get a cat image """
2222
req = requests.get('https://api.thecatapi.com/v1/images/search')
2323
if req.status_code != 200:
24+
await ctx.message.add_reaction(emoji='❌')
25+
await ctx.send("API error, could not get a meow")
2426
print("Could not get a meow")
2527
catlink = json.loads(req.text)[0]
2628
rngcat = catlink["url"]
2729
em = dmbd.newembed()
2830
em.set_image(url=rngcat)
2931
await ctx.send(embed=em)
32+
await ctx.message.add_reaction(emoji='✅')
3033

3134
@commands.command(pass_context=True, aliases=['woof'])
3235
async def dog(self, ctx):
3336
""" Get a dog image """
3437
req = requests.get('http://random.dog/')
3538
if req.status_code != 200:
39+
await ctx.message.add_reaction(emoji='❌')
40+
await ctx.send("API error, could not get a woof")
3641
print("Could not get a woof")
3742
doglink = BeautifulSoup(req.text, 'html.parser')
3843
rngdog = 'http://random.dog/' + doglink.img['src']
3944
em = dmbd.newembed()
4045
em.set_image(url=rngdog)
4146
await ctx.send(embed=em)
47+
await ctx.message.add_reaction(emoji='✅')
4248

4349

4450
def setup(bot):

0 commit comments

Comments
 (0)