mIRC Home    About    Download    Register    News    Help

Print Thread
Bot doesn't respond command by private message. #249137 15/11/14 03:50 PM
Joined: Nov 2014
Posts: 149
J
JuanAm Offline OP
Vogon poet
OP Offline
Vogon poet
J
Joined: Nov 2014
Posts: 149
The bot responds the command in the channel, but not by private message.

Code:
on *:text:*:#,?: { 
  if ($strip($1) == .silence) { 
    if ($ulevel < 500) { msg # Acces denied! }
    if ($ulevel >= 500) && ($me isop $chan) && ($2 !ison $chan) {  msg # Error, Cannot find, the $qt($2) nickname is NOT on the channel! }
    if ($ulevel >= 500) && ($me isop $chan) && ($2 ison $chan) {   .ban $chan $2 | .mode $chan -v $2 | .mode $chan -o $2 }
    if ($ulevel >= 500) && ($me !isop $chan) && ($2) {  msg # I haven´t @ in $chan }
  } 
}


Result for command in channel .silence peter:
Quote:
=> ¦ ControlBoT pone modo [+b peter!*grexe@BhgR4f.Boe777.virtual ]
=> ¦ ControlBoT pone modo [-v peter ]


Result for command in private message .silence peter:
In the channel does not shows anything, on the bot status window shows:
Quote:
[13:37] -> *I* haven´t @ in
-
I No such nick - Nick no presente en IRC
-


How I can do to make me accept commands by channel and private message.?
Other commands work for channel and private message, but this no.


Re: Bot doesn't respond command by private message. [Re: JuanAm] #249141 15/11/14 04:58 PM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Try this and tell me if it works
Click to reveal..
Code:
on *:text:*:#: { if (($strip($1) == .silence) && ($2)) silence $2 }
on *:text:*:?: { if (($strip($1) == .silence) && ($left($3,1) == $chr(35))) silence $2 $3 }
alias silence { 
  var %chan $iif($2,$2,#)
  var %dest $iif($2,$2,$nick)
  var %user $1
  if ($ulevel < 500) msg %dest Access denied.
  else {
    if ($me !isop %chan) msg %dest I'm not @ on %chan
    elseif (%user !ison %chan) msg %dest Can't find %user on %chan
    else { 
      .ban %chan %user 
      .mode %chan -v %user
      .mode %chan -o %user 
    }
  }
}
Note that in private messages you're forced to enter a channelname like .silence peter #mychannel
There's no other way to tell which channel it's supposed to use other than looping through channels you have in common with the $nick and then cross-reference with if the user is on the same channel.
Ignore the code in the spoiler. Try using this instead:
Code:
on *:text:*:#: { if (($strip($1) == .silence) && ($2)) noop $silence($2).chan }
on *:text:*:?: { if (($strip($1) == .silence) && ($2)) noop $silence($2).priv }
alias silence { 
  var %chans $comchan($nick,0)
  var %dest $iif($prop == chan,#,$nick)
  var %user $1
  if ($ulevel < 500) msg %dest Access denied
  while (%chans) { 
    var %chan $comchan($nick,%chans) 
    if (%user ison %chan) { 
      if ($me !isop %chan) msg %dest Not @ on %chan
      else { 
        .ban %chan %user 
        .mode %chan -v %user
        .mode %chan -o %user 
      }
    }
    dec %chans
  }
}
Note however that this will ban anyone on all channels (you have in common with the one who wrote it) by the name "Steve" if you type .silence Steve

Last edited by Nillen; 15/11/14 05:18 PM. Reason: Made a loop through all chans

Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Bot doesn't respond command by private message. [Re: Nillen] #249150 15/11/14 07:03 PM
Joined: Nov 2014
Posts: 149
J
JuanAm Offline OP
Vogon poet
OP Offline
Vogon poet
J
Joined: Nov 2014
Posts: 149
Originally Posted By: Nillen
Try this and tell me if it works
Click to reveal..
Code:
on *:text:*:#: { if (($strip($1) == .silence) && ($2)) silence $2 }
on *:text:*:?: { if (($strip($1) == .silence) && ($left($3,1) == $chr(35))) silence $2 $3 }
alias silence { 
  var %chan $iif($2,$2,#)
  var %dest $iif($2,$2,$nick)
  var %user $1
  if ($ulevel < 500) msg %dest Access denied.
  else {
    if ($me !isop %chan) msg %dest I'm not @ on %chan
    elseif (%user !ison %chan) msg %dest Can't find %user on %chan
    else { 
      .ban %chan %user 
      .mode %chan -v %user
      .mode %chan -o %user 
    }
  }
}
Note that in private messages you're forced to enter a channelname like .silence peter #mychannel
There's no other way to tell which channel it's supposed to use other than looping through channels you have in common with the $nick and then cross-reference with if the user is on the same channel.
Ignore the code in the spoiler. Try using this instead:
Code:
on *:text:*:#: { if (($strip($1) == .silence) && ($2)) noop $silence($2).chan }
on *:text:*:?: { if (($strip($1) == .silence) && ($2)) noop $silence($2).priv }
alias silence { 
  var %chans $comchan($nick,0)
  var %dest $iif($prop == chan,#,$nick)
  var %user $1
  if ($ulevel < 500) msg %dest Access denied
  while (%chans) { 
    var %chan $comchan($nick,%chans) 
    if (%user ison %chan) { 
      if ($me !isop %chan) msg %dest Not @ on %chan
      else { 
        .ban %chan %user 
        .mode %chan -v %user
        .mode %chan -o %user 
      }
    }
    dec %chans
  }
}
Note however that this will ban anyone on all channels (you have in common with the one who wrote it) by the name "Steve" if you type .silence Steve


Works en private message.
But it is necessary to ban at nick in all channels?
You can not ban only in one channel?

For example: .silence Steve #general

Re: Bot doesn't respond command by private message. [Re: JuanAm] #249153 15/11/14 07:47 PM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
If you want that, then use the code I used in the spoiler. It does exactly what you requested.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Bot doesn't respond command by private message. [Re: Nillen] #249157 15/11/14 09:24 PM
Joined: Nov 2014
Posts: 149
J
JuanAm Offline OP
Vogon poet
OP Offline
Vogon poet
J
Joined: Nov 2014
Posts: 149
Both codes work perfect !!! Thank you !!! smile

Now I want to ask you a few things to learn:

Code of the spoiler:
Code:
var %chan $iif($2,$2,#)
var %dest $iif($2,$2,$nick)

How work $iif command?

Another code:
Code:
noop silence($2).chan
noop silence($2).priv
var %dest $iif($prop == chan,#,$nick)


How these lines work?

Thank you smile


Re: Bot doesn't respond command by private message. [Re: JuanAm] #249158 15/11/14 10:06 PM
Joined: Jul 2006
Posts: 3,588
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,588
$iif is an inline condition.
Code:
var %a
if ($1 == 1) %a = cow
else %a = dog
echo -a %a is an animal

;is equivalent to

echo -a $iif($1 == 1,cow,dog) is an animal
$iif(condition,true,false) - if the condition is true, it returns the 'true' parameter, otherwise returns the 'false' one


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Bot doesn't respond command by private message. [Re: Wims] #249165 16/11/14 05:51 AM
Joined: Nov 2014
Posts: 149
J
JuanAm Offline OP
Vogon poet
OP Offline
Vogon poet
J
Joined: Nov 2014
Posts: 149
Originally Posted By: Wims
$iif is an inline condition.
Code:
var %a
if ($1 == 1) %a = cow
else %a = dog
echo -a %a is an animal

;is equivalent to

echo -a $iif($1 == 1,cow,dog) is an animal
$iif(condition,true,false) - if the condition is true, it returns the 'true' parameter, otherwise returns the 'false' one


I had already looked for that information, but I do not understand how it works in the Nillen code.

There are two conditions equal "$2" and both variables stored a channel.

Thanks Wims, I'll wait to see if I Nillen explained in more detail, the operation of each of these lines.


Re: Bot doesn't respond command by private message. [Re: JuanAm] #249172 16/11/14 11:02 AM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
It's exactly what Wims said. var %dest $iif($prop == chan,#,$nick) means exactly:
if ($prop == chan) { var %dest # }
else { var %dest $nick }

;Further explained: $prop is the value you enter ($silence().PROP) If the prop is chan (if the CONDITION is true), use the true value "#", if the prop isn't chan, use the false value "$nick".

As to why $iif is used. It makes it simnpler and nicer to look at, and faster to type.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Bot doesn't respond command by private message. [Re: Nillen] #249175 16/11/14 12:11 PM
Joined: Nov 2014
Posts: 149
J
JuanAm Offline OP
Vogon poet
OP Offline
Vogon poet
J
Joined: Nov 2014
Posts: 149
Originally Posted By: Nillen
It's exactly what Wims said. var %dest $iif($prop == chan,#,$nick) means exactly:
if ($prop == chan) { var %dest # }
else { var %dest $nick }

;Further explained: $prop is the value you enter ($silence().PROP) If the prop is chan (if the CONDITION is true), use the true value "#", if the prop isn't chan, use the false value "$nick".

As to why $iif is used. It makes it simnpler and nicer to look at, and faster to type.


I do not understand the use of own identifiers, please bear with me.
In this code:
Code:
on *:text:*:#: { if (($strip($1) == .silence) && ($2))  silence $2 }
on *:text:*:?: { if (($strip($1) == .silence) && ($left($3,1) == $chr(35))) silence $2 $3 }


$1 = .silence
$2 = nick
$3 = chanell

But in the alias change the value of $ 1?

Code:
 var% user $ 1



Another thing:
Code:
var %chan $iif($2, $2, #) means:
If ($2) { var %chan = $2 }
else { var %chan = # }


But, $2 always will be (is the nick żnot?)

Do not understand how &#8203;&#8203;change values $ 1, $ 2, $ 3 Event On Text - alias.

Thanks and sorry for so many questions. blush


Re: Bot doesn't respond command by private message. [Re: JuanAm] #249177 16/11/14 12:28 PM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
In the on text event:
.silence = $1
nick = $2
channel = $3

What we're telling it to do: silence $2 $3

In the alias event:
.silence IS NOT sent over. (What we sent over is "silence" which triggers the alias)
nick = $1
channel = $2

Basically since "silence" is the handle to trigger the alias, it's not treated as $1.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Bot doesn't respond command by private message. [Re: Nillen] #249178 16/11/14 02:19 PM
Joined: Nov 2014
Posts: 149
J
JuanAm Offline OP
Vogon poet
OP Offline
Vogon poet
J
Joined: Nov 2014
Posts: 149
Originally Posted By: Nillen
In the on text event:
.silence = $1
nick = $2
channel = $3

What we're telling it to do: silence $2 $3

In the alias event:
.silence IS NOT sent over. (What we sent over is "silence" which triggers the alias)
nick = $1
channel = $2

Basically since "silence" is the handle to trigger the alias, it's not treated as $1.


Thanks for the explanation.
The code of the clock, you could understand what I want?