User Control Panel
Advertisements

HELP US, HELP YOU!

Socket controls... kill, join, list, shout

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Help
View unanswered posts
Author Message
Skot
Newbie
Newbie


Joined: 25 Feb 2004
Posts: 29

Reputation: 27.3Reputation: 27.3Reputation: 27.3

PostPosted: Sat Feb 28, 2004 1:53 pm    Post subject: Reply with quote

I'm using the MayaBot template and none of these commands ive found on botdepot work on it.
Back to top
dan0211
Not Yet a God
Not Yet a God


Joined: 23 Dec 2003
Posts: 395

Reputation: 37.8Reputation: 37.8Reputation: 37.8Reputation: 37.8

PostPosted: Sat Feb 28, 2004 5:05 pm    Post subject: Reply with quote

Code:
 if ($msg =~ /^convos/i) {<br />            my $id;<br />     print $msn->GetMaster->{Handle} . "\n";<br /><br />     $reply = "Open Sockets:\n\n";<br />     foreach $id (keys %{$msn->GetMaster->{Socks}}) {<br />      next unless defined $msn->GetMaster->{Socks}->{$id} && $msn->GetMaster->{Socks}->{$id}->{Type} eq 'SB';<br />      $reply .= "$id=" . join (", ", keys %{$msn->GetMaster->{Socks}->{$id}->{Buddies}}) . "\n";<br />     }<br />     $self->sendmsg("$reply");<br />     }<br />                 <br />        if ($msg =~ /^kill (.*)$/) {<br />            $msg = $1;<br />     if ($msg) {<br />      # Kill the socket.<br />      $self->GetMaster->{Socks}->{$msg}->sendraw("OUT\*lazy*\n");<br /><br />      $reply = "I have killed socket $msg.";<br />     }<br />     else {<br />      $reply = "You must provide a socket number.\n\n"<br />       . "#kill [ID]";<br />     }<br />     $self->sendmsg("$reply");<br />     }<br />     <br />          if ($msg =~ /^join (.*)/i) {<br />  $reply = "Could not join socket." unless exists $self->GetMaster->{Socks}->{$1};<br />  $self->GetMaster->{Socks}->{$1}->invite($username);<br />  $reply = "Joining socket $1...";<br />  $self->GetMaster->{Socks}->{$1}->sendmsg("$username has joined us...");<br />  &send($self,"$reply", $username);<br />  goto end;<br />}
Back to top
Skot
Newbie
Newbie


Joined: 25 Feb 2004
Posts: 29

Reputation: 27.3Reputation: 27.3Reputation: 27.3

PostPosted: Sun Feb 29, 2004 2:53 am    Post subject: Reply with quote

A thousand thankyous dear friend.
Back to top
Cer
Upgraded Agent
Upgraded Agent


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

PostPosted: Sun Feb 29, 2004 5:18 am    Post subject: Reply with quote

QUOTE(dan0211 @ Feb 28 2004, 12:05 PM)
Code:
 if ($msg =~ /^convos/i) {<br />            my $id;<br />     print $msn->GetMaster->{Handle} . "\n";<br /><br />     $reply = "Open Sockets:\n\n";<br />     foreach $id (keys %{$msn->GetMaster->{Socks}}) {<br />      next unless defined $msn->GetMaster->{Socks}->{$id} && $msn->GetMaster->{Socks}->{$id}->{Type} eq 'SB';<br />      $reply .= "$id=" . join (", ", keys %{$msn->GetMaster->{Socks}->{$id}->{Buddies}}) . "\n";<br />     }<br />     $self->sendmsg("$reply");<br />     }<br />                 <br />        if ($msg =~ /^kill (.*)$/) {<br />            $msg = $1;<br />     if ($msg) {<br />      # Kill the socket.<br />      $self->GetMaster->{Socks}->{$msg}->sendraw("OUT\*lazy*\n");<br /><br />      $reply = "I have killed socket $msg.";<br />     }<br />     else {<br />      $reply = "You must provide a socket number.\n\n"<br />       . "#kill [ID]";<br />     }<br />     $self->sendmsg("$reply");<br />     }<br />     <br />          if ($msg =~ /^join (.*)/i) {<br />  $reply = "Could not join socket." unless exists $self->GetMaster->{Socks}->{$1};<br />  $self->GetMaster->{Socks}->{$1}->invite($username);<br />  $reply = "Joining socket $1...";<br />  $self->GetMaster->{Socks}->{$1}->sendmsg("$username has joined us...");<br />  &send($self,"$reply", $username);<br />  goto end;<br />}

That's horrible. First you check if the message *starts with* "convos" and then later check if the message *starts with* kill, without even removing the "convos" part of it first. Can a message start with two things at once? No.

And the IF statement for ^join (again, it cannot start with 'join' if it starts with 'convos'), you begin the IF statement but don't end it with a }. You have a } at the end of the code, but that would close the thing at the top (if starts with "convos"), but not the other one.

Make sure your code works before posting it. If I made a mistake somewhere it would also be due to your poor indenting of code or bad programming style.

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
eric256
The Keymaker
The Keymaker


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

PostPosted: Sun Feb 29, 2004 6:43 am    Post subject: Reply with quote

Close Cer/Nate/Kirsle but in fact this is just a case of horrible looking code. I don't know if it works but all his { and } match up, he just failed to indent them in any way that looks like it would work. Use of several if's instead of a single if and then elsif's is annoying, but perfectly legal.

So the code may be ugly and inneficient, its still legal code, wether it works for not is for someone else to find out.

_________________
Eric256
Proud previous owner and current admin of Bot-depot.com
Back to top
Skot
Newbie
Newbie


Joined: 25 Feb 2004
Posts: 29

Reputation: 27.3Reputation: 27.3Reputation: 27.3

PostPosted: Mon Mar 01, 2004 5:58 pm    Post subject: Reply with quote

Yeah it does work, but when you use the join command, it says the text in the socket before the moderator is invited, so they have to wait for the user to type something or you a shout command to open up the window :\

How can i get it to send the "Welcome to socket number 8 Skot, My owner" when ive been invited and not before?
Back to top
dan0211
Not Yet a God
Not Yet a God


Joined: 23 Dec 2003
Posts: 395

Reputation: 37.8Reputation: 37.8Reputation: 37.8Reputation: 37.8

PostPosted: Tue Mar 02, 2004 7:24 pm    Post subject: Reply with quote

QUOTE(Cer @ Feb 28 2004, 09:18 PM)
QUOTE(dan0211 @ Feb 28 2004, 12:05 PM)
Code:
 if ($msg =~ /^convos/i) {<br />            my $id;<br />     print $msn->GetMaster->{Handle} . "\n";<br /><br />     $reply = "Open Sockets:\n\n";<br />     foreach $id (keys %{$msn->GetMaster->{Socks}}) {<br />      next unless defined $msn->GetMaster->{Socks}->{$id} && $msn->GetMaster->{Socks}->{$id}->{Type} eq 'SB';<br />      $reply .= "$id=" . join (", ", keys %{$msn->GetMaster->{Socks}->{$id}->{Buddies}}) . "\n";<br />     }<br />     $self->sendmsg("$reply");<br />     }<br />                 <br />        if ($msg =~ /^kill (.*)$/) {<br />            $msg = $1;<br />     if ($msg) {<br />      # Kill the socket.<br />      $self->GetMaster->{Socks}->{$msg}->sendraw("OUT\*lazy*\n");<br /><br />      $reply = "I have killed socket $msg.";<br />     }<br />     else {<br />      $reply = "You must provide a socket number.\n\n"<br />       . "#kill [ID]";<br />     }<br />     $self->sendmsg("$reply");<br />     }<br />     <br />          if ($msg =~ /^join (.*)/i) {<br />  $reply = "Could not join socket." unless exists $self->GetMaster->{Socks}->{$1};<br />  $self->GetMaster->{Socks}->{$1}->invite($username);<br />  $reply = "Joining socket $1...";<br />  $self->GetMaster->{Socks}->{$1}->sendmsg("$username has joined us...");<br />  &send($self,"$reply", $username);<br />  goto end;<br />}

That's horrible. First you check if the message *starts with* "convos" and then later check if the message *starts with* kill, without even removing the "convos" part of it first. Can a message start with two things at once? No.

And the IF statement for ^join (again, it cannot start with 'join' if it starts with 'convos'), you begin the IF statement but don't end it with a }. You have a } at the end of the code, but that would close the thing at the top (if starts with "convos"), but not the other one.

Make sure your code works before posting it. If I made a mistake somewhere it would also be due to your poor indenting of code or bad programming style.

Look, this is how MayaBot works. in may, you would call it by typing
!convos
!kill
!join

Maybe you should have a look at it sometime <_<
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Help 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