Started refactoring for future use
This commit is contained in:
parent
712f64a03a
commit
5c2ff27656
6 changed files with 148 additions and 17 deletions
22
APICommands/ChampionMasteryCommand.py
Normal file
22
APICommands/ChampionMasteryCommand.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
from abc import ABC
|
||||
|
||||
import discord
|
||||
import riotwatcher
|
||||
|
||||
import APICommands.Command
|
||||
|
||||
|
||||
class ChampionMastery(APICommands.Command.Command, ABC):
|
||||
keywords = ["cm", "CM", "Championmastery", "championmastery"]
|
||||
|
||||
def __init__(self, pref, api: riotwatcher.LolWatcher, additionalKeywords: list):
|
||||
super().__init__(pref, api, additionalKeywords)
|
||||
|
||||
async def execute(self, message: discord.Message):
|
||||
pass
|
||||
|
||||
async def info(self, message: discord.Message):
|
||||
pass
|
||||
|
||||
async def usage(self, message: discord.Message):
|
||||
pass
|
||||
45
APICommands/Command.py
Normal file
45
APICommands/Command.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
from abc import abstractmethod, ABCMeta
|
||||
from datetime import datetime
|
||||
|
||||
import discord
|
||||
import riotwatcher
|
||||
|
||||
|
||||
class Command:
|
||||
__metaclass__ = ABCMeta
|
||||
keywords = []
|
||||
pref = ""
|
||||
api: riotwatcher.LolWatcher
|
||||
commandName = ""
|
||||
|
||||
def __init__(self, pref, api: riotwatcher.LolWatcher, addkeywords: list):
|
||||
for i in addkeywords:
|
||||
self.keywords.append(i)
|
||||
self.pref = pref
|
||||
self.api = api
|
||||
|
||||
@abstractmethod
|
||||
async def execute(self, message: discord.Message):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def info(self, message: discord.Message):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def usage(self, message: discord.Message):
|
||||
pass
|
||||
|
||||
def isCalled(self, message: discord.Message):
|
||||
for i in self.keywords:
|
||||
if message.content.startswith(self.pref + i):
|
||||
return True
|
||||
return False
|
||||
|
||||
def log(self, message: discord.Message):
|
||||
logMSG = (self.commandName + " request sent in Channel " + str(message.channel.name) + "\n\t- at: " + str(
|
||||
datetime.now())[:-7] + "\n\t- by: " + str(message.author) + "\n\t- content: '" + str(
|
||||
message.content) + "'\n")
|
||||
print(logMSG)
|
||||
with open("requests.log", "a") as f:
|
||||
f.write(logMSG)
|
||||
22
APICommands/HighestMasteryCommand.py
Normal file
22
APICommands/HighestMasteryCommand.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
from abc import ABC
|
||||
|
||||
import discord
|
||||
import riotwatcher
|
||||
|
||||
import APICommands.Command
|
||||
|
||||
|
||||
class HighestMastery(APICommands.Command.Command, ABC):
|
||||
keywords = ["highestmastery", "highestMastery", "HM", "hm", "Hm", "HighestMastery"]
|
||||
|
||||
def __init__(self, pref, api: riotwatcher.LolWatcher, additionalKeywords: list):
|
||||
super().__init__(pref, api, additionalKeywords)
|
||||
|
||||
async def execute(self, message: discord.Message):
|
||||
pass
|
||||
|
||||
async def info(self, message: discord.Message):
|
||||
pass
|
||||
|
||||
async def usage(self, message: discord.Message):
|
||||
pass
|
||||
22
APICommands/PrefixCommand.py
Normal file
22
APICommands/PrefixCommand.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
from abc import ABC
|
||||
|
||||
import discord
|
||||
import riotwatcher
|
||||
|
||||
import APICommands.Command
|
||||
|
||||
|
||||
class Prefix(APICommands.Command.Command, ABC):
|
||||
keywords = ["prefix"]
|
||||
|
||||
def __init__(self, pref, api: riotwatcher.LolWatcher, additionalKeywords: list):
|
||||
super().__init__(pref, api, additionalKeywords)
|
||||
|
||||
async def execute(self, message: discord.Message):
|
||||
pass
|
||||
|
||||
async def info(self, message: discord.Message):
|
||||
pass
|
||||
|
||||
async def usage(self, message: discord.Message):
|
||||
pass
|
||||
22
APICommands/SummonerLevelCommand.py
Normal file
22
APICommands/SummonerLevelCommand.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
from abc import ABC
|
||||
|
||||
import discord
|
||||
import riotwatcher
|
||||
|
||||
import APICommands.Command
|
||||
|
||||
|
||||
class SummonerLevel(APICommands.Command.Command, ABC):
|
||||
keywords = ["level", "Level", "lvl"]
|
||||
|
||||
def __init__(self, pref, api: riotwatcher.LolWatcher, additionalKeywords: list):
|
||||
super().__init__(pref, api, additionalKeywords)
|
||||
|
||||
async def execute(self, message: discord.Message):
|
||||
pass
|
||||
|
||||
async def info(self, message: discord.Message):
|
||||
pass
|
||||
|
||||
async def usage(self, message: discord.Message):
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue