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/
Joined: 03 May 2006 Posts: 2292 Location: Colorado
Posted: Sun Feb 29, 2004 6:43 am Post subject:
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
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?
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