I got fed up with all the !yomma and all the random things as seperate and there is hell of a lot of them on here so i though i'd stop a couple of them with this.
You need to change the directory in line 11 to where you store you're quotes and you cant have any other .txt files in that directory otherwise they will be included...
You need to name the text files what you want them to appear in the menu...
At the moment its for my evolution template but with some minor adjustments it can be changed.....
Code:
sub quotes{<br /> my ($bot,$self, $user, $name, $msg, $color) = @_;<br /><br /> my $reply;<br /> my $str;<br /> my @quotes;<br /> if($msg eq ''){<br /> $reply = "[cool]Which of the following files should i grab a quote for? EG. \"!quotes 4\"\n";<br /><br /> my $num = 0;<br /> opendir(DIR, "./Stuff/machine/");<br /> foreach $file (sort(grep(!/^\./, readdir(DIR)))) {<br /> $file =~ s/\.(.*)$//g;<br /> $num++;<br /> if($num < 10){<br /> $num = "0" . $num if($num !~ /^0/i);<br /> }<br /> $reply .= "\n$num\) $file";<br /> <br /> }<br /> $reply .= "\n\nType the number of the quote you wish to grab....";<br /> $bot->{store}->{users}->{$user}->{callback} = "quotes";<br /> }<br /> <br /><br /> else{<br /> opendir(DIR, "./Stuff/machine/");<br /> my $numa = 0;<br /> foreach $file (sort(grep(!/^\./, readdir(DIR)))) {<br /> $numa++;<br /> $file =~ s/\.(.*)$//g;<br /> if($msg eq $numa || $msg eq "0" . $numa){ <br /> open (FILE, "< ./Stuff/machine/$file.txt") or return "Could not open $file"; <br /> @lines = <FILE>;<br /> close (FILE); <br /> chomp (@lines); <br /> $str = $lines[int(rand(scalar(@lines)))]; <br /> delete $bot->{store}->{users}->{$user}->{callback};<br /> $reply = "Quote from $file:\n$bot->{dot} $str";<br /> }<br /> <br /> last if defined $str;<br /> } <br /> if(!defined $str){<br /> $reply = "[error] Invalid file to get a quote from, Please choose from the list you were provided with!";<br /> }<br /> } <br />return $reply; <br />}<br />{<br /> Category => 'FUNNY',<br /> Description => 'GRAB A RANDOM QUOTE FROM THE QUOTE MACHINE\!',<br /> Usage => '!quotes / !quotes <quote file>',<br />};
and here's me playing with it...
QUOTE(Quotes command in action on my bot)
Daz [www.evobot.net - Back up!] MsgPlus! says: !quotes Evolution [evobot.net] says: Which of the following files should i grab a quote for? EG. "!quotes 4"
01) aol disk 02) church excuses 03) excuses 04) labels 05) palindrome 06) panagram 07) phobia 0 stupid questions 09) work excuses 10) yomama
Type the number of the quote you wish to grab.... Daz [www.evobot.net - Back up!] MsgPlus! says: !quotes 2 Evolution [evobot.net] says: Quote from church excuses: • There aren't any good-looking girls there. Daz [www.evobot.net - Back up!] MsgPlus! says: !quotes 02 Evolution [evobot.net] says: Quote from church excuses: • There are too many hypocrites in church. Daz [www.evobot.net - Back up!] MsgPlus! says: !quotes 4935 Evolution [evobot.net] says: Invalid file to get a quote from, Please choose from the list you were provided with!
:rolleyes: You post the perfectly useable code, but don't attach files, and so apparently it's too much work for somebody to just copy the code to a text file and save it.... so they leave to find another forum where people do post downloadible code. That's funny. _________________ Current Site (2008) http://www.cuvou.com/
He meant the "quote" files...like yomama.txt ect....
Tooks me couple of mins to work out what you were on about :huh: [right][snapback]47443[/snapback][/right]
Ohhh. I thought he meant the Perl files. It's really something that could be interpreted either way. _________________ Current Site (2008) http://www.cuvou.com/