#!/usr/bin/perl # # Flash-Quotes.pl - Various Quote things for X-chat (Windows or Linux) # (I mean famous quotes, not "add yer mates witterings" sorta thing) # Warning: If you use this and end up being kicked out of your favourite # channel for spamming, it's your own damn fool fault! # # Check "Readme" to see how to install this thing. # # The following quote things are added ########################################################################## # What you type What others type (If triggers are ON) ########################################################################## # "/flashquote" - Lists the functions added # "/flashquote_triggers" - Toggles triggers on or off # "/remove_quote_buttons" - Remove quote buttons... # "/add_quote_buttons" - Add quote buttons... # The quotes # "/bofh" !bofh - BOFH quotes # "/wright" !wright - Steven Wright quotes # "/duke" !duke - Duke Nukem quotes # "/disc" !disc - Discworld quotes # "/metaphor" !metaphor - Student metaphors (funny!) # "/fact" !fact - True facts (over 2000!) # "/morbid" !morbid - Morbid facts # ######### # Configuration time ######### # Do you want quote buttons added? Just click to pick a random quote. # $fl_quote_buttons=1; # # Do you want others to be able to trigger quotes remotely? ( # $fl_quote_triggers=1; # # What directory are the quote files at? (Needs a trailing forwardslash..) # $quote_dir = "$ENV{'HOME'}/Application\ Data/X-Chat\ 2/quotes/"; # # End of user config. ############################################################################## # Don't be touching this stuff below here unless yer a genius, k? # # Register stuff and global vars $flquote_version="1.2"; $flquote_toggle="1"; # Toggle quote toggles $flquote_string = ""; Xchat::register( "Flashy's Quotes Script", "$flquote_version", "Famous Quotes", "" ); Xchat::print "Loading Flashy's Quote Script v.$flquote_version ( /flashquote )"; IRC::add_message_handler("PRIVMSG", "watch_quotetriggers"); srand; # Seed random generator $flash_quote = "Init quote"; # Main quote string # Commands IRC::add_command_handler("bofh", "bofh"); IRC::add_command_handler("wright", "wright"); IRC::add_command_handler("duke", "duke"); IRC::add_command_handler("disc", "disc"); IRC::add_command_handler("metaphor","metaphor"); IRC::add_command_handler("fact","fact"); IRC::add_command_handler("morbid","morbid"); IRC::add_command_handler("flashquote", "flashquote"); IRC::add_command_handler("flashquote_triggers", "flashquote_triggers"); IRC::add_command_handler("remove_quote_buttons", "remove_quote_buttons"); IRC::add_command_handler("add_quote_buttons", "add_quote_buttons"); sub bofh { if ($flquote_toggle) { load_quote("bofh"); IRC::command ("/say Bofh Excuse: $flash_quote"); return 1; } } sub disc { if ($flquote_toggle) { load_quote("disc"); IRC::command ("/say Discworld: $flash_quote"); return 1; } } sub duke { if ($flquote_toggle) { load_quote("duke"); IRC::command ("/say Duke Nukem: $flash_quote"); return 1; } } sub wright { if ($flquote_toggle) { load_quote("wright"); IRC::command ("/say Wrightism: $flash_quote"); return 1; } } sub metaphor { if ($flquote_toggle) { load_quote("metaphor"); IRC::command ("/say Metaphor: $flash_quote"); return 1; } } sub fact { if ($flquote_toggle) { load_quote("facts"); IRC::command ("/say Fact: $flash_quote"); return 1; } } sub morbid { if ($flquote_toggle) { load_quote("morbid"); IRC::command ("/say Morbid fact: $flash_quote"); return 1; } } sub flashquote { IRC::print "Flash's Quotes Script V.$flquote_version"; IRC::print "/duke /bofh /wright /disc /metaphor /fact /morbid for local action."; IRC::print "!duke !bofh !wright !disc !metaphor !fact !morbid for remote action."; IRC::print "/flashquote_triggers /add_quote_buttons /remove_quote_buttons"; } sub flashquote_triggers { if ($flquote_toggle) { IRC::print"Flash's Quotes disabled..."; $flquote_toggle=0; } else { IRC::print "Flash's Quotes enabled (/flashquotes )"; $flquote_toggle=1; } } if ($fl_quote_buttons) { # Add masses of buttons! remove_quote_buttons(); # So we don't add a double set add_quote_buttons(); } sub remove_quote_buttons { IRC::command "/delbutton Bofh"; IRC::command "/delbutton Wright"; IRC::command "/delbutton Duke"; IRC::command "/delbutton Disc"; IRC::command "/delbutton Metaphor"; IRC::command "/delbutton Fact"; IRC::command "/delbutton Morbid"; } sub add_quote_buttons { IRC::command "/addbutton Bofh bofh"; IRC::command "/addbutton Wright wright"; IRC::command "/addbutton Duke duke"; IRC::command "/addbutton Disc disc"; IRC::command "/addbutton Metaphor metaphor"; IRC::command "/addbutton Fact fact"; IRC::command "/addbutton Morbid morbid"; } sub load_quote { # Filename my $makestr = "$quote_dir$_[0].txt"; open (IN, "<$makestr") or (Xchat::print"Cannot open that file, wah! (Path: $makestr)"); rand($.) < 1 && ($flash_quote = $_) while ; # Pick random line close(IN); chomp($flash_quote); } sub watch_quotetriggers { if ($fl_quote_triggers) { foreach $line (@_) { $line =~ m/\:(.*?)\!(.*?)\sPRIVMSG\s(.*?)\s\:(.*)?/; $m_nick = $1; $m_send = $2; $m_chan = $3; $m_line = $4; $m_line =~ s/^\s+//; # Remove trailing whitespace $m_line =~ s/\s+$//; if ($m_line =~ m/!disc/gi) { disc(); } if ($m_line =~ m/!bofh/gi) { bofh(); } if ($m_line =~ m/!wright/gi) { wright(); } if ($m_line =~ m/!duke/gi) { duke(); } if ($m_line =~ m/!metaphor/gi) { metaphor(); } if ($m_line =~ m/!fact/gi) { fact(); } if ($m_line =~ m/!morbid/gi) { morbid(); } } } return 0; }