I'm sorry to say, but the reason this doesn't work is that you don't know how to program in Perl.
What is $1? $1 is a special Perl variable most commonly used to grab parts of regular expressions. You should NOT be using it. If $1 is defined, then if( $1 ) will always be true - instead you need to be checking for FL, RL, BL or AL. What version of MSN are you using? &send is not the right method to be using. You also don't pass in a $username variable. You don't put variables inside of quotes unless you need to. And you are trying incorrectly to access the first element of the array @list. You need to use $list[0] to get the first element. But you say you want the whole list, in which case you need to use @list.
Joined: 29 Dec 2004 Posts: 367 Location: Australia
Posted: Sun Jan 30, 2005 7:27 am Post subject:
I know $1 is a special variable.
please take this issue up with clcool.
extracts from the maya help file:
Quote:
More advanced commands
If your command requires a parameter, e.g. a !say command which makes the bot say something. You need to pass extra information to the command (ie. the message you want it to say in this case). In MayaBot any parameter passed to a command will be held in the variable $1.
Below is an example of a say command, you could put the following in say.maya in the public folder:
&send($self, $1, $username);
It sends the variable $1 to the user. Try replacing $1 with "You told me to say $1" (including the quotation marks).
Quote:
When sending messages please use the following syntax:
&send($self, "Message here.", $username);
If you need extra options like colours then you can still add it on the end like follows:
Works for all the other commands i've ever written. Also i do know that i need to check for FL RL BL and AL i just haven;t got to that. Also on changing it to &send($self, "@list", $username); I just recieved a '0'.
Joined: 03 May 2006 Posts: 2292 Location: Colorado
Posted: Sun Jan 30, 2005 7:50 am Post subject:
QUOTE(draget @ Jan 29 2005, 11:27 PM)
I know $1 is a special variable.
please take this issue up with clcool.
extracts from the maya help file:
Quote:
More advanced commands
If your command requires a parameter, e.g. a !say command which makes the bot say something. You need to pass extra information to the command (ie. the message you want it to say in this case). In MayaBot any parameter passed to a command will be held in the variable $1.
Below is an example of a say command, you could put the following in say.maya in the public folder:
&send($self, $1, $username);
It sends the variable $1 to the user. Try replacing $1 with "You told me to say $1" (including the quotation marks).
Quote:
When sending messages please use the following syntax:
&send($self, "Message here.", $username);
If you need extra options like colours then you can still add it on the end like follows:
Works for all the other commands i've ever written. Also i do know that i need to check for FL RL BL and AL i just haven;t got to that. Also on changing it to &send($self, "@list", $username); I just recieved a '0'.
As mojave said. Don't quote the variable. There is no need. In this case you DO need to make the string yourself though. To make a string out of all the elements in an array you can (and probably should) use join.
Code:
<br />my $str = join(',', @list);<br />
That will take all elements of a list and join them with (you guessed it I hope) a comma.
If your list is still empty then it is quite likely that $1 doesn't contain what you think it does. Try printing it out to see what it has and make sure you are actualy getting the list you want. Remember extra spaces or invisible characters in $1 will make it fail to match the contact lists correctly. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com
You shoul NOT be using $1. But most importantly, you are using the method send and that is WRONG - you need to use sendMessage or sendmsg, depending on what version of MSN 2 you are using.
I'm going to assume you got $1 from a regular expression just above your code. In that case, this would be better code:
Code:
my $list = $1;<br />print( "list = '$list'\n" );<br />if ($list =~ /^FL|RL|AL|BL$/ ) {<br />my @list = $self->getContactList($list);<br />my $strl = join(',', @list);<br />&sendMessage($self, $strl);<br />}<br />else { &sendMessage($self, "Please specify your list (FL RL AL BL)"); }
But most importantly, you are using the method send and that is WRONG - you need to use sendMessage or sendmsg, depending on what version of MSN 2 you are using.
Maya 4.0 uses a sub called "send" which does a few things, including logging the message, printing it, and sending it. He said "But when i use it it simply returns a number", which implies that he did actually get it sending. Maya displays an error message if sendmsg or sendMessage are used, as it can't log it and do everything it wants to. _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Some templates, such as White Warrior, add their owner to the FL list so that stats such as their Screenname and status can be shown in statistics. The admins are added too, with the assumption that no more than 50 admins will be around at one time. _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ]