Last active
December 14, 2015 04:09
-
-
Save uriel1998/5026690 to your computer and use it in GitHub Desktop.
mmcirc.pl - For use with MMC IRC chat bot. It's largely for me (steven_saus), so YMMV.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# mmcirc.pl - For use with MMC IRC chat bot. | |
# It's largely for me (steven_saus), so YMMV. | |
# | |
# Largely a collection of useful snippets from http://xchatdata.net/Scripting/PerlSnippets | |
# | |
my $version = '0.1'; | |
my $name = 'MyMineCraftIRC helper'; | |
Xchat::register('MyMineCraftIRC helper', '001', 'Miscellaneous small perl snippets for helping the HeroChat-IRC gateway experience.'); | |
# ignore auto-away, and auto-back | |
Xchat::hook_print('Channel Action', sub { return Xchat::EAT_ALL if ($_[0][1] =~ /^is (?:auto[ -])?(?:away|back)/i); return Xchat::EAT_NONE; }); | |
# This is to highlight user names from HeroChat | |
Xchat::hook_print('Channel Message', sub { | |
$_[0][1] =~ m/^[(](\S+)([)].*)/; | |
return Xchat::EAT_NONE unless ($1 && Xchat::user_info(MMCBot)); | |
$_[0][1] = "(\cC3$1\cO$2"; | |
Xchat::emit_print('Channel Message', @{$_[0]}); | |
return Xchat::EAT_ALL; | |
}); | |
#Had to put in for hilight as well. #NOTE THAT I MANUALLY ADDED THE COMMAND TO PLAY A CHAT SOUND | |
Xchat::hook_print('Channel Msg Hilight', sub { | |
$_[0][1] =~ m/^[(](\S+)([)].*)/; | |
return Xchat::EAT_NONE unless ($1 && Xchat::user_info(MMCBot)); | |
$_[0][1] = "(\cC3$1\cO$2"; | |
Xchat::emit_print('Channel Message', @{$_[0]}); | |
Xchat::command('splay "/home/steven/Vault/sounds/Geiger1.wav"'); | |
return Xchat::EAT_ALL; | |
}); | |
# Using this for the opposite method - to MAKE there be a notification when MMCBot, SpongeBob, or Jarvis does something. | |
my $nicks = { | |
'spongebob' => 1, | |
'mmcbot' => 1, | |
'jarvis' => 1, | |
}; | |
my $hosts = { | |
'~jflood@flooder.example.net' => 1, | |
'bob@10.250.42.164' => 1, | |
}; | |
foreach ('Join', 'Quit', 'Part', 'Part with Reason') { Xchat::hook_print($_, \&nick_conference, {data => $_}); } | |
sub nick_conference { | |
my $host = ($_[1] =~ /^Part/ ? $_[0][1] : $_[0][2]); | |
return Xchat::command('splay "/home/steven/Vault/sounds/Torchwood.wav"') if (defined $nicks->{lc Xchat::strip_code($_[0][0])} || defined $hosts->{$host}); | |
return Xchat::EAT_NONE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment