Skip to content

Instantly share code, notes, and snippets.

@concHNO3
Created July 8, 2015 18:23
Show Gist options
  • Save concHNO3/6b86545bdda8785c3dc6 to your computer and use it in GitHub Desktop.
Save concHNO3/6b86545bdda8785c3dc6 to your computer and use it in GitHub Desktop.
#8-ball / decision ball
#
use strict;
use vars qw($VERSION %IRSSI);
use Irssi qw(command_bind signal_add);
use IO::File;
$VERSION = '0.21';
%IRSSI = (
authors => '',
contact => '',
name => '',
description => '',
license => '',
);
sub own_question {
my ($server, $msg, $target) = @_;
question($server, $msg, "", $target);
}
sub public_question {
my ($server, $msg, $nick, $address, $target) = @_;
question($server, $msg, $nick, $target);
}
sub isadmin {
my ($nick) = @_;
$_ = $nick;
if (/^pni0$/i) {return 0;}
elsif (/^fayelinchen$/i) {return 0;}
elsif (/^alexventures$/i) {return 0;}
elsif (/^thechiefrap$/i) {return 0;}
else {return 1;}
}
sub givemoney {
my $nick = @_[0];
my $amount = @_[1];
system('~/TwitchBot/konto.sh '.$nick.' '.$amount);
return 0;
}
sub question {
my ($server, $msg, $nick, $target) = @_;
$_ = $msg;
if (/^!ledger/i) {
my ($result, $ignore);
$ignore = `touch ~/TwitchBot/Konto/$nick`;
$result = `cat ~/TwitchBot/Konto/$nick`;
if ($result eq ""){
$server->command('msg '.$target.' '.$nick.': nothing here.');
$ignore = `echo 0 > ~/TwitchBot/Konto/$nick`;
} else {
$server->command('msg '.$target.' '.$nick.': You have '.$result.' bottle caps.');
}
return 0;
} elsif (/^!flipcoin number/i) {
my $flip = int(rand(2));
my $ignore;
if ($flip == 1) {
$server->command('msg '.$target.' '.$nick.': Number! you won a bottle cap!');
$ignore = `touch ~/TwitchBot/Konto/$nick`;
system('TwitchBot/konto.sh $nick 1 ');
} else {
$server->command('msg '.$target.' '.$nick.': Head! you lost!');
}
return 0;
} elsif (/^!flipcoin head/i) {
my $flip = int(rand(2));
my $ignore;
if ($flip == 1) {
$server->command('msg '.$target.' '.$nick.': Head! you won a bottle cap!');
$ignore = `touch ~/TwitchBot/Konto/$nick`;
system('TwitchBot/konto.sh $nick 1 ');
} else {
$server->command('msg '.$target.' '.$nick.': Number! you lost!');
}
return 0;
} elsif (/^!gift/i) {
my $betrag = 10;
my $user = $msg =~ m/^!gift\s([\S]*)/i;
my $admin = $nick;
if ( isadmin($nick) == 0 ){
givemoney($user, $betrag);
$server->command('msg '.$target.' Target: '.$target.' User: '.$user.' Admin: '.$admin);
$server->command('msg '.$target.' '.$user.': '.$admin.' awarded you with '.$betrag.' bottel caps for your good work in chat.');
}
return 0;
}
}
signal_add("message public", "public_question");
signal_add("message own_public", "own_question");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment