To create new wiki account, please join us on #znc at Libera.Chat and ask admins to create a wiki account for you. You can say thanks to spambots for this inconvenience.

Buffextras/XChat-perl

From ZNC
Revision as of 10:44, 17 December 2011 by DarthGandalf (talk | contribs) (Created page with "===== XChat Perl Plugin ===== This is an edit of [http://fremnet.net.au Freman]'s savebuff script, edited to work for buffextras instead. Tested on X-C...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
XChat Perl Plugin

This is an edit of Freman's savebuff script, edited to work for buffextras instead. Tested on X-Chat Aqua, but should work on X-Chat.

  • Copy and paste this script to .xchat/znc-buffextras.pl or /Applications/X-Chat Aqua/Plugins/znc-buffextras.pl
  • Restart X-Chat
#!/usr/bin/perl
my $ShowMode = "mode \00310%s\003 \002%s\002 by \002%s\002";
my $ModName = "*buffextras";
Xchat::register('ZNC-BuffExtras','1.00','Display the on-join buffer for ZNC module buffextras nicely');

Xchat::hook_server('PRIVMSG',\&ProcessPMSG);
Xchat::hook_server('MODE',\&ShowModes); 
Xchat::hook_print('Channel Operator',\&DontDisplay);
Xchat::hook_print('Channel DeOp',\&DontDisplay);
Xchat::hook_print('Channel Voice',\&DontDisplay);
Xchat::hook_print('Channel DeVoice',\&DontDisplay);
Xchat::hook_print('Channel Ban',\&DontDisplay);
Xchat::hook_print('Channel UnBan',\&DontDisplay);
Xchat::hook_print('Channel Mode Generic',\&DontDisplay);
Xchat::hook_print('Channel Set Key',\&DontDisplay);
Xchat::hook_print('Channel Set Limit',\&DontDisplay);
Xchat::hook_print('Channel Remove Keyword',\&DontDisplay);
Xchat::hook_print('Channel Remove Limit',\&DontDisplay);

sub ShowMode {
       my ($Channel,$Modes,$Nick) = @_;

       my $Output = sprintf($ShowMode,$Channel,$Modes,$Nick);
       Xchat::emit_print("Generic Message","-\00310-\002-\002\003",$Output,null);
}

sub ProcessPMSG {
       my @Word = @{$_[0]};
       my @Word_EOL = @{$_[1]};
       if ((substr($Word[0],1,length($ModName)) eq $ModName) && ($Word[2]) && ($Word[3]) && ($Word[4])) {
               my $Channel = $Word[2];
               my $Hostmask = substr($Word[3], 1);
               my $Type = $Word[4];
               my $Args = ($Word[5]) ? $Word_EOL[5] : undef;

               my ($Nick, $Host) = ($Hostmask =~ /^([^\!]+)!(.+)$/g);

               if ($Type eq 'set') {
                      ShowMode($Channel,substr($Args, 6),$Nick);
               } elsif ($Type eq 'joined') {
                       Xchat::emit_print("Join",$Nick,$Channel,$Host,null);
               } elsif ($Type eq 'parted') {
                       Xchat::emit_print("Part",$Nick,$Host,$Channel,null);
               } elsif ($Type eq 'is') {
                       Xchat::emit_print("Change Nick",$Nick,substr($Args, 13),null);
               } elsif ($Type eq 'quit') {
						Xchat::emit_print("Quit",$Nick,substr($Args, 15, -1),null);
               } elsif ($Type eq 'kicked') {
						Xchat::emit_print("Kick",$Nick,$Word[5],$Channel,substr($Word_EOL[6], 9, -1));
               }elsif ($Type eq 'changed') {
               		Xchat::emit_print("Topic Change",$Nick,substr($Args, 14),null);
               } else {
                       printf STDERR "Unhandled Text! [%s]\n", $Word_EOL[2];
               }

               return Xchat::EAT_ALL;
       }

       return Xchat::EAT_NONE;
}

sub DontDisplay {
       return Xchat::EAT_XCHAT;
}

sub ShowModes {
       my @Word = @{$_[0]};
       my @Word_EOL = @{$_[1]};

       my $Channel = $Word[2];
       $Word[0] =~ /^:([^\!]+)!.*/;
       $Nick = $1;
       my $Modes = $Word_EOL[2];

       ShowMode($Channel,$Modes,$Nick);

       return Xchat::EAT_NONE; 
}