Pre-Deployment Still bugged as hell.

This commit is contained in:
Vivek Santayana 2021-07-26 18:54:28 +01:00
parent e30e89e7e3
commit 7916b1fca6
15 changed files with 76 additions and 186 deletions

3
.gitignore vendored
View File

@ -1,5 +1,8 @@
db/*
**/data/*.yml
!**/data/config_blueprint.yml
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/

View File

@ -204,3 +204,5 @@ Programming around this will need a further layer of complexity, involving flags
I have set the member verification prompt to use a global listener to avoid a situation where it creates several backlogged processes when multiple people post sign-ups at the same time.
This should also mean that the sign-up prompts should persist over reboots.
The best possible way of setting this up is probably using functions to dynamically set up and remove component call-backs.
Also components do not need to all have unique names, just unique names in the message they are part of.

123
TODO.md
View File

@ -1,7 +1,7 @@
# To Do
- [ ] Testing
- [ ] Dockerise
- [x] Dockerise
- [ ] Infer/Transfer data from old bot
- [ ] Deploy
@ -10,9 +10,7 @@
- [x] Simplify directory tree
- [x] Split event listeners into individual cogs.
- [x] Update with re-organised data and config structure
> - [x] Correct references to data in existing cogs.
- [x] Correct references to data in existing cogs.
- [x] Setup minimally functioning configs of guild on startup
- [x] Synchronise core configuration `/commands` on startup
- [ ] ~~Synchronise secondary `/commands` on complete configuration~~ ``(see below)``
@ -29,44 +27,28 @@
- [x] Delete Dev/Test Functions
- [x] Error handlers
- [x] Debug Features
> - [ ] ~~Command Installer/Uninstaller~~
- [ ] ~~Command Installer/Uninstaller~~
- [x] Help Channel Event Listener
> - [x] Add Config key for Help Channel
- [x] Add Config key for Help Channel
- [ ] ~~Slash Command Buttons or~~ `This kind of got subsumed into other features.`
- [ ] ~~Reaction listener selectors~~ `So did this.`
- [x] Member Verification
> - [x] Add Config key membership signup channels
> - [x] Add config keys: Membership Category Roles
> - [x] Message Receive listener
> - [x] ~~Message React listener~~ or buttons `Used buttons waiting within the same command thread. Possibly update to global listener if performance is affected.`
- [x] Add Config key membership signup channels
- [x] Add config keys: Membership Category Roles
- [x] Message Receive listener
- [x] ~~Message React listener~~ or buttons `Used buttons waiting within the same command thread. Possibly update to global listener if performance is affected.`
- [x] Membership Restriction
> - [x] Message Receive Listener
> - [x] Membership Validation Listener
- [x] Message Receive Listener
- [x] Membership Validation Listener
- [x] Re-synchronise commands after any relevant config changes `(See from above)`
> - [ ] Role Delete (~~member~~, ~~admin~~, ~~game~~) `Admin role missing won't cause any issues as server role will still remain in control`
- [ ] Role Delete (~~member~~, ~~admin~~, ~~game~~) `Admin role missing won't cause any issues as server role will still remain in control`
`Deleting membership roles will also trigger a mess. Event listener will trigger and attempt to execute simultaneously with the command to delete the role, which will cascade into several errors. In order to make this work, it is best to have the commands interact solely with the roles, and then subsequently the listeners to sync with the data.`
> - [ ] ~~Channel delete (notifications, logs, game text channel)~~ `There aren't any critical settings that depend on this just yet, and it is hard to set this up without circularity`
> - [ ] ~~Category delete (games)~~ `Circularity problem: if the category delete event listener is set up, it will react to the bot deleting categories when managing games.`
- [x] Flag for checking completeness of configuration for a guild.
> - [x] Function for checking configs for completeness
- [ ] ~~Channel delete (notifications, logs, game text channel)~~ `There aren't any critical settings that depend on this just yet, and it is hard to set this up without circularity`
- [ ] ~~Category delete (games)~~ `Circularity problem: if the category delete event listener is set up, it will react to the bot deleting categories when managing games.`
- [x] Flag for checking completeness of configuration for a guild.
- [x] Function for checking configs for completeness
- [ ] ~~Synchronise game channel on role updates~~
> - [ ] ~~Exception to event listener to prevent circularity~~ ~~`unsure what this means`~~
- [ ] ~~Exception to event listener to prevent circularity~~ ~~`unsure what this means`~~
`I remember what this is now: if you have a listener for when roles get deleted, and if the bot deletes a role, then it triggers the listener. It might be worth restructuring this such that the Bot command only deletes the role, which then triggers the listener that deletes the categories and synchronises data. That way, the roles can be deleted manually or via the command. Otherwise, it is not possible in the Discord API to have this exception, as the Bot only responds to the 'Guild' deleting the role, not the user or bot or admin that issued the command.`
## Event Listeners
@ -80,57 +62,46 @@
## Commands
- [x] Configure Bot function and sub commands
> - [x] botrole (role group)
> - [x] committeerole (role group)
> - [x] modchannel (channel group)
> - [x] help channel (channel group)
> - [x] signup channel (channel group)
> - [x] newcomer role (role group)
> - [x] returning player role (role group)
> - [x] student role (role group)
> - [x] help notifications (notification group)
> - [x] signup notifications (notification group)
- [x] botrole (role group)
- [x] committeerole (role group)
- [x] modchannel (channel group)
- [x] help channel (channel group)
- [x] signup channel (channel group)
- [x] newcomer role (role group)
- [x] returning player role (role group)
- [x] student role (role group)
- [x] help notifications (notification group)
- [x] signup notifications (notification group)
- [x] Set up timeslots
- [x] Delete timeslots
> - [x] Base command
> - [x] ~~Delete all games with the timeslot~~
- [x] Base command
- [x] ~~Delete all games with the timeslot~~
Do the opposite: block deleting timeslots with existing games.
- [x] List timeslots
- [x] Set up command permissions
> - [x] Slash Commands
>> - [x] Admin Commands
>> - [x] Game Management Commands
> - [x] Native Bot Commands
- [x] Slash Commands
- [x] Admin Commands
- [x] Game Management Commands
- [x] Native Bot Commands
- [x] Migrate existing bot commands
> - [x] setupgame
> - [x] ~~definebotrole~~ config
> - [x] deletegame
> - [x] ~~reset~~ purge
> - [ ] ~~migrate~~ `See above`
> - [x] ~~kickplayer~~ `/player remove`
> - [x] ~~addplayer~~ `/player add`
> - [x] ~~leavegame~~ `/player leave`
> - [x] Pitch command and sub-commands
> > - [ ] ~~run~~ `Combined both sub-commands into single command and prompt response.`
> > - [ ] ~~clear~~
- [x] setupgame
- [x] ~~definebotrole~~ config
- [x] deletegame
- [x] ~~reset~~ purge
- [ ] ~~migrate~~ `See above`
- [x] ~~kickplayer~~ `/player remove`
- [x] ~~addplayer~~ `/player add`
- [x] ~~leavegame~~ `/player leave`
- [x] Pitch command and sub-commands
- [ ] ~~run~~ `Combined both sub-commands into single command and prompt response.`
- [ ] ~~clear~~
## Misc
- [x] Review documentation
> - [x] Finalise README.md
> - [x] CHANGELOG.md
> - [x] COMMANDS.md
> - [x] resources.md
- [x] Finalise README.md
- [x] CHANGELOG.md
- [x] COMMANDS.md
- [x] resources.md
- [x] Make sure to document `not using discord_components and staying with discord-py-slash-commands library alone`.

View File

@ -1,4 +1,4 @@
FROM python:3.8.6-buster
FROM python:3.9.6-alpine
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN pip install --upgrade pip

View File

@ -60,13 +60,12 @@ if len(set(l)) != len(l): raise Exception('Config Error: there is a clash betwee
# Locate Cogs Directory
cogsDir = 'cogs'
# --> Temporary disable logging because of verboseness.
# ## Logging configuration imported boilerplate from Discord Py Docs
# logger = logging.getLogger('discord')
# logger.setLevel(logging.DEBUG)
# handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
# handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
# logger.addHandler(handler)
## Logging configuration imported boilerplate from Discord Py Docs
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
#### Dynamic Prefixes
def getPrefix(client, message):
@ -285,4 +284,4 @@ if yaml_load(configFile):
if any([len(yaml_load(configFile)[x]['membership']) > 0 for x in yaml_load(configFile)]):
loadCog(f'./{cogsDir}/slashcommands/secondary/edit_membership.py')
client.run(os.getenv('TEST_3_TOKEN'))
client.run(os.getenv('BOT_TOKEN'))

View File

@ -69,7 +69,7 @@ class Migrate(commands.Cog, name='Migrate Command'):
await r.edit(
reason=f'`migrate` command issued by {ctx.author.display_name}',
mentionable=True,
colour=discord.Colour.green
colour=discord.Colour.green()
)
c = discord.utils.get(ctx.guild.categories, name=r.name)
if c is None:

View File

@ -97,7 +97,7 @@ class Configuration(commands.Cog, name='Configuration Commands'):
permissions=discord.Permissions(administrator=True) if key == 'committee' else discord.Permissions().none(),
reason=f'`/config roles` command issued by {ctx.author.display_name}',
colour = discord.Colour.orange() if key == 'bot' else discord.Colour.blue() if key == 'committee' else discord.Colour.default(),
hoist=True if key == 'committee' else None,
hoist=True if key == 'committee' or key == 'bot' else None,
)
conf = yaml_load(configFile)
guildStr = str(ctx.guild.id)

View File

@ -1,4 +0,0 @@
'864651943820525609':
'868506573700468787': 868506572421234718
'868506638720577586': 868506637252583494
'868506722187227166': 868506720375300137

View File

@ -1,26 +0,0 @@
'864651943820525609':
channels:
help: 866645822472454206
mod: 865348933022515220
signup: 868523157680693278
configured: true
membership:
- 866795009121714207
name: Test
notifications:
help: true
signup: true
owner: 493694762210033664
prefix: '-'
restrict: false
roles:
admin:
- 866642278529368095
bot: 866639184121954305
committee: 866642278529368095
newcomer: 866645308091138060
returning_player: 866645365524660224
student: 866645394699714570
timeslots:
avatar: Avatar Time
shera: She Ra Time

View File

@ -1,38 +0,0 @@
'864651943820525609':
avatar:
'868506572421234718':
category: 868506573700468787
current_players: 1
game_title: Kyoshi
gm: 864649599671205914
header_message: 868506578934976543
max_players: 5
min_players: null
platform: null
role: 868506572421234718
system: null
text_channel: 868506576695230534
'868506637252583494':
category: 868506638720577586
current_players: 0
game_title: Roku
gm: 864649599671205914
header_message: 868506642545795142
max_players: 5
min_players: null
platform: null
role: 868506637252583494
system: null
text_channel: 868506640347971655
'868506720375300137':
category: 868506722187227166
current_players: 0
game_title: Aang
gm: 864649599671205914
header_message: 868506726029197312
max_players: 5
min_players: null
platform: null
role: 868506720375300137
system: null
text_channel: 868506724045303878

View File

@ -1,5 +0,0 @@
'864651943820525609':
'864649599671205914':
- 868506572421234718
- 868506637252583494
- 868506720375300137

View File

@ -1,19 +0,0 @@
'864651943820525609':
'868506572421234718':
category: 868506573700468787
game_title: Kyoshi
gm: 864649599671205914
text_channel: 868506576695230534
time: avatar
'868506637252583494':
category: 868506638720577586
game_title: Roku
gm: 864649599671205914
text_channel: 868506640347971655
time: avatar
'868506720375300137':
category: 868506722187227166
game_title: Aang
gm: 864649599671205914
text_channel: 868506724045303878
time: avatar

View File

@ -1 +0,0 @@
{}

View File

@ -8,7 +8,7 @@ from discord_slash import SlashCommand, SlashContext, cog_ext, utils # Slash C
from discord_slash.utils.manage_commands import create_choice, create_option # Slash Command features
from pprint import pprint
from bot import clearConfig, configFile, loadCog, loadCogs, setConfig, unloadCog, unloadCogs, yaml_dump, yaml_load, reloadCog, reloadCogs
from bot import clearConfig, configFile, loadCog, loadCogs, setConfig, unloadCog, unloadCogs, yaml_dump, yaml_load, reloadCog, reloadCogs, pitchesFile, cogsDir
##### Debug Cog
class Debug(commands.Cog, name='Debug Commands'):
@ -152,5 +152,17 @@ class Debug(commands.Cog, name='Debug Commands'):
await self.client.slash.sync_all_commands()
await ctx.reply(f'```All slash commands have been synced with the Server.```')
@commands.command(
name='pitchreset',
description='Debug feature that resets the pitches in case of any error. Clears pitch disables Pitch listeners.',
brief='Reset running pitches.',
aliases=['resetpitches', 'resetpitch']
)
async def _pitchreset(self, ctx:commands.Context):
yaml_dump({}, pitchesFile)
if self.client.get_cog('Pitch Listener') is not None:
unloadCog(f'./{cogsDir}/events/secondary/pitch_listener.py')
await ctx.reply('```Pitches have been hard reset.```')
def setup(client):
client.add_cog(Debug(client))

View File

@ -5,8 +5,4 @@ services:
build: ./app
volumes:
- ./app:/usr/src/app
restart: always
environment:
- BOT_TOKEN=${BOT_TOKEN}
- TEST_TOKEN=${TEST_TOKEN}
- BOT_VERSION=${BOT_VERSION}
restart: always