Last active
August 29, 2018 13:53
-
-
Save jtiala/4dbbc43b2f140987156f294eb9194713 to your computer and use it in GitHub Desktop.
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
use strict; | |
use vars qw($VERSION %IRSSI); | |
use Irssi qw(command_bind signal_add); | |
use IO::File; | |
$VERSION = '0.69'; | |
%IRSSI = ( | |
authors => 'Joonas Tiala', | |
contact => 'joonas.tiala@gmail.com', | |
name => 'Dustkiller', | |
description => 'Killing never gets old... just a little >dusty :D', | |
license => 'GPL', | |
); | |
sub random_int_between { | |
my($min, $max) = @_; | |
return $min if $min == $max; | |
($min, $max) = ($max, $min) if $min > $max; | |
return $min + int rand(1 + $max - $min); | |
} | |
sub send_message { | |
my $serv = $_[0]; | |
my $nick = $_[1]; | |
my $msg = $_[2]; | |
my $chan = ""; | |
my $chan = $_[3]; | |
# Check if the command arrived from query or channel | |
if ($chan ne "") { | |
$serv->command('msg '.$chan.' '.$msg); | |
} else { | |
$serv->command('msg '.$nick.' '.$msg); | |
} | |
} | |
sub message { | |
my ($server, $msg, $nick, $target, $channel) = @_; | |
$_ = $msg; | |
my @channel_whitelist = ('#blanko.elvari'); | |
if (($channel ~~ @channel_whitelist) || $channel eq "") { | |
if (/^Nyt sitä peliä vittu/i) { | |
for (my $i = 0; $i < 10; $i++) { | |
my $rand_val = random_int_between(1,2); | |
if ($rand_val == 1) { | |
send_message($server, $nick, '.red', $channel); | |
} else { | |
send_message($server, $nick, '.black', $channel); | |
} | |
} | |
} elsif (/^Nyt sitä cursea vittu/i) { | |
for (my $i = 0; $i < 3; $i++) { | |
send_message($server, $nick, '!curse satou', $channel); | |
} | |
} elsif (/^Ha-haloo/i) { | |
send_message($server, $nick, 'M-moi :3', $channel); | |
} | |
} | |
} | |
signal_add("message public", "message"); | |
signal_add("message private", "message"); | |
signal_add("message own_public", "message"); | |
signal_add("message own_private", "message"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment