Joined: 29 Dec 2004 Posts: 367 Location: Australia
Posted: Wed Feb 16, 2005 10:19 am Post subject:
I have made another attempt at a command, very basic though! Decided; you guys have helped me so I thinks its time I helped you (thought about motto)!
This one will for every one in 20 messages reply, echoing it yoda style.
To install in Maya 4: put this code anywhere into message.pl
Others: Written for Maya 4 but can easily be converted, just put it in the message sub.
Code:
# yoda --------------------------------------------------------------------------------------<br /># addition for Maya by draget. Credit to Thomashp as it uses his nice service.<br /><br />use LWP::Simple;<br /><br />#get number 20:1 are the odds I use but you may wish to change this<br /><br />my $randtwenty = int(rand(20));<br /><br /><br />#yoda style if it equals 5 (5 was the first number that popped into my head)<br /><br />if($randtwenty == 5) {<br /><br /><br />#get the the yoda translations from Thomashp's nice service<br /><br />my $yodastyle = get("http://www.thomashp.com/bw/yoda.cgi?direct=$msg");<br /><br /><br />#this is the maya send format, for others this will need to be changed<br /><br />&send($self, "$yodastyle (Yoda style)", $username);<br /><br />}
Comments/suggestions? Please no abuse though.
I'll say it again: Credit to Thomashp as it uses his great service.
Extra note: if your bot already has the line use LWP::Simple; at the top of the bot.pl file you won't need to put it again, without it there's one less line of code for the bot to go through.
Joined: 29 Dec 2004 Posts: 367 Location: Australia
Posted: Fri Feb 18, 2005 2:02 pm Post subject:
Code:
# yoda ----------------------------------------------------------------------------------------------------------<br /># addition for Maya by draget. Credit to Thomashp as it usaer his nice service.<br /><br />unless($msg =~ /^%/) {<br /><br />#get number 15:1 are the odds I use but you may wish to change this<br /><br />my $randtwenty = int(rand(20));<br /><br /><br />#yoda style if it equals 5 (5 was the first number that popped into my head)<br /><br />if($randtwenty == 5) {<br /><br /><br />#get the the yoda translations from Thomashp's nice service<br /><br />my $yodastyle = get("http://www.thomashp.com/bw/yoda.cgi?direct=$msg");<br /><br /><br />#this is the maya send format, for others this will need to be changed<br /><br />&send($self, "$yodastyle (Yoda style)", $username);<br /><br />}<br /><br />}
That version will work a bit better as it filters commands.
Code:
<br />unless($msg =~ /^%/) {
You will need to change the % in that line to whatever your command character is.