Skip to content

Instantly share code, notes, and snippets.

@Lifelovinglight
Created December 12, 2019 00:46
Show Gist options
  • Save Lifelovinglight/5402e67ffde1a3123429417eb553ef20 to your computer and use it in GitHub Desktop.
Save Lifelovinglight/5402e67ffde1a3123429417eb553ef20 to your computer and use it in GitHub Desktop.
s4s fortunes for irssi
#!/usr/bin/perl -w
# USAGE:
#
# /FORTUNE
# - Outputs a random fortune.
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = "1.0";
%IRSSI = (
authors => 'whiteline',
contact => '',
name => 's4s fortune',
description => 'Prints colored fortunes in the style of s4s.',
license => 'GNU GPLv3 or later',
url => '',
);
use Irssi;
use Irssi::Irc;
use Encode;
my @colors = ('2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14');
my @fortunes = ("Your fortune: Reply hazy, try again", "Your fortune: Excellent Luck", "Your fortune: Good Luck", "Your fortune: Average Luck", "Your fortune: Bad Luck", "Your fortune: Good news will come to you by mail", "Your fortune: ( ´_ゝ`)フーン", "Your fortune: キタ━━━━━━(゚∀゚)━━━━━━ !!!!", "Your fortune: You will meet a dark handsome stranger", "Your fortune: Better not tell you now", "Your fortune: Outlook good", "Your fortune: Very Bad Luck", "Your fortune: Godly Luck");
sub fortune {
my $newstr = "";
my $index = 0;
$index = int(rand(scalar(@colors)));
$newstr .= "\003";
$newstr .= sprintf("%02d", $colors[$index]);
$newstr .= $fortunes[$index];
return $newstr;
}
sub rfortune {
my ($text, $server, $dest) = @_;
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
return unless $dest;
if ($dest->{type} eq "CHANNEL" || $dest->{type} eq "QUERY") {
$dest->command("/msg " . $dest->{name} . " " . fortune());
}
}
Irssi::command_bind("fortune", "rfortune");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment