Skip to content

Instantly share code, notes, and snippets.

@sarahhodne
Created April 16, 2009 15:17
Show Gist options
  • Save sarahhodne/96470 to your computer and use it in GitHub Desktop.
Save sarahhodne/96470 to your computer and use it in GitHub Desktop.
# blah blah redistribution blah warranty blah
use Irssi;
use strict;
use vars qw($VERSION %IRSSI);
$VERSION='0.1';
%IRSSI=(
authors => 'grawity',
name => '...',
description => 'Does things.',
license => 'WTFPL 2.0',
url => 'sftp://scalar.cluenet.org/home/grawity/....pl'
);
sub onMessage {
my ($server, $message, $srcNick, $srcAddress, $target) = @_;
my $replyTo;
if ($target =~ m/^#/) { $replyTo = $target; }
else { $replyTo = $srcNick; }
return if $replyTo =~ /^#(clueirc)$/i;
for ($msg) {
if (/apples or oranges/i) {
$server->command("/msg ".$replyTo." Bananas!");
}
}
}
sub onPrivateMessage {
my ($server, $message, $srcNick, $srcAddress) = @_;
onMessage($server, $message, $srcNick, $srcAddress, $srcNick);
}
Irssi::signal_add_last('message public','onMessage');
Irssi::signal_add_last('message private','onPrivateMessage');
# blah blah redistribution blah warranty blah
use Irssi;
use strict;
use vars qw($VERSION %IRSSI);
$VERSION='1.1';
%IRSSI=(
authors => 'grawity',
name => 'fishbot',
description => 'Moos.',
license => 'WTFPL 2.0',
);
my @CobiMode = qw(#cluecouncil #clueirc);
my $me;
sub respondMessage {
my ($message, $who, $where) = @_;
for ($message) {
if (/^$me\??$/i)
{ return "You rang?"; }
elsif (/^fishbot, shut up$/i)
{ push @CobiMode, $where; return "Hrmpf."; }
elsif (/^fishbot, come back$/i)
{
for (my $i = 0; $i <= $#CobiMode; $i++) {
delete $CobiMode[$i] if $CobiMode[$i] eq $where;
}
return "\\o/";
}
return if grep $_ eq $where, @CobiMode;
if (/hampster/i)
{ return $who.": There is no 'p' in hamster you retard."; }
elsif (/(vinegar.*aftershock|aftershock.*vinegar)/)
{ return "Ah, a true connoisseur!"; }
elsif (/^some people are being fangoriously devoured by a gelatinous monster$/i)
{ return "Hillary's legs are being digested."; }
elsif (/^ag$/i)
{ return "Ag, ag ag ag ag ag AG AG AG!"; }
elsif (/^$me owns$/i)
{ return "Aye, I do."; }
elsif (/vinegar/i)
{ return "Nope, too sober for vinegar. Try later."; }
elsif (/martian/i)
{ return "Don't run! We are your friends!"; }
elsif (/^just then, he fell into the sea$/i)
{ return "Ooops!"; }
elsif (/aftershock/i)
{ return "mmmm, Aftershock."; }
elsif (/^why are you here\?$/i)
{ return "Same reason. I love candy."; }
elsif (/^spoon$/i)
{ return "There is no spoon."; }
elsif (/^(bounce|wertle)$/i)
{ return "moo"; }
elsif (/^crack$/i)
{ return "Doh, there goes another bench!"; }
elsif (/^you can't just pick people at random!$/i)
{ return "I can do anything I like, $who, I'm eccentric! Rrarrrrrgh! Go!"; }
elsif (/^flibble$/i)
{ return "plob"; }
elsif (/(the fishbot has|fishbot) created splidge/i)
{ return "omg no! Think I could show my face around here if I was responsible for THAT?"; }
elsif (/^now there's more than one of them\?$/i)
{ return "A lot more."; }
elsif (/^i want everything$/i)
{ return "Would that include a bullet from this gun?"; }
elsif (/we('re| are) getting aggravated/i)
{ return "Yes, we are."; }
elsif (/^how old are you, $me\?$/i)
{ return "\x01ACTION is older than time itself!\x01"; }
elsif (/^atlantis$/i)
{ return "Beware the underwater headquarters of the trout and their bass henchmen. From there they plan their attacks on other continents."; }
elsif (/^oh god$/i)
{ return "$me will suffice."; }
elsif (/^what is the matrix\?$/i)
{ return "No one can be told what the matrix is. You have to see it for yourself."; }
elsif (/^what do you need\?$/i)
{ return "Guns. Lots of guns."; }
elsif (/^i know kungfu$/i)
{ return "Show me."; }
elsif (/^cake$/i)
{ return "fish"; }
elsif (/^trout go m[o0][o0]$/i)
{ return "Aye, that\'s cos they\'re fish."; }
elsif (/^kangaroo$/i)
{ return "The kangaroo is a four winged stinging insect."; }
elsif (/^sea bass$/i)
{ return "Beware of the mutant sea bass and their laser cannons!"; }
elsif (/^trout$/i)
{ return "Trout are freshwater fish and have underwater weapons."; }
elsif (/has returned from playing counterstrike/i)
{ return "like we care ffs :("; }
elsif (/^where are we\?$/i)
{ return "Last time I looked, we were in %c."; }
elsif (/^where do you want to go today\?$/i)
{ return "anywhere but redmond :(."; }
elsif (/^fish go m[o0][o0]$/i)
{ return "\x01ACTION notes that $who is truly enlightened.\x01"; }
elsif (/^(.*) go(es)? m[o0][o0]$/i)
{ return "$who: only when they are impersonating fish."; }
elsif (/^fish go ([a-z0-9 _]+)$/i)
{ return "$who LIES! Fish don\'t go $1! fish go m00!"; }
elsif (/^you know who else (.*)$/i)
{ return "$who: YA MUM!"; }
elsif (/^if there's one thing i know for sure, it's that fish don't m00\.$/i)
{ return "$who: HERETIC! UNBELIEVER!"; }
elsif (/^$me: muahahaha\. ph33r the dark side\. :\)$/i)
{ return "$who: You smell."; }
elsif (/^ammuu\?$/i)
{ return "$who: fish go m00 oh yes they do!"; }
elsif (/^fish$/i)
{ return "$who: fish go m00!"; }
elsif (/^snake$/i)
{ return "Ah snake a snake! Snake, a snake! Ooooh, it's a snake!"; }
elsif (/^carrots handbags cheese$/i)
{ return "toilets russians planets hamsters weddings poets stalin KUALA LUMPUR! pygmies budgies KUALA LUMPUR!"; }
elsif (/sledgehammer/i)
{ return "sledgehammers go quack!"; }
elsif (/^badger( badger){11,}$/i)
{ return "mushroom mushroom!"; }
elsif (/^(m[o0][o0])\??$/i)
{ return "To $1, or not to $1, that is the question. Whether \'tis nobler in the mind to suffer the slings and arrows of outrageous fish..."; }
elsif (/^herring$/i)
{ return "herring(n): Useful device for chopping down tall trees. Also moos (see fish)."; }
elsif (/www\.outwar\.com/i)
{ return "would you please GO AWAY with that outwar rubbish!"; }
elsif (/^O( ?)RLY\??$/)
{ return "Y$1RLY"; }
elsif (/^$me[,:] (who) (are|r) (you|u)/i)
{ return "$who: I'm an irssiperl clone of a PHPserv clone of the QuakeNet fishbot."; }
elsif (/^$me[,:] what is (the )?fishbot/i)
{ return "$who: http://tinyurl.com/fishbot"; }
elsif (/^(¿|\?)oo(m|ɯ)$/i)
{ return "˙˙˙ɥsıɟ snoǝƃɐɹʇno ɟo sʍoɹɹɐ puɐ sƃuıls ǝɥʇ ɹǝɟɟns oʇ puıɯ ǝɥʇ uı ɹǝlqou sıʇ, ɹǝɥʇǝɥʍ ˙uoıʇsǝnb ǝɥʇ sı ʇɐɥʇ 'ooɯ oʇ ʇou ɹo 'ooɯ oʇ"; }
elsif (/what (do )?(you|u) need/i)
{ return "Guns. Lots of guns."; }
}
return "";
}
sub respondAction {
my ($message, $who, $where) = @_;
for ($message) {
return if grep $_ eq $where, @CobiMode;
if (/hampster/i)
{ return $who.": There is no 'p' in hamster you retard."; }
elsif (/^feeds fishbot hundreds and thousands$/i)
{ return "MEDI.. er.. FISHBOT"; }
elsif (/(vinegar.*aftershock|aftershock.*vinegar)/)
{ return "Ah, a true connoisseur!"; }
elsif (/vinegar/i)
{ return "Nope, too sober for vinegar. Try later."; }
elsif (/martian/i)
{ return "Don't run! We are your friends!"; }
elsif (/aftershock/i)
{ return "mmmm, Aftershock."; }
elsif (/we('re| are) getting aggravated/i)
{ return "Yes, we are."; }
elsif (/^trout go m[o0][o0]$/i)
{ return "Aye, that\'s cos they\'re fish."; }
elsif (/has returned from playing counterstrike/i)
{ return "like we care fs :("; }
elsif (/^fish go m[o0][o0]$/i)
{ return "\x01ACTION notes that $who is truly enlightened.\x01"; }
elsif (/^(.*) go m[o0][o0]$/i)
{ return "$who: only when they are impersonating fish."; }
elsif (/^fish go ([a-z0-9 _]+)$/i)
{ return "$who LIES! Fish don\'t go $1! fish go m00!"; }
elsif (/^you know who else (.*)$/i)
{ return "$who: YA MUM!"; }
elsif (/^strokes $me$/i)
{ return "\x01ACTION m00s loudly at $who\x01"; }
elsif (/^thinks happy thoughts about pretty (.*)$/i)
{ return "\x01ACTION has plenty of pretty $1. Would you like some?"; }
elsif (/^snaffles a (.+) off $me$/i)
{ return ":("; }
elsif (/^m[o0][o0]s at $me$/)
{ return "Moo."; }
elsif (/^goes m[o0][o0]/)
{ return "You aren't a fish, $who! YOU DON'T GO MOO!"; }
elsif (/^slaps ([^ ]+) around a bit with a large (trout)\.?$/)
{ return "trouted!"; }
}
return "";
}
sub respond {
my ($isAction, $server, $message, $who, $target) = @_;
return if $who =~ /^(i-log-things|fishbot|cluefish)$/i;
my ($isPrivate, $channel, $replyTo);
$me = $server->{nick};
if ($target =~ m/^#/) {
$isPrivate = 0;
$channel = $target;
$replyTo = $target;
}
else {
$isPrivate = 1;
$channel = 0;
$replyTo = $who;
}
return if $replyTo eq "#clueirc";
my $reply;
# if (
if ($who eq "hampster") { $who = 'nathan'; }
if ($isAction)
{ $reply = respondAction($message, $who, $replyTo); }
else
{ $reply = respondMessage($message, $who, $replyTo); }
return if $reply eq "";
if ($reply =~ /^\x01ACTION (.+)\x01$/)
{ $server->command("/action $replyTo $1"); }
elsif ($reply =~ /^\x01([a-z0-9_-]+( .+)?)\x01$/)
{ $server->command("/ctcp $replyTo $1"); }
else
{ $server->command("/msg $replyTo $reply"); }
}
sub onMessage {
my ($server, $message, $who, $whoAddress, $target) = @_;
respond(0, $server, $message, $who, $target);
} Irssi::signal_add_last('message public','onMessage');
sub onAction {
my ($server, $message, $who, $whoAddress, $target) = @_;
respond(1, $server, $message, $who, $target);
} Irssi::signal_add_last('message irc action','onAction');
sub onPrivateMessage {
my ($server, $message, $who, $srcAddress) = @_;
onMessage($server, $message, $who, $srcAddress, $who);
} #Irssi::signal_add_last('message private','onPrivateMessage');
# blah blah redistribution blah warranty blah
use Irssi;
use strict;
use vars qw($VERSION %IRSSI);
$VERSION='0.1';
%IRSSI=(
authors => 'grawity',
name => 'IRC logging bot',
description => 'Does things.',
license => 'WTFPL 2.0',
url => 'sftp://scalar.cluenet.org/home/grawity/logbot2.pl'
);
my $myOwner = '[email protected] [email protected] [email protected].* [email protected].* [email protected] [email protected] *[email protected] [email protected] [email protected] [email protected]';
my $trigger = 'computer';
sub demoronizeFunkyIPs {
my ($in) = @_;
my $out;
foreach my $piece (split /\./, $in) {
if (/^0x0*[0-9a-f]{1,2}$/i) {
$out .= "." . hex $piece;
}
elsif (/^0+[0-7]{1,2}$/) {
$out .= "." . oct $piece;
}
else {
$out .= "." . $piece;
}
}
}
sub onMessage {
my ($server, $message, $srcNick, $srcAddress, $target) = @_;
my $myNick = $server->{nick};
my $isOwner = $server->masks_match($myOwner, $srcNick, $srcAddress);
my $source = $srcNick."!".$srcAddress;
my ($isPrivate, $replyTo, $prettySource, $replyPrefix);
if ($target =~ /^#/) {
$isPrivate = 0;
$replyTo = $target;
$prettySource = $srcNick . " on " . $target;
$replyPrefix = $srcNick.": ";
}
else {
$isPrivate = 1;
$replyTo = $srcNick;
$prettySource = $srcNick;
$replyPrefix = "";
}
my @argv = split /\s+/, $message;
my $argc = @argv;
$message =~ m/^([^\s]*)\s(.*)$/;
my $command = $1;
my $args = $2;
for ($message) {
# check the entire line
if (/^\.\/?last\s*/i) {
return if $argc < 1;
return if $isPrivate and not $isOwner;
return if $isPrivate and $argc < 2;
my $channel = $isPrivate ? $argv[1] : $target;
$channel =~ tr/A-Z/a-z/;
my $logfile = '~/.logbot/irclogs/'.$server->{tag}.'/'.$channel.'.log';
my @tail = `tail -n 14 $logfile`;
$server->send_message($srcNick, '-----BEGIN LOG FOR '.$channel.'-----', 1);
foreach my $line (@tail) {
$server->send_message($srcNick, "[".$channel."] ".$line, 1);
}
$server->send_message($srcNick, '-----END LOG FOR '.$channel.'-----', 1);
}
elsif (/^\.rule ([0-9a-z.]+)$/) {
my %rules = (
"0" => "Don't be an asshole",
"1.3.3.7" => "This rule doesn't exist. Stop trying",
"1.1" => "No Leetspeak",
"1.2" => "No Malicious or Illegal Bots",
"1.3" => "Obey All Channel Operators of the Channels You are In",
"1.4" => "Obey All Network Operators",
"1.5" => "No Threats of DoS or Other Illegal Attacks",
"1.6" => "No DNS Spam Hosts",
"1.7" => "No Colors in Channel Topics",
"1.8" => "No Ban Evasion",
"1.9" => "No Harassment or Flooding",
"1.10" => "No Spreading of Viruses, Intentionally or Unintentionally",
"1.11" => "No Illegal Activity",
"2.1" => "No Auto-Rejoin on Kick",
"2.2" => "No Blatant Insults or Nonconstructive Criticism",
"2.3" => "No Private-Message Without Permission",
"2.4" => "Speak English",
"2.5" => "Use Clueful Chatting to the Best of your Ability",
"2.6" => "No Promotion or Emulation of Illegal Activity",
"3.1" => "No Frivolous Kills or Bans"
);
if ($rules{$1} eq "") {
$server->command("/msg ".$replyTo." Rule ".$1."not found.");
}
else {
$server->command("/msg ".$replyTo." ClueNet IRC Rule ".$1.": ".$rules{$1});
}
}
elsif (/^\.rules$/i) {
$server->command("/msg ".$replyTo." ClueNet IRC rules can be found at http://wiki.cluenet.org/IRC_Rules .");
}
elsif (/^\.ccl? ${myNick}\s*$/) {
return if $isPrivate;
sleep 1;
if (int rand(5) > 2) {
$server->command('/msg '.$replyTo.' '.$replyPrefix.'No thanks. I\'ll stay quiet.');
} else {
$server->command('/msg '.$replyTo.' '.$replyPrefix.'I\'m a bot, idiot. Bots don\'t talk.');
}
}
elsif (/^\.ld ${myNick}\s*$/) {
return if $isPrivate;
$server->command('/msg '.$srcNick.' Not funny.');
if ($srcNick eq 'Cobi' or $srcNick eq 'Crispy') {
sleep 5;
$server->command('/join '.$target);
$server->command('/msg '.$replyTo.' '.$replyPrefix.'Not funny.');
}
}
elsif (/^\.\/configure/) {
my @replies = (
'Bad command or file name',
'bash: ./configure: command not found',
'make install clean',
'%DCL-W-IVVERB, unrecognized command verb - check validity and spelling',
);
if (int rand(100) < 70) {
$server->command('/msg '.$replyTo.' '.$replies[int rand(1+$#replies)]);
}
}
elsif (($isPrivate and /a\/?s\/?l/i) or (not $isPrivate and /^${myNick}[:,]? a\/?s\/?l/i)) {
print "asl from ".$source;
my $age;
if (int rand(10) > 4) { $age = int rand(400) + 900; }
else { $age = int rand(100) - 100; }
srand time;
my @sex = qw(unknown male geek female uhh dude guy tree emo dumbass evilgenius nathan yourmom);
my @location = qw(USA Idiotistan Mars 127.0.0.1 Fuckyouville Hogwarts Internets your-arse Netherlands);
$server->command('/msg '.$replyTo.' '.$replyPrefix.$age.'/'.$sex[int rand($#sex)].'/'.$location[int rand($#location)]);
}
# no exact matches so far, check for "logbot:" prefix (not necessary for PMs)
elsif (($isPrivate and /^(.+)$/) or /^(?:logbot|computer|bucket|${myNick})[:,] (.+)$/i) {
for ($1) {
if (/^(die[^a-z]+|rm -rf|format [a-zA-Z]:)$/) {
$server->send_message("MemoServ", "send grawity logbot shutdown requested by ".$source." on ".$server->{tag}, 1);
return unless $isOwner;
print "quit by ".$source;
$server->command("/msg ".$replyTo." Ok, ".$srcNick);
#$server->command("/disconnect ".$server->{tag}." requested by ".$prettySource);
$server->command("/quit requested by ".$prettySource."/".$server->{tag});
}
elsif (/^(can|would) you (please )?(kill|terminate|kick|get rid of) (.+)\?$/i) {
return unless $isOwner;
return if $isPrivate;
$server->command("/kick $replyTo $4 Requested by $srcNick.");
}
elsif (/^poke/) {
$server->send_message($replyTo, $replyPrefix."Hm?", $isPrivate);
}
elsif (/^(run|plz|C:\\>) \//) {
return unless $isOwner;
$server->command("/msg ".$replyTo." Ok, ".$srcNick);
$args =~ /^[^\s]+ (\/.*)$/;
$server->command($1);
}
elsif (/^reload/) {
return unless $isOwner;
print "reload by ".$source;
$server->command("/run leetbot");
$server->command("/run logbot2");
$server->command("/msg ".$replyTo." Ok, ".$srcNick);
}
elsif (/^slap (.+)$/) {
$server->command("/action $replyTo slaps $1 around a bit with a large trout");
}
elsif (/^(#.+)/) {
if ($1 =~ /,0/) {
$server->command("/kick $replyTo $srcNick This... Is... SPARTA!!@") unless $isPrivate;
return;
}
print "join -> ".$1." by ".$source;
$server->command("/msg ".$replyTo." Ok, ".$srcNick);
$server->channels_join($1, 1);
#$server->command("/join ".$1);
}
elsif (/^(leave|part)( #.+)?/) {
#return unless $isOwner;
return if $isPrivate;
return if $srcNick eq "Cobi" or $srcNick eq "Crispy" or $srcNick eq "C-N810";
my $channel = $2 eq "" ? $target : $2;
print "part <> ".$channel." by ".$source;
$server->command("/msg ".$replyTo." Ok, ".$srcNick);
$server->command("/part ".$channel);
}
elsif (/^invite (me|.*) to (#.+)\.?$/) {
my $who = ($1 eq "me" ? $srcNick : $1);
my $where = $2;
return if not $isOwner and $who ne $srcNick;
$server->command('/invite '.$who.' '.$where);
}
elsif (/^invite (.*)\.?$/) {
return if $isPrivate;
my $who = ($1 eq "me" ? $srcNick : $1);
my $where = $target;
$server->command('/invite '.$who.' '.$where);
}
elsif (/^kick (me|.*)(\.| for .+)\.?$/) {
return unless $isOwner or $1 eq "me";
return if $isPrivate;
my $targets = (($1 eq "me") ? $srcNick : $1);
my $reason = (($2 eq ".") ? "kthxbai" : $2);
$reason =~ s/^ for //;
$reason =~ s/\s$//;
$server->command('/kick '.$target.' '.$targets.' '.$reason);
}
elsif (/^\/?(|de|un)(op|voice|halfop) (me|.*[^.])\.?$/) {
return if $isPrivate;
my $mode = $isOwner? ($1 eq "" ? "+" : "-") : "-";
my $targets = $isOwner? ($3 eq "me"? $srcNick : $3) : $srcNick;
my %modes = (
'op' => 'o',
'voice' => 'v',
'halfop' => 'h',
'ban' => 'b',
'except' => 'e',
'key' => 'k',
'limit' => 'l'
);
foreach my $temp (split /\s+/, $targets) { $mode .= $modes{$2}; }
$server->command('/mode '.$target.' '.$mode.' '.$targets);
}
elsif (/^(|de|un|remove |unset )(op|voice|halfop|ban|except|key|limit) (me|.*[^.])\.?$/) {
return if $isPrivate;
my $mode = $isOwner? ($1 eq "" ? "+" : "-") : "-";
my $targets = $isOwner? ($3 eq "me"? $srcNick : $3) : $srcNick;
my %modes = (
'op' => 'o',
'voice' => 'v',
'halfop' => 'h',
'ban' => 'b',
'except' => 'e',
'key' => 'k',
'limit' => 'l'
);
foreach my $temp (split /\s+/, $targets) { $mode .= $modes{$2}; }
$server->command('/mode '.$target.' '.$mode.' '.$targets);
}
elsif (/^mode (.+)\.?$/) {
return unless $isOwner;
return if $isPrivate;
$server->command('/mode '.$target.' '.$1);
}
elsif (/^\/(.+)$/) {
if ($isOwner) {
$server->command($1);
}
else {
$server->command("/action ".$replyTo." kicks ".$srcNick);
}
}
elsif (/(.+)$/) {
return unless $isOwner;
my $max = 4; # including the [more] line
my $thing = $1;
if ($thing =~ /^all /) {
$thing =~ s/^all (.+)$/$1/;
$max = 0;
}
my @out = `$thing 2>&1`;
my $i = 0; my $count = 1+$#out; my $line; my $left;
while ((($max == 0) || ($i < $max)) && ($i < $count)) {
$line = $out[$i];
$left = $count - $i;
if (($max > 0) && ($i+1 == $max) && ($left > 1)) {
$server->command("/msg ${replyTo} [$left more lines]");
}
else {
$server->command("/msg ${replyTo} ${line}");
}
$i++;
}
}
}
} # end if $myNick
# handle all other private messages
elsif ($isPrivate and not $isOwner) {
#$server->send_message("MemoServ", "send grawity <".$source."> ".$_, 1);
$server->send_message("#clueirc", "<".$srcNick."> ".$_, 0);
}
}
}
sub onPrivateMessage {
my ($server, $message, $srcNick, $srcAddress) = @_;
onMessage($server, $message, $srcNick, $srcAddress, $srcNick);
}
Irssi::signal_add_last('message public','onMessage');
Irssi::signal_add_last('message private','onPrivateMessage');
sub onInvite {
my ($server, $channel, $srcNick, $srcAddress) = @_;
$server->channels_join($channel, 1);
$server->command("/action ".$channel." m00s contentedly at ".$srcNick.".");
}
Irssi::signal_add_last('message invite','onInvite');
sub onKick {
my ($server, $channel, $victim, $srcNick, $srcAddress, $reason) = @_;
if ($victim eq $server->{nick}) {
$server->command("/msg ".$srcNick." Owie. Why?");
}
}
#Irssi::signal_add_last('message kick','onKick');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment