mIRC Home    About    Download    Register    News    Help

Print Thread
#244008 16/01/14 04:40 PM
Joined: Dec 2013
Posts: 779
N
Nillen Offline OP
Hoopy frood
OP Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
I've got a code running thanks to Hixxy, ever so thankful to him <3
However, the code allows me to play a .txt file based off of a skill name, and there are 6 skills which have identical names. So I came up with this code. Can anyone point out what I did wrong?

Code:
on *:text:*:#: {
  if ( %skill [ $+ [ $nick ] ] > 0 ) {
    if ($istok(%am,$1,32)) { msg $chan Anti Mage }
    elseif ($istok(%qop,$1,32)) { msg $chan Queen of Pain }
    elseif ($istok(%ss,$1,32)) { msg $chan Shadow Shaman }
    elseif ($istok(%lion,$1,32)) { msg $chan Lion }
    elseif ($istok(%dp,$1,32)) { msg $chan Death Prophet }
    elseif ($istok(%drow,$1,32)) { msg $chan Drow Ranger }
    else { return }
    unset %skill [ $+ [ $nick ] ]
  }
  else { return }
}


How %skill [ $+ [ $nick ] ] gets set:

Code:
alias -l skilldir { return C:\Users\Nillen\Dropbox\BOT\DotaRelated\Skills\ }

on *:text:!skill *:#:{
  if ($($+(%,floodchan.,$chan),2)) || ($($+(%,flooddota.,$chan),2)) || ($($+(%,flood.,$nick),2)) { return }
  if ($2 == blink) { msg $chan By Blink, did you mean Anti Mage or Queen of Pain? }
  if ($2 == silence) { msg $chan By Silence, did you mean Drow Ranger or Death Prophet? }
  if ($2 == hex) { msg $chan By Hex, did you mean Lion or Shadow Shaman? }
  if (!$isfile($+($skilldir,$remove($2-,$chr(32)),.txt))) { msg $chan Sorry, we have not yet made that skill. If you would like to contribute, please visit https://docs.google.com/spreadsheet/ccc?key=0AhffoErVyWcVdFZWTGxDOVd4OFdaME5xeF9nVk8tamc#gid=0 }
  if (!$isfile($+($skilldir,$remove($2-,$chr(32)),.txt))) { return }
  set -u10 %floodchan. $+ $chan On
  set -u30 %flooddota. $+ $chan On
  set -u60 %flood. $+ $nick On
  set -u30 %skill [ $+ [ $nick ] ] 1
  .play # $qt($+($skilldir,$remove($2-,$chr(32)),.txt)) 0
}

Note that I put a blank .txt file named "blink", "hex" and "silence" in the dir to prevent the bot from running the !$isfile.

The code works fine, but any command I use after this command won't work. I'm highly suspicious of the on *:text: * :
Or maybe even the: if ( %skill [ $+ [ $nick ] ] > 0 )

Example: After this code, I have this:
Code:
 on *:text:!test:#: { msg $chan test } 

It doesn't trigger at all. If I place it above the broken code, it works fine.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
The reurn will be triggered so your unset will not be used.

You have a check here
if ( %skill [ $+ [ $nick ] ] > 0 ) {

That will only trigger if the %skill<nick> have a level higher then 0, so all you need to do is to remove all your returns.
Code:
on *:text:*:#: {
  if ( %skill [ $+ [ $nick ] ] > 0 ) {
       ; Check the value and will go on if more then 0.

    if ($istok(%am,$1,32)) { msg $chan Anti Mage }
    elseif ($istok(%qop,$1,32)) { msg $chan Queen of Pain }
    elseif ($istok(%ss,$1,32)) { msg $chan Shadow Shaman }
    elseif ($istok(%lion,$1,32)) { msg $chan Lion }
    elseif ($istok(%dp,$1,32)) { msg $chan Death Prophet }
    elseif ($istok(%drow,$1,32)) { msg $chan Drow Ranger }
  }
}

You already removing "%skill" with this code

set -u30 %skill [ $+ [ $nick ] ] 1

The code give you 30 seconds to use the variable, and it should be more then enough. I didnt test it.


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Dec 2013
Posts: 779
N
Nillen Offline OP
Hoopy frood
OP Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Same issue. I'll provide a screenshot of my mIRC chat.


Relevant Code

Code:
alias -l skilldir { return C:\Users\Nillen\Dropbox\BOT\DotaRelated\Skills\ }

on *:text:!skill *:#:{
  if ($($+(%,floodchan.,$chan),2)) || ($($+(%,flooddota.,$chan),2)) || ($($+(%,flood.,$nick),2)) { return }
  if ($2 == blink) { msg $chan By Blink, did you mean Anti Mage or Queen of Pain? }
  if ($2 == silence) { msg $chan By Silence, did you mean Drow Ranger or Death Prophet? }
  if ($2 == hex) { msg $chan By Hex, did you mean Lion or Shadow Shaman? }
  if (!$isfile($+($skilldir,$remove($2-,$chr(32)),.txt))) { msg $chan Sorry, we have not yet made that skill. If you would like to contribute, please visit https://docs.google.com/spreadsheet/ccc?key=0AhffoErVyWcVdFZWTGxDOVd4OFdaME5xeF9nVk8tamc#gid=0 }
  if (!$isfile($+($skilldir,$remove($2-,$chr(32)),.txt))) { return }
  set -u10 %floodchan. $+ $chan On
  set -u30 %flooddota. $+ $chan On
  set -u60 %flood. $+ $nick On
  set -u30 %skill [ $+ [ $nick ] ] 1
  .play # $qt($+($skilldir,$remove($2-,$chr(32)),.txt)) 0
}

on *:text:*:#: {
  if ( %skill [ $+ [ $nick ] ] > 0 ) {
    ; Check the value and will go on if more then 0.

    if ($istok(%am,$1,32)) { msg $chan Anti Mage }
    elseif ($istok(%qop,$1,32)) { msg $chan Queen of Pain }
    elseif ($istok(%ss,$1,32)) { msg $chan Shadow Shaman }
    elseif ($istok(%lion,$1,32)) { msg $chan Lion }
    elseif ($istok(%dp,$1,32)) { msg $chan Death Prophet }
    elseif ($istok(%drow,$1,32)) { msg $chan Drow Ranger }
  }
}

on *:text:!test:#: { msg $chan test }

on *:text:!help:#: { msg $chan Visit https://docs.google.com/spreadsheet/ccc?key=0AhffoErVyWcVdFZWTGxDOVd4OFdaME5xeF9nVk8tamc#gid=0 }


Also tested with removing the gap.



Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Try with this part at the bottom of the file. That one will trigger on ALL text events in the channel. on *:text:*:#:{
* tell it to match everything typed in the channel.
Code:
on *:text:*:#: {
  if ( %skill [ $+ [ $nick ] ] > 0 ) {
    ; Check the value and will go on if more then 0.

    if ($istok(%am,$1,32)) { msg $chan Anti Mage }
    elseif ($istok(%qop,$1,32)) { msg $chan Queen of Pain }
    elseif ($istok(%ss,$1,32)) { msg $chan Shadow Shaman }
    elseif ($istok(%lion,$1,32)) { msg $chan Lion }
    elseif ($istok(%dp,$1,32)) { msg $chan Death Prophet }
    elseif ($istok(%drow,$1,32)) { msg $chan Drow Ranger }
  }
}



if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Dec 2013
Posts: 779
N
Nillen Offline OP
Hoopy frood
OP Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Ahh, I see!
That's why my other 2 commands using
Code:
 on *:text:*:#: 

have been broken as well.

So basically, I have to choose only one of these 3 scripts?
(I'll look into and see if I can combine all 3 commands within one later.)

Seems like I won't have a linkban system or a certain word ban system unless I can make a workaround to this.

Thanks for clarifying!


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
This is untested, but you could use somthing like.
Code:
on *:text:*:#: {
  if ($1 == !bla) { do stuff }
  elseif ($1 == !moo) { do stuff }
  elseif ( %skill [ $+ [ $nick ] ] > 0 ) {
   rest of code
  }
}


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Dec 2013
Posts: 779
N
Nillen Offline OP
Hoopy frood
OP Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Dunno if it's going to be that easy.
The other 2 codes are both put into an alias already, which might help. I'm not going to work on this just yet, my priorities lie elsewhere. When I get to it though, this is what I'll be working on:

Code:
 
on @*:text:*:#:linkpost $1-
on @*:action:*:#:linkpost $1-
on @*:notice:*:#:linkpost $1-
alias -l linkpost {
  if ((!%p) && (!$hfind(permit,$nick))) { inc -u4 %p
    var %purge /^!(link\so(n|ff)|(permit))\b/iS
    var %domain com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk|se
    var %link /(?<=^|\s)((?>\S{3,8}:\/\/|w{3}\56)\S+)|\56( $+ %domain $+ )\b/iS
    if ($findtok(%chanon1,#,1,32)) && ($nick(#,$nick,vr)) && ($regex($1-,%link)) {
      timeout # $nick | /mode # -b $nick
      msg # $nick You did not have permission to post a link, please ask a mod to !permit you.
      msg # /timeout $nick 1
    }
    elseif (($regex($1-,%purge)) && ($regml(1) = permit) && ($nick isop #) && ($$2 ison #)) {
      hadd -mz permit $v1 60 | notice $v1 You have 60 seconds to post a link. 
      msg # You now have 60 seconds to post a link!
    }
    elseif (($regml(1) = link on) && ($nick isop #)) {
      goto $iif(!$istok(%chanon1,#,32),a,b) | :a | set %chanon1 $addtok(%chanon,#,32)
      .msg # Link protection is now enabled, please ask a mod to !permit you.
      halt | :b | .msg # $nick $+ , Link protection is already enabled. $&
        $+($chr(2),#,$chr(2)) !
    }
    elseif (($regml(1) = link off) && ($nick isop #)) {
      goto $iif($istok(%chanon1,#,32),c,d) | :c | set %chanon1 $remtok(%chanon,#,1,32)
      .msg # Link protection is now disabled in: $+($chr(2),#)
      halt | :d | .msg # $nick $+ , Link protection is already disabled. $&
      }
  }
}


And:

Code:
on @*:text:*:#: bdwdwkb $1-
on @*:action:*:#: bdwdwkb $1-
on @*:notice:*:#: bdwdwkb $1-
alias -l bdwdwkb {
  if ($regex($1-,$+(/(?<![a-z\d])\Q,$replacecs(%badwords,\E,\\E\Q,$chr(32),\E|\Q),\E(?![a-z\d])/Si))) {
    inc $+(%,$site,#)
    if ($($+(%,$site,#),2) > 2) {
      .msg # /timeout $nick 180
      .msg # $nick has been timed out for 180 seconds due to cursing.
      unset $+(%,$site,#) 
    }
    elseif ($($+(%,$site,#),2) == 2) {
      .msg #  /timeout $nick 60
      .msg # $nick has been timed out for 60 seconds due to cursing.
    }
    else { .msg # $nick $+ , please do not use such language again. }
  }
}


Looking at it right now, it doesn't seem that hard at all, I just don't want to dedicate time to it right now as it isn't a priority.




Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net

Link Copied to Clipboard