Skip to content

Instantly share code, notes, and snippets.

@bigpresh
Created December 5, 2016 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigpresh/00b5b942a8654482a3d3572279ba8766 to your computer and use it in GitHub Desktop.
Save bigpresh/00b5b942a8654482a3d3572279ba8766 to your computer and use it in GitHub Desktop.
trigger.pl - adding -targettag option to allow commands to react from a different connection
--- /home/davidp/tmp/vimbackups/trigger.pl_20161205-210005 2008-05-21 22:52:48.000000000 +0100
+++ /home/davidp/.irssi/scripts/trigger.pl 2016-12-05 21:05:09.123258579 +0000
@@ -107,6 +107,7 @@
Other options:
-disabled: %|Same as removing it, but keeps it in case you might need it later
-name: %|Give the trigger a name. You can refer to the trigger with this name in add/del/change commands
+ -targettag: %|the tag of the server to react from
Examples:
Knockout people who do a !list:
@@ -538,7 +539,7 @@
# list of all switches
my @trigger_switches = (@trigger_types, qw(all nocase stop once debug disabled));
# parameters (with an argument)
-my @trigger_params = qw(pattern regexp command replace name);
+my @trigger_params = qw(pattern regexp command replace name targettag);
# list of all options (including switches) for /TRIGGER ADD
my @trigger_add_options = (@trigger_switches, @trigger_params, keys(%filters));
# same for /TRIGGER CHANGE, this includes the -no<option>'s
@@ -605,6 +606,17 @@
} else {
$context = undef;
}
+
+ # ... if the targettag option was set, override the
+ # context with it
+ if ($trigger->{targettag}) {
+ $context = Irssi::server_find_tag(
+ $trigger->{targettag}
+ );
+ warn sprintf "Looked for %s, found %s",
+ $trigger->{targettag},
+ $context;
+ }
if (defined($context)) {
$context->command("eval $command");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment