Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bbtag update phase2 #67

Merged
merged 41 commits into from
Mar 29, 2018
Merged

Bbtag update phase2 #67

merged 41 commits into from
Mar 29, 2018

Conversation

danny-may
Copy link
Contributor

@danny-may danny-may commented Mar 27, 2018

Most of this update revolves around the update to the engine. While not perfect or anything, this new one does allow for greater control over scopes and what gets passed around between subtags during execution.

Backend Changes

  1. Added BBTagEngine.js - All the complex stuff goes here. Includes all the logic for processing and responding to tag execution requests
  2. Various updates to match this new engine - The bulk of the changes to all subtags have been as follows:
  • params.args => args (now 0 indexed rather than 1 indexed)
  • whenArgs(x => whenArgs(x-1
  • beforeExecute(.... => removed. Subtags which previously had no before execute now have resolveArgs which you supply with arg indexes to resolve.
  • params.msg => context.msg
  • params.channel => context.channel
  • params.channel.guild => context.guild
  • params.msg.author => context.user
  • params.msg.member => context.member
  1. Variable caching - Now all variables will be cached in-memory upon first access/set and wont be persisted to the database until the tag completes. This 1. provides better protection against malformed data in the event of an internal server error, 2. speeds up all variable types to nearly the same speed as temporary variables and 3. enables operations that may have been previously too costly to be added in the future.

"Front" end changes - The stuff users gon see

  1. Added b!cc test <code>, b!cc test debug <code>, b!cc debug <CCName> [args...], b!t test debug <code> and b!t debug <tag> [args...]. Debug statements will cause an attachment to be sent which will contain all the useful information about the tag execution. While not comprehensive, it does have better error tracking and a dump of the final variable values.
  2. Removed the silly restriction on the docs for cc only subtags. Idk why I thought this was a good idea, sorry support :notlikecat:
  3. Better {exec[cc]} - Now rather than it being a limit of 200 calls per tag, its instead a maximum depth of 200 calls. I intend to do something similar for the loop tags (for, foreach and repeat) but I need to figure out how to approach that first.

Bug fixes
Ive done various fixes on my way through this PR, the notable ones I can think of off the top of my head are:

  1. Fixed a logical error in slice causing internal server errors
  2. Fixed rolemes being completely mute
  3. Fixed cats typos on {userbot}
  4. Fixed an error or two on edit when the message is not found
  5. Finally fixed a dumb persistent issue with capitalize
  6. Fixed a shard kill that {inject} could cause

Next phase
This update, because its actually less breaking than the previous one, has been kept rather feature light. This is because I am intending to add a lot of new subtags for the next big PR I do:
{listreact}
{removereact}
{waitreact}
{waitmessage}
{function} (creates a function)
{call} (calls a function)
{getmessage}
{hasperm}
{userexists}
{rolemove} and a few other tweaks and features

Fixed some scope issues
Added text trimming before execution
Removing all the old tag stuff. Escaping isnt actually needed any more
because the whole tag is parsed and markers placed before any execution,
meaning theres no way to inject your own code into the bot. The only
tags that dont get fully parsed beforehand are {exec}, {execcc} and
{inject}, for obvious reasons, however before they execute their
contents they too parse before executing, meaning no issues there.
Also made various errors actual errors rather than strings
@Ratismal Ratismal merged commit 71d57b0 into blargbot:master Mar 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants