Skip to content

Commit 0f4dce2

Browse files
committed
Initial Commit
Signed-off-by: ColaIan <colaian.yt@gmail.com>
0 parents  commit 0f4dce2

22 files changed

+1445
-0
lines changed

.github/CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at support@redtea.red. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

.gitignore

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
db.sqlite3
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Environments
85+
.env
86+
.venv
87+
env/
88+
venv/
89+
ENV/
90+
env.bak/
91+
venv.bak/
92+
93+
# Spyder project settings
94+
.spyderproject
95+
.spyproject
96+
97+
# Rope project settings
98+
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
106+
# JetBrains Configurations
107+
.idea
108+
109+
# Config
110+
*.env

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 RedCoke Development
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
worker: python Teapot.py

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
![banner](https://user-images.githubusercontent.com/43201383/72987537-89830a80-3e25-11ea-95ef-ecfa0afcff7e.png)
2+
3+
<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>
5+
<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>
6+
<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>
7+
<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+
<br><br>
9+
<a href="https://discord.gg/7BRGs6F"><img src="https://discordapp.com/api/guilds/667714189254459414/widget.png?style=banner3" alt="Discord Server"></a>
10+
</p>
11+
12+
<h2 align="center">
13+
This project is currently in development!<br>
14+
</h2>
15+
<h4 align="center">
16+
If you would like to be notified when we commit, please watch this repository and join our Discord server.
17+
</h4>
18+
19+
20+
## 👋 About
21+
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+
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)!
25+
26+
## ⌨ Planned Features
27+
- Music Player
28+
- Moderation Tools
29+
- Localization
30+
- Storage Type Support
31+
32+
33+
## 📖 Wiki
34+
35+
Our wiki is currently work in progreses, please check back later!
36+
37+
## 🤝 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+
40+
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 🙂
41+
42+
A big thanks to all those who contribute to the project ❤
43+
44+
## 💼 Project Owners
45+
There are two owners for this project. They all contribute massively to the running of this project. Links to their GitHub profiles can be found below:
46+
47+
- [ColaIan](https://github.com/ColaIan) (ColaIan#2974)
48+
- [RedTea](https://github.com/RedTeaDev) (RedTea#0001)
49+
50+
## 📜 Requirements
51+
These are the requirements for the bot, and they will be bundled in future releases.
52+
53+
- [Python 3.7](https://www.python.org/downloads/release/python-376/) (Required packages listed in requirements.txt)
54+
- [LavaLink Server](https://github.com/Frederikam/Lavalink) (Java 11 required)
55+
56+
## 💛 Credits
57+
The projects listed in below have provided inspiration, and we thought we'd mention them:
58+
59+
- LavaLink: https://github.com/Frederikam/Lavalink

Teapot.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import os
2+
import time
3+
from os.path import join, dirname
4+
5+
import discord
6+
from discord.ext import commands as dcmd
7+
from dotenv import load_dotenv
8+
9+
import teapot
10+
11+
print("""
12+
_____ _
13+
|_ _|__ __ _ _ __ ___ | |_
14+
| |/ _ \/ _` | '_ \ / _ \| __|
15+
| | __/ (_| | |_) | (_) | |_
16+
|_|\___|\__,_| .__/ \___/ \__|
17+
by ColaIan |_| & RedTea
18+
""")
19+
20+
load_dotenv(join(dirname(__file__), '.env'))
21+
22+
if os.getenv('CONFIG_VERSION') != teapot.config_version():
23+
if os.path.isfile('.env'):
24+
print("Missing environment variables. Please delete .env and run Teapot.py again.")
25+
quit()
26+
print("Unable to find required environment variables. Running setup.py...")
27+
teapot.setup.__init__()
28+
29+
print("Initializing bot...")
30+
if teapot.config.storage_type() == "mysql":
31+
time_start = time.perf_counter()
32+
database = teapot.database.__init__()
33+
db = teapot.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")
38+
39+
bot = dcmd.Bot(command_prefix=teapot.config.bot_prefix())
40+
41+
42+
@bot.event
43+
async def on_ready():
44+
print(f"Connected to DiscordAPI in {round(time.perf_counter() - discord_time_start, 2)}s")
45+
time_start = time.perf_counter()
46+
teapot.events.__init__(bot)
47+
teapot.cogs.cmds.__init__(bot)
48+
teapot.cogs.music.setup(bot)
49+
teapot.cogs.osu.setup(bot)
50+
teapot.cogs.github.setup(bot)
51+
teapot.cogs.cat.setup(bot)
52+
teapot.cogs.neko.setup(bot)
53+
if teapot.config.storage_type() == "mysql":
54+
for guild in bot.guilds:
55+
db.execute("SELECT * FROM `guilds` WHERE guild_id = '" + str(guild.id) + "'")
56+
if db.rowcount == 0:
57+
db.execute("INSERT INTO `guilds`(guild_id, guild_name) VALUES(%s, %s)", (guild.id, guild.name))
58+
database.commit()
59+
db.execute("CREATE TABLE IF NOT EXISTS `" + str(
60+
guild.id) + "_logs" + "` (`timestamp` TEXT, `guild_id` BIGINT, `channel_id` BIGINT, `message_id` "
61+
"BIGINT, `user_id` BIGINT, `action_type` TINYTEXT, `message` MEDIUMTEXT)")
62+
elif teapot.config.storage_type() == "flatfile":
63+
print("[!] Flatfile storage has not been implemented yet. MySQL database is recommended")
64+
print(f"Registered commands and events in {round(time.perf_counter() - time_start, 2)}s")
65+
await bot.change_presence(status=discord.Status.online, activity=discord.Game(teapot.config.bot_status()))
66+
67+
68+
@bot.event
69+
async def on_message(message):
70+
guild = message.guild
71+
if teapot.config.storage_type() == "mysql":
72+
try:
73+
db.execute("SELECT * FROM `users` WHERE user_id = '" + str(message.author.id) + "'")
74+
if db.rowcount == 0:
75+
db.execute("INSERT INTO `users`(user_id, user_name, user_discriminator) VALUES(%s, %s, %s)",
76+
(message.author.id, message.author.name, message.author.discriminator.zfill(4)))
77+
database.commit()
78+
db.execute("SELECT * FROM `channels` WHERE channel_id = '" + str(message.channel.id) + "'")
79+
if db.rowcount == 0:
80+
db.execute("INSERT INTO `channels`(channel_id, channel_name) VALUES(%s, %s)",
81+
(message.channel.id, message.channel.name))
82+
database.commit()
83+
db.execute("INSERT INTO `" + str(
84+
guild.id) + "_logs" + "`(timestamp, guild_id, channel_id, message_id, user_id, action_type, message) VALUES(%s, %s, %s, %s, %s, %s, %s)",
85+
(teapot.time(), message.guild.id, message.channel.id, message.id, message.author.id,
86+
"MESSAGE_SEND", message.content))
87+
database.commit()
88+
except Exception as e:
89+
print(e)
90+
await bot.process_commands(message)
91+
92+
93+
try:
94+
discord_time_start = time.perf_counter()
95+
bot.run(teapot.config.bot_token())
96+
except Exception as e:
97+
print(e)
98+
print("[/!\] Failed to connect to DiscordAPI. Please check your bot token!")

requirements.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
aiohttp==3.5.4
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.2.5
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

0 commit comments

Comments
 (0)