mIRC Home    About    Download    Register    News    Help

Print Thread
#157909 30/08/06 08:03 AM
Joined: Jan 2006
Posts: 22
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2006
Posts: 22
Yes I cant find it. I've searched,
yes I dont have a clue as to how to write it.
yes I am a noob
I did find something I thought would work not even close.

what I would like to have is a script that would just run in the background in the remotes section of my mirc of the channel I am opped on and scan the user list maybe every 5 minutes or so (or set to whatever time I wish). and check them agasint a txt file of bad channels I have, then ban and kick them if they are one of those bad channels.

so if anyone out there would like to help me, you would be greatly thanked, to write a script that would do this. I would be greatfull..

thank you in advance for reading and maybe helping

Lord_Night

#157910 30/08/06 09:03 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Use this at your own risk. Setting the time for too low a number may cause overlaps and/or severe lag times (also dependent on the number of people in the room). Only the person/bot running the code has been exempted. If you'd like others to be exempted, let me know how they are designated,. and I'll see what I can do.
Code automatically checks when a person joins the channel, as well as via the timer.

Code:
 on *:join:#:{
  set %nick $nick
  set %chan $chan
  bad.channels $nick
}
menu channel,nicklist {
  Bad Channels
  .Scan Now : bad.channels $chan
  .Set Timed scan : {
    set %bad.channel.scan $$?="Time between scans"
    if (%bad.channel.scan !isnum) && ($chr(58) !isin $v1) {
      echo 4 -a Invalid Format
      echo 12 -a Number of minutes or hh:mm:ss format only
      unset %bad.channel.scan
    }
    else {
      set %bad.channel.scan $iif(%bad.channel.scan isnum,$v1,$iif($chr(58) isin %bad.channel.scan,$duration($v1)))
    }
    if %bad.channel.scan {
      .timerbad.channel 0 %bad.channel.scan bad.channels $chan
    }
  }
}
alias bad.channels {
  if $1 == %nick {
    .enable #bad.channels.whois
    .whois $1
  }
  else {
    unset %nick
    var %a = 1
    while %a <= $nick($1,0) && ($nick($1,%a) != $me) {
      .enable #bad.channels.whois
      .whois $nick($1,%a)
      inc %a
    }
  }
}
#bad.channels.whois off
raw 318:*:{
  .disable #bad.channels.whois
  haltdef
}
raw 319:*:{
  var %b = 1, %c = $numtok($3-,32)
  while %b <= %c {
    if $read(bad_channels.txt,w,$gettok($3-,%b,32)) && ($me isop %chan) {
      .ban -k %chan $2 Bad Channels detected
    }
    inc %b
  }
}
#bad.channels.whois end
 

#157911 30/08/06 12:08 PM
Joined: Jan 2006
Posts: 22
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2006
Posts: 22
Ok so far it looks like it working.
I put the bad_channels.txt in the main directory where the mirc.exe is it should read it from there. I hope.

ive listed the channels on seperate lines kinda like
#channel 1
#channel 2

etc.
Thank You so much I hope it all works and will let you know..

Last edited by LordNight; 30/08/06 12:11 PM.
#157912 31/08/06 04:13 AM
Joined: Dec 2002
Posts: 10
A
Pikka bird
Offline
Pikka bird
A
Joined: Dec 2002
Posts: 10
will that snippet ban exact channel names or channel names that are simailar like, #xxxworld but not #xxxworld-chat etc.?
Also will it ban Ops, voiced and regular users or does it matter?
I think it would be much better if I could specify which mode to ban.

#157913 31/08/06 05:13 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Exact channel names, and any user except for the person/bot running the script.

The script could be modified to account for any or all of the items you've mentioned.

If you'll specify what you want:
examples: all channels that start with the name listed or only exact channel matches
only regular users are banned, voiced and regular, just voiced, half-ops exempt, ops exempt

Do you want to specify the ban mode on a ban by ban basis, or a single setting for all bans?

The more specific the details regarding what you want, the easier it is for me to write.

#157914 31/08/06 05:32 AM
Joined: Dec 2002
Posts: 10
A
Pikka bird
Offline
Pikka bird
A
Joined: Dec 2002
Posts: 10
Here's what I'm thinking:
Ban exact channel names.
Ban whatever user mode I choose via a input dialog, I may want to ban reg. plus voiced but not ops or any combo there after.
Have a set timer say every 30 minutes the script will auto-scan chan for banned channels or I may do the scan manually.
Ban Mode I find that 2 works the best.

#157915 31/08/06 06:07 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Parts of this are untested, but it should work per your request.
Code:
 on @!*:join:#:{
  set %nick $nick
  set %chan $chan
  bad.channels $nick
}

menu channel,nicklist {
  Bad Channels
  .Scan Now : bad.channels $chan
  .Set exemptions : set $+(%,exempt,.,$cid,.,$chan) $$?="Exemption status (o = ops, h = half-ops, v = voice, r = regular) Multiple letters will work"
  .Set Timed scan : {
    set bad.channel.scan $$?="Time between scans"
    if (%bad.channel.scan !isnum) && ($chr(58) !isin $v1) {
      echo 4 -a Invalid Format
      echo 12 -a Number of minutes or hh:mm:ss format only
      unset %bad.channel.scan
    }
    else {
      set $+(%,bad.channel.scan,.,$cid,.,$chan) $iif(%bad.channel.scan isnum,$v1,$iif($chr(58) isin %bad.channel.scan,$duration($v1)))
    }
    if $($+(%,bad.channel.scan,.,$cid,.,$chan),2) {
      .timerbad.channel 0 $($+(%,bad.channel.scan,.,$cid,.,$chan),2) bad.channels $chan
    }
  }
}

alias bad.channels {
  if $1 == %nick {
    .enable #bad.channels.whois
    .whois $1
  }
  else {
    unset %nick
    var %a = 1
    while %a <= $nick($1,0) && ($nick($1,%a) != $me) && !$nick($1,%a,$($+(%,exempt,.,$cid,.,$chan),2)) {
      .enable #bad.channels.whois
      .whois $nick($1,%a)
      inc %a
    }
  }
}

#bad.channels.whois off
raw 318:*:{
  .disable #bad.channels.whois
  haltdef
}
raw 319:*:{
  var %b = 1, %c = $numtok($3-,32)
  while %b <= %c {
    if $read(bad_channels.txt,w,$gettok($3-,%b,32)) && ($me isop %chan) {
      .ban -k %chan $2 2 Bad Channels detected
    }
    inc %b
  }
}
#bad.channels.whois end
 

Manual scan was available in the original code, so I didn't need to add it. Timed scan is settable by you using the Set Timed Scan option. Exemption status has been added, and will take an entry from you. o, h, v, and r are valid entries, but there's no verification that some other character hasn't been entered.
You can use something like oh (for ops and half-ops)

Ban mode 2 has been hard-coded.
Timings and exemptions are tracked on a channel by channel basis, and is multi-network ready.

#157916 01/09/06 10:09 AM
Joined: Jan 2006
Posts: 22
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2006
Posts: 22
hi Russel

wow talk about lag and yes you warned me on that.. thanks I was prepared for it then..

now I dont wanna seem like a leech. but. couple things if I may ask.
1. I dont need it to scan on join bot does that.
2. the bad_channels.txt has to be in the main directory right?

thanks for your time. you ahve been more then helpful to me on this.

Lord_Night
P.S. I copied your new one and put it in place of the old one. BUT it keeps savign it as user. not in the remote tab but on the user tab. am i doign something wrong

Last edited by LordNight; 01/09/06 10:15 AM.
#157917 01/09/06 10:22 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
1) Remove the ON JOIN event

2) No, it doesn't, but that is the easiest place. If you put it somewhere else, you'll have to specify the full directory with the file name in the code, remembering that if there are any spaces in the directory name (and/or any of the sub-directories), you'll have to enclose the entire thing in quotation marks.

3) You must be, however, I'm at a loss to explain it, as there is nothing in the code that references the User tab.

4) Worked on this code, for a dialog/remote based access, however, it has been reported to crash a system running Win2K.
I don't have a Win2k system, so I'm unable to test it with that configuration. I did run it for about 4 hours on a P4 1.7Ghz with 512M ram and Windows XP Home, without any difficulties.

Code:
 ;Dialog items
dialog bad_channel {
  title "Bad Channel Ban"
  size -1 -1 149 125
  option dbu
  text "Bad Channels", 1, 10 10 60 8, center
  combo 2, 10 20 60 100, drop sort size edit
  box "Exemptions", 3, 73 6 37 40
  check "Ops", 4, 75 13 30 8
  check "Half-Ops", 5, 75 21 30 8
  check "Voice", 6, 75 29 30 8
  check "Regular", 7, 75 37 30 8
  check "Timed Check", 8, 73 50 40 8
  edit "", 9, 73 60 40 10
  button "Check Now", 10, 115 10 30 10
  button "Apply", 11, 115 20 30 10
  button "Close", 12, 115 30 30 10, cancel
}
on *:dialog:bad_channel:init:*:{
  channels
}
on *:dialog:bad_channel:sclick:2:{
  var %chan = $did(2).seltext, %timed = $gettok($hget(bad_channel,%chan),1,32), %exempt = $gettok($hget(bad_channel,%chan),2,32)
  did $iif(%timed,-c,-u) $dname 8
  did $iif(%timed,-evra,-bhr) $dname 9 $duration(%timed,3)
  did $iif($mid(%exempt,1,1) == o,-c,-u) $dname 4
  did $iif($mid(%exempt,2,1) == h,-c,-u) $dname 5
  did $iif($mid(%exempt,3,1) == v,-c,-u) $dname 6
  did $iif($mid(%exempt,4,1) == r,-c,-u) $dname 7
}
on *:dialog:bad_channel:dclick:2:{
  .hdel bad_channel $did(2).seltext
  .channels
}
on *:dialog:bad_channel:sclick:8:{
  did -r $+ $iif($did(8).state,ev,bh) $dname 9
}
on *:dialog:bad_channel:sclick:11:{
  if $did(8).state {
    var %time = $iif($did(9) isnum,$calc($did(9) * 60),$iif($chr(58) isin $did(9),$duration($did(9))))
    $+(.timer,bad_channel_check,.,$cid,.,$chan) 0 %time bad.channel $chan
  }
  var %exempt
  if $did(4).state {    %exempt = o  }
  if $did(5).state {    %exempt = %exempt $+ h  }
  if $did(6).state {    %exempt = %exempt + v  }
  if $did(7).state {    %exempt = %exempt + r  }
  .hadd -m bad_channel $did(2) $iif(%time,$v1,0) $+($did(4).state,$did(5).state,$did(6).state,$did(7).state)
  .channels
}

;Aliases
alias -l channels {
  did -bhr bad_channel 9
  did -u bad_channel 4-8
  did -r bad_channel 2
  var %a = 1, %b = $hget(bad_channel,0).item
  while %a <= %b {
    did -a bad_channel 2 $hget(bad_channel,%a).item
    inc %a
  }
}
alias -l bad.channel {
  if $me isop $1 {
    var %exempt = $gettok($hget(bad_channel,%chan),2,32), %a = 1
    while %a <= $nick($1,0,a,%exempt) {
      .enable #bad.chan.whois
      .whois $nick($1,%a,a,%exempt)
      inc %a
    }
  }
}

;Groups
#bad.chan.whois off
raw 318:*:{
  .disable #bad.chan.whois
  haltdef
}
raw 319:*:{
  var %b = 1, %c = $numtok($3-,32)
  while %b <= %c {
    if $hfind(bad_channel,$gettok($3-,%b,32)) && ($me isop %chan) {
      .ban -k %chan $2 2 Bad Channels detected
    }
    inc %b
  }
}
#bad.chan.whois end

;Ops remote access
on op:text:!list:*:{
  var %a = 1, %b = $hget(bad_channel,0).item
  while %a <= %b {
    var %chan = $hget(bad_channel,%a).data
    .timer 1 %a .msg $nick $hget(bad_channel,%a).item $duration($gettok(%chan,1,32),3) $gettok(%chan,2,32)
    inc %a
  }
}
on op:text:!add*:*:{
  if !$2 {
    .msg $nick Format is !add <channel> <timing> <exemption status>
    .msg $nick ....
    halt
  }
  if !$3 || $3 !isnum || $chr(58) !isin $3 {
    .msg $nick <timing> must be in minutes or hh:mm:ss format
    .msg $nick Use 0 if no automatic check is to be used
    .msg $nick ....
    halt
  }
  if !$4 {
    .msg $nick <exemption status> must be in ohvr format
    .msg $nick any or all of those are valid
    .msg $nick ....
    halt
  }
  .hadd -m bad_channel $2 $iif($3 isnum,$calc(60 * $3),$iif($chr(58) isin $3,$duration($3),0)) $4
  if $gettok($hget(bad_channel,$2),1,32) {
    $+(.timer,bad_channel_check,.,$cid,.,$2) 0 $v1 bad.channel $2
  }
}
on op:text:!remove*:*:{
  if !$2 {
    .msg $nick Format is !remove <channel> <timing> <exemption status>
    .msg $nick <timing> and <exemption status> are optional
    .msg $nick Use 0 for <timing> to turn it off and change the exemption status
    .msg $nick <exemption status> must be in ohvr format
    .msg $nick any or all of those are valid
    .msg $nick ....
  }
  elseif $3 == $null {
    $+(.timer,bad_channel_check,.,$cid,.,$2) off
    .hdel bad_channel $2
    .msg $nick $2 has been removed
  }
  elseif $3 == 0 && $4 {
    $+(.timer,bad_channel_check,.,$cid,.,$2) off
    .hadd -m bad_channel $2 0 $remove($gettok($hget(bad_channel,$2),2,32),$4)
  }
  elseif !$4 {
    var %time = $iif($3 isnum,$calc(60 * $3),$iif($chr(58) isin $3,$duration($3),0))
    $+(.timer,bad_channel_check,.,$cid,.,$2) 0 %time bad.channel $2
  }
  else {
    var %time = $iif($3 isnum,$calc(60 * $3),$iif($chr(58) isin $3,$duration($3),0))
    .hadd -m bad_channel $2 %time $remove($gettok($hget(bad_channel,$2),2,32),$4)
    $+(.timer,bad_channel_check,.,$cid,.,$2) 0 %time bad.channel $2
  }
}

on !@*:join:#:{
  .enable #bad.chan.whois
  .whois $nick
}
menu nicklist,channel {
  Bad Channel Dialog : dialog $iif(!$dialog(bad_channel),-md,-ev) bad_channel bad_channel
}
on *:start:{
  if !$hget(bad_channel) { .hmake bad_channel 100 }
  if $exists(bad_channel.hsh) { .hload bad_channel bad_channel.hsh }
}
on *:disconnect:{
  .hsave -o bad_channel bad_channel.hsh
}
on *:exit:{
  .hsave -o bad_channel bad_channel.hsh
}
on *:op:#:{
  .auser -a op $opnick
}
on *:serverop:#:{
  .auser -a op $opnick
}
on op:nick:{
  .ruser op $nick
  .auser -a op $newnick
}
 

#157918 02/09/06 07:28 AM
Joined: Jan 2006
Posts: 22
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2006
Posts: 22
well I ran it for one whole day,
and I dont know if I have the bad.channels.txt wrong or in the wrong place, but its not working. I had someone enter a bad channel and then told it to scan and it didnt kick him.

also a bit confused on remove the on join part.
god I am such a noob and I sound like I am leeching the code off you.. lol.
in the bad channel txt file should the channel be listed with the # or not.

THanks
P.S. forget about the user tab thing on save.. it was just me. it loads fine in the remote section

#157919 02/09/06 12:38 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The channel names do require the # symbol with each channel in the bad.channels.txt file.

If you use the latest code that I posted, then you won't have to worry about the text file, since it uses dialogs and hash tables. You'll have to add the bad channels to the hash table, using the dialog, and, once again, the # symbol is required.

#157920 04/09/06 06:33 AM
Joined: Jan 2006
Posts: 22
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2006
Posts: 22
WOOHOO.... Thank You... works great....
I used the last one you posted, put all the channels in there.
and its works great....

I thak you so much.. yea it lags a lil. but not bad enough for me to care.

thank you so much... A+ in my book


Link Copied to Clipboard