Skip to content

Instantly share code, notes, and snippets.

@LifeIsPain
Created April 22, 2013 03:41
Show Gist options
  • Save LifeIsPain/5432309 to your computer and use it in GitHub Desktop.
Save LifeIsPain/5432309 to your computer and use it in GitHub Desktop.
XChat script for moving notifications that a user is +g into the query tab
# Name: badassials.pl
# Version: 001
# Author: LifeIsPain < idontlikespam (at) orvp [dot] net >
# Date: 2013-04-21
# Description: Brian's ADvanced Adjust the Server-Side Ignore Alert Location Script
# Changes the notice location for when someone is in +g mode (Server-Side Ignore)
# The messages will now show up in the query tab you have with that user, if there is one.
# If there is no query tab, it will go into the front tab, if that tab is on the right
# network. If not, the message will show up in the server tab.
# Version History
# 001 2013-04-21 Initial Code, Requested in #xchat
# No changes needed within this file
use strict;
use warnings;
use Xchat qw(:all);
register('BADASSIALS', '001', 'Brian\'s ADvanced Adjust the Server-Side Ignore Alert Location Script');
hook_print("Server Text", \&caller_id_alert_query);
sub caller_id_alert_query {
my $return = EAT_NONE; # so it doesn't return 3 levels deep
# On tested network, this message shows up with raw events 716 and 717
if ( $_[0][2] == 716 || $_[0][2] == 717 ) {
# only do if not in a query context
my $event_context_info = context_info();
# 3 is the type for a query window
if ( $event_context_info->{type} != 3 ) {
# determine nick that caused the alert
$_[0][0] =~ /(^\S+)/;
my $target = $1;
# Attempt to set the context to an open query window on correct server
if ( set_context($target, $event_context_info->{server})
# make sure that the server id is the same for each
&& $event_context_info->{id} == context_info()->{id} ) {
# repeat print in right context
emit_print("Server Text", @{$_[0]});
$return = EAT_ALL;
}
# if there wasn't a context, place message in front tab rather than
# strictly server tab, this should handle /msg lines
# first gather information about the front context
elsif ( my $front_context_info = context_info(find_context()) ) {
# Make sure that the front context is on the same connection as where event is
if ( $front_context_info->{id} == $event_context_info->{id}
# and then verify that contexts are different, no point re-emit if already there
&& $front_context_info->{context} != $event_context_info->{context} ) {
set_context($front_context_info->{context});
# repeat print in right context
emit_print("Server Text", @{$_[0]});
$return = EAT_ALL;
}
}
}
}
# all done!
return $return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment