User Control Panel
Advertisements

HELP US, HELP YOU!

!fortune for mayabot

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Commands
View unanswered posts
Author Message
kayleighthorpe
Newbie
Newbie


Joined: 21 Aug 2005
Posts: 3

Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7

PostPosted: Sun Aug 21, 2005 6:22 pm    Post subject: !fortune for mayabot Reply with quote

A simple code that will get your bot to fortune tell:



@names=("You will be rich", "You will find money today", "you will die soon", "Future looks hazy, ask again later", "Your going to have a baby", "You will hurt yourself in a car accident", "You will take a journey somewhere", "You will find true love", "You will have your heart broken this week", "You will recieve a great shock tomorrow", "Your friend will reveal she is pregnant", "You will die in a terrorist bombing", "You will win a contest on TV", "You will lose something special") ;

$random = rand 7 ;

&send($self, @names[$random], $username);


You can add fortunes, change them, whatever, enjoy!

Oh yes, does anyone know a working !chat !horoscope or !shutup command for Maya? If so I would be really greatful to hear it!

Thanks!
Back to top
mat007
Almost An Agent
Almost An Agent


Joined: 12 Jan 2004
Posts: 1375

Reputation: 15.8Reputation: 15.8
votes: 2

PostPosted: Sun Aug 21, 2005 6:38 pm    Post subject: Reply with quote

All those commands are on this site posted by users

Im sure with a bit of using your brain you can figure out how to convert them Smile
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Sun Aug 21, 2005 8:00 pm    Post subject: Reply with quote

Quote:
@names=("You will be rich", "You will find money today", "you will die soon", "Future looks hazy, ask again later", "Your going to have a baby", "You will hurt yourself in a car accident", "You will take a journey somewhere", "You will find true love", "You will have your heart broken this week", "You will recieve a great shock tomorrow", "Your friend will reveal she is pregnant", "You will die in a terrorist bombing", "You will win a contest on TV", "You will lose something special") ;

$random = rand 7 ;

&send($self, @names[$random], $username);


I wouldn't use that code for a number of reasons. You made @names and $random globals, instead make them local variables with my. rand returns a fractional value and while Perl is smart enough to use just the integer part in a list index, it's bad programming style. Use int to make sure the value is an integer. @names[$random] is incorrect usage of a list to get an item from the list. You need to use $names[$random] to get a scalar value. Finally, your use of &send( $self... means you're probably using an older version of MSN.pm, which are buggy. Get a newer one.

Also, as mat007 mentioned, all those commands as well as fortune itself have been written a dozen times, you should just use an existing one that is written properly instead of posting your own code looking for recognition.
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Tue Aug 23, 2005 11:30 pm    Post subject: Re: !fortune for mayabot Reply with quote

kayleighthorpe wrote:
@names=("You will be rich", "You will find money today", "you will die soon", "Future looks hazy, ask again later", "Your going to have a baby", "You will hurt yourself in a car accident", "You will take a journey somewhere", "You will find true love", "You will have your heart broken this week", "You will recieve a great shock tomorrow", "Your friend will reveal she is pregnant", "You will die in a terrorist bombing", "You will win a contest on TV", "You will lose something special") ;

$random = rand 7 ;


Also, you are picking a random number out of 7 (giving you a range of 0 to 6) when there are more than 7 items in your array. Every item past 7 would never be used. Instead you can get a random number out of the array's length:

Code:
my $random = int(rand(scalar(@names)));


Or better yet, get a random value right away instead of getting a number first:

Code:
my $answer = $names [ int(rand(scalar(@names))) ];

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Commands All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group