############################################################################## # # # irssi_ddate - Discordian date for Irssi # Version FIVE # # This program takes no arguments. It doesn't take shit from _anyone_. # # It returns today's date in the Discordian calendar format. It also # tells you if today is a Holyday. # # This program is written in perl to maximize the amount of chaos in # the implementation. Kallisti (K) 1993, Screaming Lizard Propulsion # Systems. All rights reversed. Mess with this program. Call it your # own. Hail Eris. -><- # # Hugs and Kisses, # Reverend I. C. Puckett, Durham Discordian Glee Club # Prince of the Southern Provinces # # ############################################################################## use strict; use vars qw($VERSION %IRSSI); use Irssi; use Irssi::Irc; my ($nexttime,$trigger,$delay); $VERSION = '1.00'; %IRSSI = ( authors => 'Eris','Reverend I. C. Puckett', contact => 'eris@servergirl.net', name => 'Discordian Calender Script', description => 'Prints discordian date', license => 'Public Domain', ); # Say, how 'bout them month things? my @days_in_the_months = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); sub convert_date { my ($gday, $gmon, $gyear) = @_; my ($dweekday, $dday, $dseason, $dyear) = (-5, -5, -5, -5); my ($fnord); # Figure out the correct year. Easy peasy. $dyear = $gyear + 1166; # Now what day of the year is this? my ($day_of_year) = $gday; for (1 .. ($gmon - 1)) { $day_of_year += @days_in_the_months[$_ - 1]; } ###### print "Day of year: $day_of_year\n"; # What season is it? Seasons are seventy-three days long. There # are _five_ seasons in a year. Seven minus three is four, which is # two squared. Take one of those twos, and add it to the three: # you get _five_. Take the other two, subtract it from the seven: # you get _five_. $dseason = int(($day_of_year-1) / 73) + 1; if (($gmon == 2) && ($gday == 29)) { # Happy St. Tib's day! Time for Jello (tm). $dweekday = 0; $dday = 0; } else { # St. Tib will have to wait. $dweekday = (($day_of_year - 1) % 5) + 1; $dday = (($day_of_year - 1) % 73) + 1; } return ($dweekday, $dday, $dseason, $dyear); } sub print_discordian_date { my ($dweekday, $dday, $dseason, $dyear); my ($targetchan,$server)=@_; # Use the groovy perl time interface. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; # Fix the screwed up results from the groovy perl time interface. $mon++; $year += 1900; # And convert to Discordian calendar. my @discordian_date = do convert_date($mday,$mon,$year); $dweekday = ( "Saint Tib's Day", "Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange", )[@discordian_date[0]]; if (@discordian_date[1] == 0) { $dday = "between 59 and 60"; } else { $dday = @discordian_date[1]; } $dseason = ( "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath", )[@discordian_date[2] - 1]; $dyear = @discordian_date[3]; $server->command("/QUOTE PRIVMSG " . $targetchan ." :Today is $dweekday, day $dday in the season of $dseason,$dyear."); $server->print($targetchan,"Today is $dweekday, day $dday in the season of $dseason,$dyear.",MSGLEVEL_CLIENTCRAP); # Handle the Apostle Holydays. Rejoice rejoice. Whee. if ($dday == 5) # is today a holy day? huh? { my ($aholyday)=( "Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay", )[@discordian_date[2] - 1]; $server->command("/QUOTE PRIVMSG " . $targetchan ." :It is the sacred Apostle Holyday of $aholyday."); $server->print($targetchan,"It is the sacred Apostle Holyday of $aholyday.",MSGLEVEL_CLIENTCRAP); } # Handle the Season Holydays. The crowd goes wild. Who celebrates # these things anyway? if ($dday == 50) # is today a holy day? huh? { my($sholyday)=( "Chaoflux", "Discoflux", "Confuflux", "Bureflux", "Afflux", )[@discordian_date[2] - 1]; $server->command("/QUOTE PRIVMSG " . $targetchan ." :It is the sacred Season Holyday of $sholyday."); $server->print($targetchan,"It is the sacred Season Holyday of $sholyday.",MSGLEVEL_CLIENTCRAP); } } sub pub_msg { my ($server, $msg, $nick, $address, $targetchan) = @_; if (($msg eq $trigger) && (time() > $nexttime)){ print_discordian_date($targetchan,$server); $nexttime = time()+$delay; } } sub own_pub_msg { my ($server,$msg,$targetchan)=@_; pub_msg($server,$msg,'','',$targetchan); } sub ddate_change_settings { $delay=Irssi::settings_get_int('ddate_dly'); $trigger=Irssi::settings_get_str('ddate_trigger'); $nexttime=time()+$delay; } Irssi::signal_add_last('message public', 'pub_msg'); Irssi::signal_add('message own_public','own_pub_msg'); Irssi::signal_add('setup changed', 'ddate_change_settings'); Irssi::signal_add('setup reread', 'ddate_change_settings'); Irssi::settings_add_int('ddate', 'ddate_dly', '5'); Irssi::settings_add_str('ddate', 'ddate_trigger', '!ddate'); ddate_change_settings();