-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
5,573 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,25 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
bin/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
.venv | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.vscode/ | ||
meowth/config.py | ||
docs/ | ||
logs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
# Eevee | ||
# Eevee v2 - In Developement | ||
A Discord helper bot for Pokemon Go communities. | ||
|
||
Eevee is based on Meowth, and is a Pokemon Go community manager and coordinator bot for Discord servers, upholding the ideal to respect the Terms of Service of both the game and the associated accounts. | ||
|
||
It is written in Python 3.6.1 using the [discord.py v1.0.0a](https://github.com/Rapptz/discord.py/tree/rewrite) library. | ||
|
||
This version of Eevee is currently under heavy development and is not recommended for any type of actual usage. | ||
|
||
This update aims to meet the following goals: | ||
- [x] Compatible with [discord.py v1.0.0a](https://github.com/Rapptz/discord.py/tree/rewrite) | ||
- [x] Able to be installed as a pip package with dependancies auto-installing | ||
- [x] Redesign Meowth into a modular structure, with extension management | ||
- [x] Ability to update most of the codebase with no downtime or loss of data | ||
- [x] Able to perform all current features of Eevee v1 or excel beyond it | ||
|
||
## Proposed Structure: | ||
- Docs | ||
- Readme | ||
- Setup | ||
- Meowth | ||
- Core | ||
- Config | ||
- Data Management | ||
- Cogs | ||
- Server Greeting | ||
- Team Management | ||
- Wild Tracking | ||
- Raid Management | ||
- Gym Management |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/python3 | ||
"""Eevee - A Discord helper bot for Pokemon Go communities. | ||
Eevee is a Discord bot written in Python 3.6.1 using version 1.0.0a of the discord.py library. | ||
It assists with the organisation of local Pokemon Go Discord servers and their members.""" | ||
|
||
__version__ = "2.0.0a0" | ||
|
||
__author__ = "scragly" | ||
__credits__ = ["FoglyOgly"] | ||
__maintainer__ = "scragly" | ||
__status__ = "Development" | ||
|
||
from eevee.core.bot import command, group | ||
from eevee.core import checks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"""Eevee - A Discord Bot for Pokemon Go Communities""" | ||
|
||
import argparse | ||
import asyncio | ||
import sys | ||
|
||
import discord | ||
|
||
from eevee.core import bot, events | ||
from eevee.utils import ExitCodes, logger | ||
|
||
if discord.version_info.major < 1: | ||
print("You are not running discord.py v1.0.0a or above.\n\n" | ||
"Eevee v2 requires the new discord.py library to function " | ||
"correctly. Please install the correct version.") | ||
sys.exit(1) | ||
|
||
def run_eevee(debug=False, launcher=None): | ||
description = "Eevee v2 - Alpha" | ||
eevee = bot.Eevee(description=description) | ||
eevee.debug = debug | ||
eevee.logger = logger.init_logger(debug_flag=debug) | ||
events.init_events(eevee, launcher=launcher) | ||
eevee.load_extension('eevee.core.commands') | ||
eevee.load_extension('eevee.core.cog_manager') | ||
for ext in eevee.preload_ext: | ||
ext_name = ("eevee.cogs."+ext) | ||
eevee.load_extension(ext_name) | ||
loop = asyncio.get_event_loop() | ||
if eevee.token is None or not eevee.default_prefix: | ||
eevee.logger.critical("Token and prefix must be set in order to login.") | ||
sys.exit(1) | ||
try: | ||
loop.run_until_complete(eevee.start(eevee.token)) | ||
except discord.LoginFailure: | ||
eevee.logger.critical("Invalid token") | ||
loop.run_until_complete(eevee.logout()) | ||
eevee._shutdown_mode = ExitCodes.SHUTDOWN | ||
except KeyboardInterrupt: | ||
eevee.logger.info("Keyboard interrupt detected. Quitting...") | ||
loop.run_until_complete(eevee.logout()) | ||
eevee._shutdown_mode = ExitCodes.SHUTDOWN | ||
except Exception as e: | ||
eevee.logger.critical("Fatal exception", exc_info=e) | ||
loop.run_until_complete(eevee.logout()) | ||
finally: | ||
code = eevee._shutdown_mode | ||
sys.exit(code.value) | ||
|
||
def parse_cli_args(): | ||
parser = argparse.ArgumentParser( | ||
description="Eevee - Pokemon Go Bot for Discord") | ||
parser.add_argument( | ||
"--debug", "-d", help="Enabled debug mode.", action="store_true") | ||
parser.add_argument( | ||
"--launcher", "-l", help=argparse.SUPPRESS, action="store_true") | ||
return parser.parse_args() | ||
|
||
|
||
|
||
def main(): | ||
args = parse_cli_args() | ||
run_eevee(debug=args.debug, launcher=args.launcher) | ||
|
||
if __name__ == '__main__': | ||
main() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .teams import Teams | ||
|
||
def setup(bot): | ||
bot.add_cog(Teams(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import discord | ||
from discord.ext import commands | ||
|
||
class Teams: | ||
"""Team Management""" | ||
|
||
def __init__(self, bot): | ||
self.bot = bot | ||
|
||
def team_list(self): | ||
"""Returns a list of playable teams""" | ||
config = self.bot.config | ||
teams = config['teams']['team_list'] | ||
return teams | ||
|
||
@staticmethod | ||
def role_heirarchy_check(ctx: commands.Context, role: discord.Role): | ||
"""Checks if the bot has a higher role than the given one.""" | ||
return ctx.guild.me.top_role > role | ||
|
||
def get_team_role(self, guild: discord.Guild, team: str): | ||
"""Returns the guild role for a given team.""" | ||
return discord.utils.get(guild.roles, name=team) | ||
|
||
def get_team_roles(self, guild: discord.Guild): | ||
"""Returns a list of guild roles for all teams.""" | ||
teams = self.team_list() | ||
team_roles = [] | ||
for team in teams: | ||
team_role = self.get_team_role(guild, team) | ||
if team_role: | ||
team_roles.append(team_role) | ||
return team_roles | ||
|
||
def get_team_colour(self, team: str): | ||
"""Returns the teams colour as discord.Colour.""" | ||
colour_dict = self.bot.config['teams']['team_colours'] | ||
return discord.Colour(colour_dict[team]) | ||
|
||
def get_team_emoji(self, team: discord.Role): | ||
"""Returns the emoji representing the given team.""" | ||
emoji_dict = self.bot.config['teams']['team_emoji'] | ||
return emoji_dict[team.name] | ||
|
||
async def create_team_roles(self, guild: discord.Guild): | ||
"""Creates new team roles for the guild. | ||
By default, each team role is assigned their default colours as | ||
set in the config file, and are set to be shown seperately in | ||
the member list. | ||
""" | ||
teams = self.team_list() | ||
for team in teams: | ||
team_role = self.get_team_role(guild, team) | ||
if team_role is None: | ||
team_colour = self.get_team_colour(team) | ||
await guild.create_role( | ||
reason="Eevee Bot auto-created team roles.", | ||
name=team, colour=team_colour, hoist=True) | ||
|
||
@commands.command() | ||
async def team(self, ctx, team: str): | ||
"""Set your team role.""" | ||
guild = ctx.guild | ||
member = ctx.author | ||
team_roles = self.get_team_roles(guild) | ||
team_role = None | ||
|
||
if not team_roles: | ||
await ctx.send(_("Teams aren't setup for this server!")) | ||
return | ||
|
||
for role in team_roles: | ||
if role.name.lower() == team.lower(): | ||
team_role = role | ||
if role in member.roles: | ||
await ctx.send(_("You already have a team role!")) | ||
return | ||
|
||
if team_role is None: | ||
msg = _("I don't know of any team named **{}**!\n" | ||
"Try one of the following:").format(team) | ||
for role in team_roles: | ||
msg += "\n**{}**".format(role.name) | ||
await ctx.send(msg) | ||
return | ||
|
||
if not self.role_heirarchy_check(ctx, team_role): | ||
await ctx.send(_("There's an issue with this team role!\n" | ||
"Please get an admin to check that the team " | ||
"roles are below my highest role.")) | ||
|
||
try: | ||
await member.add_roles(team_role) | ||
team_emoji = self.get_team_emoji(team_role) | ||
await ctx.send(_( | ||
"Welcome to {team_name}, {member}! {team_emoji}" | ||
"").format(team_name=team_role.name.capitalize(), | ||
member=member.mention, | ||
team_emoji=team_emoji)) | ||
except discord.Forbidden: | ||
await ctx.send(_("I can't add roles!\n" | ||
"Please get an admin to check my permissions.")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .tests import Tests | ||
|
||
def setup(bot): | ||
bot.add_cog(Tests(bot)) |
Oops, something went wrong.