mIRC Homepage
Posted By: masterofpuppets Bot problem - 06/04/04 10:33 PM
Ok, this is really annoying now. I am trying to create a bot for my new server (not open to public yet though) and it will just NOW do any commands. The one which I am having most trouble with is the !op command. I test it by opening two clients and using one as the bot with the script loaded. Here is the code:

Code:
on !6:TEXT:!mopop *:#: {
  if ($ulevel == 6) {
  mode $1 +o $2 }
  else {
  msg $nick You don't have the user levels to do that! }
}


Now. When I use the client non-bot client to activate the script, there is no response. I have set my hostname to work with level 6 commands. HELP! The deop command and basicly all commands that require user levels don't respond!
Posted By: landonsandor Re: Bot problem - 06/04/04 11:25 PM
There's a bit of redundancy here:

on !6:TEXT:!mopop *:#: {
if ($ulevel == 6) {
mode $1 +o $2 }
else {
msg $nick You don't have the user levels to do that! }
}


Ok, so you want only user level 6 to be able to trigger this. So let's try a few things. First, how many ON TEXT events do you have of level 6 nature in the same remote file? More than one can cause problems. Also, try some of the code below:


on !6:TEXT:!mopop *:#://mode $1 +o $2

In the above the blue is not needed because on text events CANT be triggered by the script host (the one running the script). Im alos going to assume by your code that the format for said command is !mopop #channelname nickname

Something else you can do is:

on +6:TEXT:!mopop *:#://mode $1 +o $2

The above script because of the + means ONLY level 6 users can trigger said event. Another solution would be (since it appears you want to respond to NON level 6 users with a message):

on *:text:!mopop *:#: {
if ($ulevel == 6) { mode $1 +o $2 }
else { msg $nick You don't have the user levels to do that! }
}

Another idea you could try is:

on @*:text:!mopop *:#: {
if ($ulevel == 6) { mode $1 +o $2 }
else { msg $nick You don't have the user levels to do that! }
}

In the above, the @ means "dont trigger this event UNLESS I (the one running the script) am opped

You COULD (if you wanted to) even combine things from above like this:

on @+6:TEXT:!mopop *:#://mode $1 +o $2

The above means:
1) If I am opped
2) the user triggering the event has level 6 access
3) perform the script


I hope all of this helps you out. Im not the best iwth userlevels, but this is jsut an example and shoudl give you ideas smile
Posted By: masterofpuppets Re: Bot problem - 06/04/04 11:41 PM
Ok, it at least messages me with the You Dont have Levels message. So, tht means I have a problem with me users file.
BUT, it even does it when I have the default user level at 6. Wierd!

Code:
on :TEXT:!request MoPBoT *:#: {
if ($ulevel == 6){ join $3 }
else { msg $nick You don't have the user levels to do that! }

on *:text:!mopop *:#: {
  if ($ulevel == 4) { mode $1 +o $2 }
  else { msg $nick You don't have the user levels to do that! }
}

on *:text:!mopdeop *:#: {
  if ($ulevel == 4) { mode $1 -o $2 }
  else { msg $nick You don't have the user levels to do that! }
}

on *:text:!moptopic *:#: {
  if ($ulevel == 4) { topic $1 $2 }
  else { msg $nick You don't have the user levels to do that! }
}

on *:text:!mopvoice *:#: {
  if ($ulevel == 4) { mode $1 +v $2 }
  else { msg $nick You don't have the user levels to do that! }
}


ALL of those functions have the same result. That stupid User Levels query.
Posted By: landonsandor Re: Bot problem - 07/04/04 12:13 AM
Ok, it COULD be (unless it's just a typo HERE) that you're missing a bracket AND missing a space on the first blue section:

{code}
on :TEXT:!request MoPBoT *:#: {
if ($ulevel == 6) { join $3 }
else { msg $nick You don't have the user levels to do that! }
}
on *:text:!mopop *:#: {
if ($ulevel == 4) { mode $1 +o $2 }
else { msg $nick You don't have the user levels to do that! }
}

on *:text:!mopdeop *:#: {
if ($ulevel == 4) { mode $1 -o $2 }
else { msg $nick You don't have the user levels to do that! }
}

on *:text:!moptopic *:#: {
if ($ulevel == 4) { topic $1 $2 }
else { msg $nick You don't have the user levels to do that! }
}

on *:text:!mopvoice *:#: {
if ($ulevel == 4) { mode $1 +v $2 }
else { msg $nick You don't have the user levels to do that! }
}
[/code]

Also, you could do this (tho I MIGHT screw up the coding a bit so be warned):

Code:
on *:text:*:#: {
  if ($ulevel == 4) {
    if (!mopop == $1) { mode $1 +o $2 }
    if (!mopdeop == $1) { mode $1 -o $2 }
    if (!moptopic == $1) { topic $1 $2 }
    if (!mopvoice == $1) { topic $1 +v $2 }
  }
  if ($ulevel == 6) {
    if (!request*MoPBoT iswm $1-) { join $3 }
  }
  else { msg $nick You don't have the user levels to do that! }
}



The above code would also allow for more comparisons and less event titles making things a bit clearer (possibly) for you and also remove a lot of repetitive code. See if that helpsand if anybody else spots an error in my coding, PLEASE correct it smile
Posted By: landonsandor Re: Bot problem - 07/04/04 12:30 AM
OOOOOOOOO I see another problem here. Try this:

Code:
on *:text:*:#: {
  if ($ulevel == 4) {
    if (!mopop == $1) { mode [color:blue]#[/color] +o $2 }
    if (!mopdeop == $1) { mode [color:blue]#[/color] -o $2 }
    if (!moptopic == $1) { topic [color:blue]#[/color] $2 }
    if (!mopvoice == $1) { mode [color:blue]#[/color] +v $2 }
  }
  if ($ulevel == 6) {
    if (!request*MoPBoT iswm $1-) { join $3 }
  }
  else { msg $nick You don't have the user levels to do that! }
}


Stupid me, how can you set any moes on $1 if $1 is the !trigger?? *smack* (among another typo I found in the voice command) . Also, in the !request MoPBoT part, is $3 the actual channelname?
Posted By: masterofpuppets Re: Bot problem - 07/04/04 12:33 AM
Nope, it didn't work. Totally unresponsive!
Posted By: landonsandor Re: Bot problem - 07/04/04 12:39 AM
Is somebody OTHER than the script hlder testing this? You should be getting SOME KIND of response. Hmm, try this (for error checking):

Code:
on *:text:*:#: {
  echo -a On Text worked
  if ($ulevel == 4) {
    echo -a It recognized user level 4
    if (!mopop == $1) { mode # +o $2 }
    if (!mopdeop == $1) { mode # -o $2 }
    if (!moptopic == $1) { topic # $2 }
    if (!mopvoice == $1) { mode # +v $2 }
  }
  if ($ulevel == 6) {
    echo -a It recognized user level 6
    if (!request*MoPBoT iswm $1-) { join $3 }
  }
  else { msg $nick You don't have the user levels to do that! }
}


if it still doesnt trigger anything, somebody else'll have to help you as Im missing somthing (probably really stupid). Also, what do you normally keep your own (the mirc that runs the scripts) default user level at? Are you trying it at default level as 1? Another number? If at another number, try it at one and see what happens
Posted By: masterofpuppets Re: Bot problem - 07/04/04 12:44 AM
Ok, the ontext worked and it recognised user level 6. But nothing happened.
Posted By: landonsandor Re: Bot problem - 07/04/04 12:49 AM
Ok, for now Im gonna pass this on to somebody else who knows more than I do cause it LOOKS right to me, but Im prolly making a SIMPLE mistake somehwere that Im just not seeing (cause I wrote the code lol). Hopefully one of the better scripters can guide you beyond here smile
Posted By: milosh Re: Bot problem - 07/04/04 12:51 AM
Hi, there. Tested... this works fine for me:
Code:
on *:text:*:#: {
  if ($ulevel == 4) { 
    if (!mopop == $1) { mode # +o $2 } 
    if (!mopdeop == $1) { mode # -o $2 }
    if (!moptopic == $1) { topic # $2 }
    if (!mopvoice == $1) { mode # +v $2 }
  }
  [color:red]elseif[/color] ($ulevel == 6) { 
    if ([color:red]!request MoPBoT == $1-2[/color]) { join $3 }
  } 
  else { msg $nick You don't have the user levels to do that! }
}


landonsandor, you did a good job man, just a little red things. grin
Posted By: landonsandor Re: Bot problem - 07/04/04 12:53 AM
What's your default user level in ALT + R --> Options --> Default Level? Same to you masterofpuppets, what's your default userlevel when you're testing the script? Im not keen on user levels when the script owner has a default level other than 1. BTW milosh, thanks for the backing up, I thought it looked right to me, but again, I coded it so I can sometimes overlook simple issues smile

Posted By: masterofpuppets Re: Bot problem - 07/04/04 12:54 AM
It's still totally defunc.
Posted By: milosh Re: Bot problem - 07/04/04 01:04 AM
landonsandor, def level 1
masterofpuppets, cerate a new script file, enter the landonsandor's code with two corrections (see my post).
Type !mppop <nick> to give <nick> the op, type !request MoPBoT #channel, to make the bot enter the channel.

Oh, give level 4 and 6 to your own nick (the nick who's executing the commands)
Posted By: landonsandor Re: Bot problem - 07/04/04 01:07 AM
Didnt think of the $1-2 thing milosh. I knew about it, just didnt think about it lol Hope that made sence lol Also, i didnt think it would matter if I used elseif vs another if, but hey, if it works, then fine, that's all that matters
Posted By: masterofpuppets Re: Bot problem - 07/04/04 01:12 AM
But the thing is, it DOESN'T work fine. Even with those corrections! Wierd.
Posted By: milosh Re: Bot problem - 07/04/04 01:16 AM
Let's say you put if instead of elseif and you don't have 4 or 6. Then you will not get the error msg (msg $nick You don't have the user levels to do that! will NOT be executed).
It WILL be executed only if you have level 6 and do not type !request MoPBoT. That's why I did elseif to your code. :tongue:
Posted By: milosh Re: Bot problem - 07/04/04 01:18 AM
Can you tell us what are you typing, what are the commands, give an example, like I did: !mopop <nick> will op the <nick> in current channel.
Posted By: masterofpuppets Re: Bot problem - 07/04/04 01:22 AM
I tried without any user levels at all. It was un-responsive.
Posted By: milosh Re: Bot problem - 07/04/04 01:26 AM
Did you made a new script file and post the code in? I hate this short post, but what can man do. smirk
With no level you will get You don't have the user levels to do that!
Posted By: masterofpuppets Re: Bot problem - 07/04/04 01:34 AM
It didn't query me saying about that I don't have the user levels. It didnt even RESPOND! BUT! The request script works fine. The other ones don't.
Posted By: milosh Re: Bot problem - 07/04/04 01:45 AM
Paste your code here, please. The code I gave you should work fine.
Posted By: masterofpuppets Re: Bot problem - 07/04/04 01:46 AM
Code:
on *:text:*:#: {
  echo -a On Text worked
  if ($ulevel == 4) {
    echo -a It recognized user level 4
    if (!mopop == $1) { mode # +o $2 }
    if (!mopdeop == $1) { mode # -o $2 }
    if (!moptopic == $1) { topic # $2 }
    if (!mopvoice == $1) { mode # +v $2 }
  }
  elseif ($ulevel == 6) {
    echo -a It recognized user level 6
    if (!request MoPBoT == $1-2) { join $3 }
  }
  else { msg $nick You don't have the user levels to do that! }
}
Posted By: milosh Re: Bot problem - 07/04/04 02:03 AM
Give yourself level 4. Type in the channel where bot is: !mopop <YourNick>
If he(bot) doesn't give you op, then I don't know what's the problem, it WORKS here.
Also, you should get private msg if you do not have any access...
Posted By: masterofpuppets Re: Bot problem - 07/04/04 02:13 AM
Absoloutly NO response! It is basicly DEAD.
Posted By: Hammer Re: Bot problem - 07/04/04 03:05 AM
/remote on
Posted By: masterofpuppets Re: Bot problem - 07/04/04 03:10 AM
Nope. No difference.
Posted By: MIMP Re: Bot problem - 07/04/04 01:44 PM
Here's a general checklist you and others can use to try and debug remote issues:

1) What version is the bot on? (ideally 6.14 would be nice, any of the 5.X versions or older may have problems with this code.) If you're on an older version please test your code on a new version (in a different directly if you like) to see if the version is the problem or upgrade it outright.

2) Have the bot add you in the remotes using: "/guser <level> <your nick> 3" (without the quotes of course,) and make sure it returns the appropriate line in the active window saying you've been added by address.

3) Move the script/event/aliases in question to the top of the first file in the remote window (you can use the file menu to change order of files if you need to.) This ensures another event in another file won't /halt the event before this one triggers.

4) Double check that the bot's remotes are on, in that client type: /remote and if necessary: /remote on

5) I see you have some debugging code, you may want to add a public message:
Code:
&lt;your on text line&gt; {
  msg $target Event triggered: $script - $scriptline
  &lt;the rest of your code&gt;
}


6) On version 6.14 or later you can use error capturing too:
Code:
&lt;your on text line&gt; {
  msg $target Event triggered: $script - $scriptline
  &lt;the rest of your code&gt;
  :error
  msg $target Event error: $error - $script - $scriptline
}


I hope this helps track down the problem.
Posted By: Zyzzyx26 Re: Bot problem - 08/04/04 12:36 PM
I worked fine here.. i just some little changes:

Code:
on *:text:*:#: {
  if ($ulevel == 4) {
    if (!mopop == $1) { mode  [color:red]$chan[/color] +o $2 }
    [color:red]elseif[/color] (!mopdeop == $1) { mode  [color:red]$chan[/color] -o $2 }
    [color:red]elseif[/color] (!moptopic == $1) { topic  [color:red]$chan[/color] $2 }
    [color:red]elseif[/color] (!mopvoice == $1) { mode  [color:red]$chan[/color] +v $2 } 
  }
  elseif ($ulevel == 6) {
     if (!request MoPBoT == [color:red]$$1 $2[/color]) { join $3 }
  }
  else { msg $nick You don't have the user levels to do that! }
}


The $chan identifier will make sure that the bot makes the mode change in the channel that the event took place (if the bot is in more than 2 chans, it can mix them up)

To activate those command, the string should be: !mopop <nickname>, !mopdeop <nickname> and so on..
and !request MoPBoT #channel

Hope this helps!
Posted By: masterofpuppets Re: Bot problem - 08/04/04 05:06 PM
It works now. I used the /guser to add all of the users and I even made a little login system. So, when the person msgs the bot, and the login is correct, it gusers the person to the levels I have set in the code. If it is incorrect it msgs the user saying "That username and/or password don't exist! You cannot login!". Nice eh. And it works.
Posted By: Zyzzyx26 Re: Bot problem - 08/04/04 05:30 PM
Cool then laugh
© mIRC Discussion Forums