Skip to content

Instantly share code, notes, and snippets.

@LifeIsPain
Created May 6, 2013 01:29
Show Gist options
  • Save LifeIsPain/5522875 to your computer and use it in GitHub Desktop.
Save LifeIsPain/5522875 to your computer and use it in GitHub Desktop.
XChat script to set the nick to the primary nick for the network, even if defined in server list
# Name: nick_to_primary.pl
# Version: 001
# Author: LifeIsPain < idontlikespam (at) orvp [dot] net >
# Date: 2013-05-05
# Description: Set the nick to the primary nick for the network, even if defined in server list
# Version History
# 001 2013-05-05 Initial Version
use strict;
use warnings;
use Xchat qw(:all);
register('Nick to Primary', '001', 'Change nick to the primary nick for a network');
hook_command('nickprimary', \&nick_primary);
sub nick_primary {
# determine what primary nick would be
my $network_name = get_info('network');
my $network_nick;
# only check if $network_name is defined, otherwise was done with /server irc.network.net
if (defined $network_name) {
my @network_list = get_list('networks');
for my $network (@network_list) {
if ($network_name eq $network->{network}) {
$network_nick = $network->{irc_nick1};
last;
}
}
}
# if we don't know the network nick (either no network name, or using default), pull from set
unless (defined $network_nick) {
$network_nick = get_prefs('irc_nick1');
}
# only change nick if a different nick
if ($network_nick ne get_info('nick')) {
command("nick $network_nick");
}
return EAT_XCHAT;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment