mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2016
Posts: 8
D
DML1783 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Mar 2016
Posts: 8
Quote:
on *:join:*:#:{
/timer $+ $nick 1 %idle /kick # $nick Idle time is %idle seconds
}
on *:text:*:#:{
/timer $+ $nick off | /timer $+ $nick 1 %idle /kick $chan $nick Idle time is %idle seconds
}

alias idle { /set %idle $1 }


So its working perfect if a user joins the room, and says soemething and then goes idle...

I need it to kick if a user joins a room and never says something...

Please help?

Joined: Apr 2004
Posts: 73
Z
Babel fish
Offline
Babel fish
Z
Joined: Apr 2004
Posts: 73
This might have a bug or two but I think it should work

Code:
on !@*:join:#: { resetIdleKick $chan $nick }
on !@*:text:*:#: { resetIdleKick $chan $nick }
on !@*:action:*:#: { resetIdleKick $chan $nick }

alias -l resetIdleKick {
  var %thisTimer = $+(idleKick,$1,$2)
  if ($timer(%thisTimer)) { $+(.timer,%thisTimer) off }
  else { $+(.timer,%thisTimer) 1 %idleKick idleKick $1 $2 }
}

alias -l idleKick {
  ban -u5 $1 $2 2
  kick $1 $2 Idle time exceeded %idleKick seconds
}

alias setIdleKick { set %idleKick $1 }



/tokenize 32 $gettok($1-,1-,32)
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
I don't see any obvious bug (though you don't need to stop a timer before recreating one with the same name, it would just overwrite), but there is the typical exploit with timer: you are passing unknown content to timer, $chan can be exploited and even $nick on some weird network can be, more informations here

Code:
 else { $+(.timer,%thisTimer) 1 %idleKick idleKick $unsafe($1) $unsafe($2) }
should be used ($unsafe($1 $2) or $unsafe($1-2) is also good here)

Last edited by Wims; 01/03/18 07:22 PM. Reason: actual solution

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2004
Posts: 73
Z
Babel fish
Offline
Babel fish
Z
Joined: Apr 2004
Posts: 73
Ah, okay, thanks! It's been a while since I've used timers. Thanks also for the info on these exploits.

Revised code for the lazy:

Code:
on !@*:join:#: { resetIdleKick $chan $nick }
on !@*:text:*:#: { resetIdleKick $chan $nick }
on !@*:action:*:#: { resetIdleKick $chan $nick }

alias -l resetIdleKick { $+(.timer,idleKick,$1,$2) 1 %idleKick idleKick $unsafe($1-2) }

alias -l idleKick { if ($2 ison $1) { ban -ku5 $1 $2 2 Idle time exceeded %idleKick seconds } }

alias setIdleKick { set %idleKick $1 }

Last edited by Zelda4ever32; 01/03/18 09:32 PM. Reason: per Wims' suggestion

/tokenize 32 $gettok($1-,1-,32)
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Another small thing, /ban has a -k switch to kick the user, no need to use /kick here!


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2004
Posts: 73
Z
Babel fish
Offline
Babel fish
Z
Joined: Apr 2004
Posts: 73
Ah, looks like the documentation needs to get updated, I wasn't sure if it was possible or not. The help file documentation for /ban doesn't mention the kick message so I just wrote a new line instead of bothering to check to see if it was possible. Thanks again smile


/tokenize 32 $gettok($1-,1-,32)
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
The help file is old and in too many places, lacking informations, that's why we started a wiki about the mIRC scripting language, which not only document everything (few things are missing and it's up to date to 7.52), I recommend anyone who is looking for a better help about mIRC scripting to look at the wiki, not only it documents all commands and identifiers, it also has articles about things like hash table, if statement, binary variable, pretty much any main category for the language, the aim it also to document everything that's not documented that can be useful as well as even the tiniest quirks.

Unsurprisingly, the /ban page already had this very well documented


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2002
Posts: 5,420
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,420
Thanks, the [kick message] description has been added to the help file for /ban -k. That said, it is amazing how up-to-date the help file is considering that mIRC has been in development for over twenty years and has gone through such a huge number of changes. I will occasionally forget to add some changes to it and over a period of decades these can add up. There is a thread regarding Missing documentation that I follow, so if you find anything else missing, you can post it there.


Link Copied to Clipboard