Releases: Trimatix/BASED
v0.8-beta
The main changes in this release are:
- switch from flatfile json to sql
- switch from text commands and mainly reaction menus to slash commands and mainly components
What's Changed
- swap out configurator module for Carica integration by @Trimatix in #57
- fix all mypy warnings by @Trimatix in #58
- Introduce Defaultable class by @Trimatix in #59
- fix some mypy warnings by @Trimatix in #62
- make Defaultable a Mixin by @Trimatix in #63
- 81 switch from flat file to SQL database by @Trimatix in #93
- 81 switch from flat file to sql database by @Trimatix in #96
- v0.8 beta by @Trimatix in #98
Full Changelog: v0.5-alpha...v0.8-beta
dynamic scheduling
-
Central dynamic scheduler
The biggest change in this update is the start of moving from multiple task schedulers to a single scheduler. You can still use task references, but you should not rely on maintaining multiple schedulers to keep track of your tasks.
v0.5 also adds the new "dynamic" scheduler, which automatically yields its thread until the soonest-expiring timedtask is due to expire. In essence, AutoCheckingTimedTaskHeap is an interrupts-based scheduler, whereas TimedTaskHeap can be seen as polling-based. It will also handle its own task expiry thread, meaning you don't need to have a main loop in your client. -
Configurator timeouts
the timeouts config variable is now special-cased to allow for multi-level serialization. The configurator module, and this special-cased variable, are both planned to be overhauled and separated into a separate package. -
Run scripts removed
BASED no longer supports code deployment with git out of the box. This means that run scripts are now obsolete, and automatic restarting should instead be handled by your container software. In accordance, therestart
andupdate
commands have also been removed. -
SaveableMenu decorator
Relying on a public class attribute for menu saveability was not a viable long-term solution. Any classsaveable
attributes will now be completely disregarded, and can be removed unless you have your own behaviour which uses them. Instead, reaction menus are now marked as saveable using the newreactionMenu.saveableMenu
class decorator. Simply placing this decorator before your subclass declaration will set up your menu type for serializing and deserializing, with no extra input needed, other than the implementations of serializer methodstoDict
andfromDict
. You may also wish to check the new utility functions inreactionMenu.py
, beingisSaveableMenuClass
,isSaveableMenuInstance
,isSaveableMenuTypeName
, andsaveableMenuClassFromName
. Unfortunately, to allow for portability, classes are identified ENTIRELy by their names. As such, attempting to register two reactionMenu subclasses with the same name as saveable is not supported. -
Updated emoji support
BASED now supports the latest version of the emoji library. This was original handled by specifying an emoji library, but has since been changed to use emoji's built-in regex. The regional indicator emojis (🇦, 🇧, 🇨...), which are accepted by discord emojis but are not registered as emojis under the emoji consortium, will not be accepted into the emoji library standard, and have instead been special-cased. For details, see the PR here. Finally, emoji display mode indicators are now special-cased and stripped as well. This fixes false-negatives with emojis such as ⚒. I imagine more invisible characters such as this will need to be added in the future.
Misc
- fix erroneous exception swallowing when importing commands modules
- fix
BasedEmoji.fromReaction
references inSingleUserReactionMenu.doMenu
- added draft tox.ini with a few PEP standards ignored to align with my personal code style
compliance
This update adds a myriad of tweaks and reformatting, to fix hundreds of cases of standards misalignment;
for example, the entire codebase has been reformatted to align with PEP standards MUCH better - bringing violations down from 837 to 239 - and hundreds of code smells, as detected by sonarcloud, have been cleaned up.
This update also brings a fix to a major bug, in which adding a custom emoji reaction to a reaction menu could crash the menu, if the emoji is not accessible to the bot. This was an exceptionally large issue with inline menus.
hotfix: defaultEmoji initialization
Fix defaultEmoji config vars not being initialized properly from UninitializedBasedEmoji, due to new ConfigProxy typing.
configs
This update adds the ability to configure all of the bot's cfg
attributes externally with toml.
- To run the bot with your config, pass it through command-line arguments. e.g:
python3 main.py path-to-config.toml
- This path can be either absolute, or relative to the project root directory.
- All config variables are optional.
- Any emoji variable can be either unicode or custom.
- give custom emojis as the emoji ID, or unicode emojis as a string containing a single unicode emoji character.
- A default config file containing all configurable variables and their default values can be generated by running
makeDefaultConfig.py
. - The bot token can now be given in a config variable, or in an environment variable whose name is specified in config.
- To give your token directly in the config file, specify it in the
botToken
config var. - To give your token in an environment variable, give the name of the environment variable in the
botToken_envVarName
- You must give exactly one of these variables.
- To give your token directly in the config file, specify it in the
With the addition of the required config variables botToken
and botToken_envVarName
, a toml config file is now indirectly a requirement to launch the bot. This can be changed by providing your token in the attributes in the cfg
python module. If one of cfg.botToken
or botToken_envVarName
is present, the config file command line argument becomes optional.
This update also brings two looping bot launching scripts, run.bat
and run.sh
.
By launching your bot from a run
script, dev_cmd_restart becomes functional. This command will restart the script. The run
script will also restart your bot if critical errors are encountered, crashing the bot.
By giving the -g
argument to a run
script, dev_cmd_update becomes functional. ONLY specify -g
if you have git installed on your system, and your bot is in a git tree.
Running dev_cmd_update
will shut down the bot, run git pull
, and restart the bot again. If conflicts are encountered with merging commits, the pull will be cancelled entirely. This error will not be announced to discord, and you should check your console after running dev_cmd_update to ensure that it was successful (or implement your own bot version checking command)
ping
Minor update fixes and small features:
- BasedEmoji.eq now directly compares sendables and nothing else
- added admin_cmd_ping
- BasedClient now uses the
members
intent by default. Make sure you enable the members intent in the "bot" page of your application's setup: https://discord.com/developers/applications - added InlineConfirmationMenu
Useable
Add BASED version checking with git. A personal GitHub access token is no longer required.
on_reaction
events overhaul that's far more efficient than before.
Remove all bountybot references.
Reformat the built in source
command.
Initial draft
This version is a simple copy-over of code written in GOF2BountyBot.
The codebase is likely to change rapidly during the early stages of BASED development.