From 9b2063b8875ba424ce5d5080d51fd0844bf2d816 Mon Sep 17 00:00:00 2001 From: Bobloy Date: Fri, 2 Feb 2018 15:08:46 -0500 Subject: [PATCH] Stucture updates --- README.md | 14 +- fox/fox.py | 81 -------- fox/info.json | 9 - test/info.json | 9 - test/test.py | 52 ----- timezone/info.json | 9 - timezone/timezone.py | 478 ------------------------------------------- 7 files changed, 8 insertions(+), 644 deletions(-) delete mode 100644 fox/fox.py delete mode 100644 fox/info.json delete mode 100644 test/info.json delete mode 100644 test/test.py delete mode 100644 timezone/info.json delete mode 100644 timezone/timezone.py diff --git a/README.md b/README.md index 2eb87b1..85ac553 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,17 @@ -# Fox-Cogs +# Fox-V3 Cog Status - ccrole: **Incomplete** - - fight: **Abandoned** for RED v3 alternative, see Fox-V3 + - challonge: **Incomplete** - Challonge integration with discord + - fight: **Incomplete** Still in-progress, a massive project - fixjoin: **Failed** - Proof of concept failed, this does not work - flag: **Working**, may continue development - fox: **Abandoned** Original cog, never completed - - hangman: **Finished!** Will address issues - - immortal: **Private** Designed for a specific server, not recommened to install - - leaver: **Finished!** Will address issues - - timezone: **Failed** - Proof of concept failed, this does not work \ No newline at end of file + - hangman: **Incomplete** v2 version is functional at [Fox-Cogs v2](https://github.com/bobloy/Fox-Cogs) + - immortal: **Private** Designed for a specific server, not recommended to install + - leaver: **Incomplete** Have not begun conversion yet + - reactrestrict: **Beta** - Removes reactions by role per channel + - stealemoji: **Beta** - Removes reactions by role per channel \ No newline at end of file diff --git a/fox/fox.py b/fox/fox.py deleted file mode 100644 index 119d99f..0000000 --- a/fox/fox.py +++ /dev/null @@ -1,81 +0,0 @@ -import discord -import os -from discord.ext import commands - -from .utils.dataIO import dataIO -from .utils import checks - -class Fox: - """My custom cog that does stuff!""" - - def __init__(self, bot): - self.bot = bot - - @commands.group(pass_context=True) - async def fox(self, ctx): - """This does stuff!""" - - #Your code will go here - if ctx.invoked_subcommand is None: - await self.bot.send_cmd_help(ctx) - #await self.bot.say("I can do stuff!") - - - @fox.command(name="punch") - async def fox_punch(self, user : discord.Member): - """I will puch anyone! >.<""" - #Your code will go here - await self.bot.say("ONE PUNCH! And " + user.mention + " is out! ლ(ಠ益ಠლ)") - - @fox.command(name="lowtrophy") - async def fox_lowtrophy(self): - """Prints low trophy users for all registered clans""" - await self.bot.say("Todo") - - @fox.command(name="gettrophy") - async def fox_gettrophy(self): - """Gets fresh data from Clashstat""" - await self.bot.say("Todo") - - @fox.command(name="addclan") - async def fox_addclan(self, ctag, ckind = "Unranked", irank = 0): - """Adds clan to grab-list""" - await self.bot.say("Todo") - - @fox.command(name="removeclan") - async def fox_removeclan(self, ctag): - """Removes clan from future data grabs""" - await self.bot.say("Todo") - - async def _getclanstats(self): - await self.bot.say("Getclanstats Todo") - - async def _gettrophy(self): - await self.bot.say("Gettrophy Todo") - - async def _parseclanstats(self): - await self.bot.say("Parseclanstats Todo") - - async def _parsedate(self): - await self.bot.say("Parsedate Todo") - - async def _parsemember(self): - await self.bot.say("Parsemember Todo") - -def check_folders(): - if not os.path.exists("data/Fox-Cogs"): - print("Creating data/Fox-Cogs folder...") - os.makedirs("data/Fox-Cogs") - - if not os.path.exists("data/Fox-Cogs/fox"): - print("Creating data/Fox-Cogs/fox folder...") - os.makedirs("data/Fox-Cogs/fox") - - -def check_files(): - if not dataIO.is_valid_json("data/Fox-Cogs/fox/fox.json"): - dataIO.save_json("data/Fox-Cogs/fox/fox.json" ,{}) - - -def setup(bot): - bot.add_cog(Fox(bot)) diff --git a/fox/info.json b/fox/info.json deleted file mode 100644 index cf959c3..0000000 --- a/fox/info.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "AUTHOR" : "Bobloy", - "INSTALL_MSG" : "Thank you for installing fox. This is a beta program for interacting with fox.exe", - "NAME" : "Fox", - "SHORT" : "Cog to interact with Fox", - "DESCRIPTION" : "Cog to interact with Fox", - "TAGS" : ["fox", "bobloy"], - "HIDDEN" : false -} \ No newline at end of file diff --git a/test/info.json b/test/info.json deleted file mode 100644 index e284bf2..0000000 --- a/test/info.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "AUTHOR" : "Bobloy", - "INSTALL_MSG" : "Thank you for installing test cog. Please uninstall this now", - "NAME" : "Test", - "SHORT" : "Test short", - "DESCRIPTION" : "Test description is longer", - "TAGS" : ["fox", "bobloy"], - "HIDDEN" : false -} \ No newline at end of file diff --git a/test/test.py b/test/test.py deleted file mode 100644 index b1ab775..0000000 --- a/test/test.py +++ /dev/null @@ -1,52 +0,0 @@ -import discord -import os -from datetime import datetime -from discord.ext import commands - -from .utils.dataIO import dataIO -from .utils import checks - -class Test: - def __init__(self, bot): - self.bot = bot - self.path = "data/Fox-Cogs/test" - self.file_path = "data/Fox-Cogs/test/test.json" - self.the_data = dataIO.load_json(self.file_path) - - def save_data(self): - dataIO.save_json(self.file_path, self.the_data) - - @commands.command() - async def test(self): - self.the_data["WOAH"] = True - #self.the_data["WOAH"]["knarly"] = "Biiiiiitch" - if "Yeah dude" not in self.the_data: - self.the_data["Yeah dude"]={} - self.the_data["Yeah dude"]["knarly"]= {"ur lyin" : True, - "kick-ass" : { "no way!!!" : "Biiiiiitch" }, - "created_at" : datetime.now().strftime("%Y-%m-%d %H:%M:%S") - } - - #self.the_data["Yeah dude"]["knarly"] = "ur lyin" - #self.the_data["Yeah dude"]["knarly"]["kick-ass"]["no way!!!"] = "Biiiiiitch" - self.save_data() - - -def check_folders(): - if not os.path.exists("data/Fox-Cogs"): - print("Creating data/Fox-Cogs folder...") - os.makedirs("data/Fox-Cogs") - - if not os.path.exists("data/Fox-Cogs/test"): - print("Creating data/Fox-Cogs/test folder...") - os.makedirs("data/Fox-Cogs/test") - - -def check_files(): - if not dataIO.is_valid_json("data/Fox-Cogs/test/test.json"): - dataIO.save_json("data/Fox-Cogs/test/test.json" ,{}) - -def setup(bot): - check_folders() - check_files() - bot.add_cog(Test(bot)) diff --git a/timezone/info.json b/timezone/info.json deleted file mode 100644 index cc53094..0000000 --- a/timezone/info.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "AUTHOR" : "Bobloy", - "INSTALL_MSG" : "Thank you for installing Timezone. Run with [p]tz or [p]tzset", - "NAME" : "Timezone", - "SHORT" : "[Incomplete] Cog to check timezones", - "DESCRIPTION" : "[Incomplete] Cog to compare times with other users", - "TAGS" : ["tool", "tools", "utilities", "utility", "time", "convert", "timezone", "fox", "bobloy"], - "HIDDEN" : false -} \ No newline at end of file diff --git a/timezone/timezone.py b/timezone/timezone.py deleted file mode 100644 index c192b4b..0000000 --- a/timezone/timezone.py +++ /dev/null @@ -1,478 +0,0 @@ -import discord -import os -import math -from discord.ext import commands - -from .utils.dataIO import dataIO -from .utils import checks -from random import randint - - -class Timezone: - """Cog for organizing fights""" - - def __init__(self, bot): - self.bot = bot - self.path = "data/Fox-Cogs/fight/" - self.file_path = "data/Fox-Cogs/fight/fight.json" - self.the_data = dataIO.load_json(self.file_path) - - def save_data(self): - """Saves the json""" - dataIO.save_json(self.file_path, self.the_data) - - -# ************************Fight command group start************************ - @commands.group(pass_context=True, no_pm=True) - async def fight(self, ctx): - """Participate in active fights!""" - server = ctx.message.server - - if not self._activefight(server.id): - await self.bot.say("No tournament currently running!") - else: - await self.bot.say("Current tournament ID: " + self.the_data[server.id]["CURRENT"]) - - if ctx.invoked_subcommand is None: - await self.bot.send_cmd_help(ctx) - # await self.bot.say("I can do stuff!") - - @fight.command(name="join", pass_context=True) - async def fight_join(self, ctx, user: discord.Member=None): - """Join the active fight""" - server = ctx.message.server - if not user: - user = ctx.message.author - - currFight = self._getcurrentfight(server.id) - currID = self._activefight(server.id) - if not currFight: - await self.bot.say("No tournament currently running!") - return - - if not currFight["OPEN"]: - await self.bot.say("Tournament currently not accepting new players") - return - - if self._infight(user.id, server.id, currID): - await self.bot.say("You are already in this tournament!") - return - - currFight["PLAYERS"].append(user.id) - - await self.bot.say("User has been added to tournament") - - @fight.command(name="score", pass_context=True) - async def fight_score(self, ctx, gameID): - """Enters score for current match, or for passed game ID""" - if gameID is None: - if ctx.message.author not in currFight["PLAYERS"]: - await self.bot.say("You are not in a current tournament") - - await self.bot.say("Todo Score") - - @fight.command(name="leave", pass_context=True) - async def fight_leave(self, ctx): - """Forfeit your match and all future matches""" - await self.bot.say("Todo Leave") - -# @fight.command(name="leaderboard", pass_context=True) -# async def fight_leaderboard(self, ctx, ctag, ckind="Unranked", irank=0): -# """Adds clan to grab-list""" -# await self.bot.say("Todo Leaderboard") - - @fight.group(name="bracket", pass_context=True) - async def fight_bracket(self, ctx, ctag): - """Shows your current match your next opponent, - run [p]fight bracket full to see all matches""" - await self.bot.say("Todo Bracket") - - # Your code will go here - if ctx.invoked_subcommand is None: - await self.bot.send_cmd_help(ctx) - # await self.bot.say("I can do stuff!") - - @fight_bracket.command(name="full") - async def fight_bracket_full(self, ctag): - """Shows the full bracket""" - await self.bot.say("Todo Bracket Full") - -# **********************Fightset command group start********************* -# def fightsetdec(func): -# async def decorated(self, ctx, *args, **kwargs): -# server = ctx.message.server -# await func(self, ctx, server, *args, **kwargs) -# return decorated - - @commands.group(pass_context=True, no_pm=True, aliases=['setfight']) - @checks.mod_or_permissions(administrator=True) - async def fightset(self, ctx): - """Admin command for starting or managing tournaments""" - server = ctx.message.server - - if server.id not in self.the_data: - self.the_data[server.id] = { - "CURRENT": None, - "TOURNEYS": {} - } - self.save_data() - - if ctx.invoked_subcommand is None: - await self.bot.send_cmd_help(ctx) - # await self.bot.say("I can do stuff!") - - @fightset.command(name="bestof", pass_context=True) - async def fightset_bestof(self, ctx, incount, tID=None): - """Adjust # of games played per match. Must be an odd number""" - server = ctx.message.server - if not tID and not self._activefight(server.id): - await self.bot.say("No active fight to adjust") - return - - if not tID: - tID = self._activefight(server.id) - - try: - num = int(incount) - except: - await self.bot.say("That is not a number") - return - - if num % 2 != 1: - await self.bot.say("Must be an odd number") - return - - if num < 1: - await self.bot.say("Must be greater than 0, idiot") - return - - self._getfight(server.id, tID)["RULES"]["BESTOF"] = num - self.save_data() - await self.bot.say("Tourney ID "+tID+" is now Best of "+str(num)) - - @fightset.command(name="bestoffinal", pass_context=True) - async def fightset_bestoffinal(self, ctx, incount, tID=None): - """Adjust # of games played in finals. Must be an odd number - (Does not apply to tournament types without finals, such as Round Robin)""" - server = ctx.message.server - if not tID and not self._activefight(server.id): - await self.bot.say("No active fight to adjust") - return - - if not tID: - tID = self._activefight(server.id) - - try: - num = int(incount) - except: - await self.bot.say("That is not a number") - return - - if num % 2 != 1: - await self.bot.say("Must be an odd number") - return - - if num < 1: - await self.bot.say("Must be greater than 0, idiot") - return - - self._getfight(server.id, tID)["RULES"]["BESTOFFINAL"] = num - self.save_data() - await self.bot.say("Tourney ID "+tID+" is now Best of "+str(num)) - - @fightset.command(name="current", pass_context=True) - async def fightset_current(self, ctx, tID): - """Sets the current tournament to passed ID""" - server = ctx.message.server - try: - aFight = self.the_data[server.id]["TOURNEYS"][tID] - - except: - await self.bot.say("No tourney found with that ID") - - self.the_data[server.id]["CURRENT"] = tID - self.save_data() - - await self.bot.say("Current tournament set to "+tID) - - @fightset.command(name="list", pass_context=True) - async def fightset_list(self, ctx): - """Lists all current and past fights""" - server = ctx.message.server - - await self.bot.say(self.the_data[server.id]["TOURNEYS"]) - await self.bot.say("Done") - - @fightset.command(name="toggleopen", pass_context=True) - async def fightset_toggleopen(self, ctx): - """Toggles the open status of current tournament""" - server = ctx.message.server - if not self._activefight(server.id): - await self.bot.say("No active fight to adjust") - return - - currFight = self._getcurrentfight(server.id) - currFight["OPEN"] = not currFight["OPEN"] - - self.save_data() - - await self.bot.say("Tournament Open status is now set to: " + str(currFight["OPEN"])) - - @fightset.command(name="setup", pass_context=True) - async def fightset_setup(self, ctx): - """Setup a new tournament! - Default settings are as follows - Name: Tourney # (counts from 0) - Best of: 1 - Best of (final): 1 - Self Report: True - Type: 0 (Round Robin)""" - server = ctx.message.server - currServ = self.the_data[server.id] - tourID = str(len(currServ["TOURNEYS"])) # Can just be len without +1, tourney 0 makes len 1, tourney 1 makes len 2, etc - currServ["CURRENT"] = tourID - currServ["TOURNEYS"][tourID] = { - "PLAYERS": [], - "NAME": "Tourney "+str(tourID), - "RULES": {"BESTOF": 1, "BESTOFFINAL": 1, "SELFREPORT": True, "TYPE": 0}, - "TYPEDATA": {}, - "OPEN": False, - "WINNER": None - } - - self.save_data() - - await self.bot.say("Tournament has been created!\n\n" + str(currServ["TOURNEYS"][tourID])) - - await self.bot.say("Adjust settings as necessary, then open the tournament with [p]fightset toggleopen") - - @fightset.command(name="stop", pass_context=True) - async def fightset_stop(self, ctx): - """Stops current tournament""" - server = ctx.message.server - if not self._activefight(server.id): - await self.bot.say("No active fight to adjust") - return - - author = ctx.message.author - currServ = self.the_data[server.id] - - await self.bot.say("Current fight ID is "+str(currServ["CURRENT"])+"\nOkay to stop? (yes/no)") - - answer = await self.bot.wait_for_message(timeout=120, author=author) - - if not answer.content.upper() in ["YES", "Y"]: - await self.bot.say("Cancelled") - return - - currServ["CURRENT"] = None - - self.save_data() - await self.bot.say("Fight has been stopped") - -# **********************Private command group start********************* - def _activefight(self, serverid): - """Returns id for active fight, or None if no active fight""" - return self.the_data[serverid]["CURRENT"] - - def _infight(self, userid, serverid, tID): - """Checks if passed member is already in the tournament""" - - return userid in self.the_data[serverid]["TOURNEYS"][tID]["PLAYERS"] - - async def _openregistration(self, serverid, tID): - """Checks if fight is accepting joins""" - await self.bot.say("_openregistration Todo") - - async def _comparescores(self): - """Checks user submitted scores for inconsistancies""" - await self.bot.say("_comparescores Todo") - - async def _parsemember(self): - await self.bot.say("Parsemember Todo") - - def _get_user_from_id(self, server, userid): - return discord.utils.get(server.members, id=userid) - - def _get_server_from_id(self, serverid): - return discord.utils.get(self.bot.servers, id=serverid) - - def _getfight(self, serverid, tID): - return self.the_data[serverid]["TOURNEYS"][tID] - - def _getcurrentfight(self, serverid): - if not self._activefight(serverid): - return None - - return self._getfight(serverid, self._activefight(serverid)) - -# **********************Single Elimination*************************** - async def _elim_setup(self, tID): - await self.bot.say("Elim setup todo") - - async def _elim_start(self, tID): - await self.bot.say("Elim start todo") - - async def _elim_update(self, matchID, ): - await self.bot.say("Elim update todo") - - -# **********************Round-Robin********************************** - def _rr_setup(self, serverid, tID): - - theT = self.the_data[serverid]["TOURNEYS"][tID] - theD = theT["TYPEDATA"] - - get_schedule = self._rr_schedule(theT["PLAYERS"]) - - theD = {"SCHEDULE": get_schedule[0], "MATCHES": get_schedule[1], "ROUND": 0} - - self.save_data() - - async def _rr_printround(self, serverid, tID, rID): - - theT = self.the_data[serverid]["TOURNEYS"][tID] - theD = theT["TYPEDATA"] - - await self.bot.say("Round "+str(rID)) - - for match in theD["SCHEDULE"][rID]: - await self.bot.say(theD["MATCHES"][match]["TEAM1"] + " vs " + theD["MATCHES"][match]["TEAM2"] + " || Match ID: " + match) - - async def _rr_start(self, serverid, tID): - - self._rr_setup(serverid, tID) - - await self.bot.say("**Tournament is Starting**") - - await self._rr_printround(tID) - - async def _rr_update(self, serverid, tID=None, mID=None, t1points=None, t2points=None): - - theT = self.the_data[serverid]["TOURNEYS"][tID] - theD = theT["TYPEDATA"] - - if t1points and t2points: - theD["MATCHES"][mID]["TEAM1"] = t1points - theD["MATCHES"][mID]["TEAM2"] = t2points - self.save_data() - return - - await self.bot.say("Entering scores for match ID: " + mID + "\n\n") - await self.bot.say("How many points did " + theD["MATCHES"][mID]["TEAM1"] + " get?") - answer = await self.bot.wait_for_message(timeout=120, author=author) - try: - t1points = int(answer.content) - except: - await self.bot.say("That's not a number!") - return - - await self.bot.say("How many points did " + theD["MATCHES"][mID]["TEAM2"] + " get?") - answer = await self.bot.wait_for_message(timeout=120, author=author) - try: - t2points = int(answer.content) - except: - await self.bot.say("That's not a number!") - return - - if t1points == math.ceil(theD["RULES"]["BESTOF"]/2) or t2points == math.ceil(theD["RULES"]["BESTOF"]/2): - theD["MATCHES"][mID]["TEAM1"] = t1points - theD["MATCHES"][mID]["TEAM2"] = t2points - self.save_data() - return - else: - await self.bot.say("Invalid scores, nothing will be updated") - return - - def _rr_schedule(inlist): - """ Create a schedule for the teams in the list and return it""" - s = [] # Schedule list - outID = {} # Matches - - firstID = ["A", "B", "C", "D", "E", "F", - "G", "H", "I", "J", "K", "L", - "M", "N", "O", "P", "Q", "R", - "S", "T", "U", "V", "W", "X", - "Y", "Z"] # God dammit this could've been a string - - if len(inlist) % 2 == 1: - inlist = inlist + ["BYE"] - - for i in range(len(inlist)-1): - - mid = int(len(inlist) / 2) - l1 = inlist[:mid] - l2 = inlist[mid:] - l2.reverse() - - matchLetter = "" - j = i - while j+1 > 26: - - matchLetter += firstID[int(j + 1) % 26 - 1] - - j = (j + 1) / 26 - 1 - matchLetter += firstID[int(j+1) % 26-1] - matchLetter = matchLetter[::-1] - - matchID = [] - for ix in range(len(l1)-1): - matchID += [matchLetter+str(ix)] - - rPlayers = list(zip(l1, l2)) - TeamCnt = 0 - for ID in matchID: - outID[ID] = { - "TEAM1": rPlayers[TeamCnt][0], - "TEAM2": rPlayers[TeamCnt][1], - "SCORE1": 0, - "SCORE2": 0, - "USERSCORE1": {"SCORE1": 0, "SCORE2": 0}, - "USERSCORE2": {"SCORE1": 0, "SCORE2": 0} - } - - TeamCnt += 1 - - # List of match ID's is now done - - s += [matchID] # Schedule of matches - inlist.insert(1, inlist.pop()) - - outlist = [[], {}] - outlist[0] = s - outlist[1] = outID - # outlist[0] is list schedule of matches - # outlist[1] is dict data of matches - - return outlist - - def _rr_nextround(self, serverid, tID): - currFight = self._getfight(serverid, tID) - currRound = currFight["TYPEDATA"]["SCHEDULE"][currFight["TYPEDATA"]["ROUND"]] - - for match in currRound: - if (currFight["TYPEDATA"]["MATCHES"][match]["SCORE1"] > currFight["RULES"]["BESTOF"]/2 or - currFight["TYPEDATA"]["MATCHES"][match]["SCORE2"] > currFight["RULES"]["BESTOF"]/2): - return False - return True - - -def check_folders(): - if not os.path.exists("data/Fox-Cogs"): - print("Creating data/Fox-Cogs folder...") - os.makedirs("data/Fox-Cogs") - - if not os.path.exists("data/Fox-Cogs/fight"): - print("Creating data/Fox-Cogs/fight folder...") - os.makedirs("data/Fox-Cogs/fight") - - -def check_files(): - if not dataIO.is_valid_json("data/Fox-Cogs/fight/fight.json"): - dataIO.save_json("data/Fox-Cogs/fight/fight.json", {}) - - -def setup(bot): - check_folders() - check_files() - bot.add_cog(Fight(bot))