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

Add pre_expand signal for filtering tidbits #100

Merged
merged 1 commit into from
May 16, 2017

Conversation

dgw
Copy link
Collaborator

@dgw dgw commented Apr 26, 2017

New signal called before expanding variables in a factoid. The tidbit itself is passed in as a reference.

Added for use by my plugin that implements the new syntax described in #89.

New signal called before expanding variables in a factoid. The tidbit
itself is passed in as a reference.
@dgw
Copy link
Collaborator Author

dgw commented Apr 28, 2017

Ping @zigdon, is there anything you'd change about this before I merge it?

@@ -3063,6 +3063,8 @@ sub sql {
sub expand {
my ( $who, $chl, $msg, $editable, $to ) = @_;

return if &signal_plugin( "pre_expand", {tidbit => \$msg} );
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why pass by reference? Seems out of norm relative to the other plugins?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I elected to pass by reference because of the existing plugin documentation, which states:

  Any sub that is handling a signal should return -1, 0 or 1:
  - -1 - no further processing should be done, no other plugins called.
  - 1  - process other plugins, but shouldn't continue with the core functions.
  - 0  - process other plugins and core functions.

The signal could return an array/list instead, but I preferred the simplicity of modifying $msg directly in the signaled plugin and returning a simple integer. I can rewrite it if you like, but I honestly think passing by reference is the least complicated method from a plugin writer's perspective.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me.

@dgw dgw merged commit 93d2cb5 into zigdon:master May 16, 2017
@dgw dgw deleted the pre_expand-signal branch May 16, 2017 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants