User Control Panel
Advertisements

HELP US, HELP YOU!

list command

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Ideas
View unanswered posts
Author Message
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun Jan 30, 2005 5:28 am    Post subject: Reply with quote

I am making a command that should send the bots contact list.

But when i use it it simply returns a number Sad

any idea's?


Quote:
if ($1) {
my @list = $self->getContactList($1);

&send($self, "@list[0]", $username);
}
else { &send($self, "Please specify your list (FL RL AL BL)", $username); }
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Sun Jan 30, 2005 6:00 am    Post subject: Reply with quote

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.
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun Jan 30, 2005 7:27 am    Post subject: Reply with quote

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:


&send($self, "Message here", $username, Colour => "336633");



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'.
Back to top
eric256
The Keymaker
The Keymaker


Joined: 03 May 2006
Posts: 2292
Location: Colorado
Reputation: 47Reputation: 47Reputation: 47Reputation: 47Reputation: 47

PostPosted: Sun Jan 30, 2005 7:50 am    Post subject: Reply with quote

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:


&send($self, "Message here", $username, Colour => "336633");



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
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun Jan 30, 2005 8:41 am    Post subject: Reply with quote

Thanks eric, (btw i did guess it, i'm not that new to perl)

but it still doesn't appear to work

Quote:
if ($1) {
print "$1";
my @list = $self->getContactList($1);
my $strl = join(',', @list);
&send($self, "$strl", $username);
}
else { &send($self, "Please specify your list (FL RL AL BL)", $username); }


I still get 0, i checked $1 using print and it gave FL which is what is was supposed to contain.
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Sun Jan 30, 2005 6:29 pm    Post subject: Reply with quote

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)"); }


See what you get with that.
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Sun Jan 30, 2005 7:43 pm    Post subject: Reply with quote

QUOTE(Mojave @ Jan 30 2005, 07:29 PM)
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. ]
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Sun Jan 30, 2005 7:55 pm    Post subject: Reply with quote

Oh ok, send is a Maya function. My mistake.
Back to top
Keenie
Almost An Agent
Almost An Agent


Joined: 31 Oct 2003
Posts: 1071

Reputation: 52.4

PostPosted: Mon Jan 31, 2005 1:03 pm    Post subject: Reply with quote

Just out of curiousity, does your FL actually have any contacts on it?
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Mon Jan 31, 2005 1:05 pm    Post subject: Reply with quote

yes
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Mon Jan 31, 2005 1:39 pm    Post subject: Reply with quote

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. ]
Back to top
mattaustin
Sentinel
Sentinel


Joined: 19 Jul 2004
Posts: 556
Location: Los Angeles, CA
Reputation: 50.7
votes: 1

PostPosted: Mon Jan 31, 2005 5:13 pm    Post subject: Reply with quote

should it be

$msn->getContactList(

i would thinnk the lists would be part of the main object not the SB object

_________________
[ matt ]
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Mon Jan 31, 2005 5:22 pm    Post subject: Reply with quote

Oops, how in the &*@% did we all miss that? Razz
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Mon Jan 31, 2005 6:42 pm    Post subject: Reply with quote

Hehe, in the old MSN.pm it was $self, I remember Smile
_________________
~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Tue Feb 01, 2005 1:35 am    Post subject: Reply with quote

aaaah, thanks guys
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Ideas 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