mIRC Home    About    Download    Register    News    Help

Print Thread
#160308 25/09/06 01:27 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
This is what I have so far. Is it possible to store in ahash file the address and maybe the nicks also that will be re-ban if someone else but me removes the ban from the channel banlist ?

on @*:ban:#:{ if (%ban == off || !%ban) { return } | if ($nick == $me) { hadd -m $+(#,.ban) $banmask $ctime } }
on @*:unban:#:{ if ($hget($+(#,.ban),$banmask) && $nick != $me) { mode # +b $banmask } }

#160309 25/09/06 09:54 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
First of all, a hash table will not be saved automatically if you close mIRC. Therefore, just doing /hadd -m to create the table is a bad idea. You are better off with an on START command that will create the hash table and then /hload the saved hash table if there is a saved copy. Then, anytime the hash file is changed (when you ban someone), you should /hsave the file. Of course, because this is supposed to work for any number of channels without having to manually set things up, I'd just use an alias to load it for you.

Second, scripts that are all on one line, using pipes, are a real pain to debug. You are *much* better off getting in the habit of writing code in an easy to read format. Writing it all on one line doesn't really do anything except frustrate you or others later when you try to debug it.

Third, the on ban doesn't need @ because you don't have to be opped for it to do any of the commands... and you'll be an op if the if $nick == $me statement is true, anyhow.

Finally, I would avoid dealing with combining $chan + .ban for the hash table name if possible. You can do that, but it's just easier to avoid it if you can. I've seen problems crop up when you combine them incorrectly somewhere along the line and it's not evaluating properly and you're stuck trying to figure out what went wrong.

Anyhow, here is the code I'd suggest using:
Code:
on *:ban:#: {
  if (%ban == off || !%ban) { return }
  if ($nick == $me) {
    if (!$hget($chan,0).item) { MakeHash $chan }
    hadd $chan $banmask $ctime
    hsave $chan $chan $+ .hsh
  }
}
on @*:unban:#: {
  if ($hget($chan,$banmask) && $nick != $me) {
    mode # +b $banmask
  } 
}
alias MakeHash {
  hmake $1 100
  if ($isfile($1 $+ .hsh)) {
    hload $1 $+ .hsh
  }
}


Invision Support
#Invision on irc.irchighway.net
#160310 25/09/06 11:47 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
Riamus2 thx for the explaination. I want to re-ban only the ones I added manually that will be stored not all my bans so I guess I need to add from the menu right?

Last edited by Garou; 25/09/06 11:56 PM.
#160311 26/09/06 09:06 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It will only re-ban users who are in the hash table. And it only adds users to the hash table if you ban them. So, it should do what you want... you may just have to manually /hadd the users who are already banned.


Invision Support
#Invision on irc.irchighway.net
#160312 26/09/06 11:17 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
Riamus2 its perfect accept that I dont want the script to auto add all my bans just the ones that I will manually add :P
How do I add or remove from the script?

Last edited by Garou; 26/09/06 11:35 PM.
#160313 27/09/06 01:23 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Just remove the on ban section. Then, add this to make it easier to add the banmask:
Code:
alias AddBan {
  if (!$hget($chan,0).item) {
    MakeHash $chan
  }
  hadd $chan $$?="Enter banmask" $ctime
  hsave $chan $chan $+ .hsh
}


Then, type /addban whenever you want to add a banmask. Keep in mind that if you enter the banmask incorrectly, it won't work for the unban prevention.


Invision Support
#Invision on irc.irchighway.net
#160314 27/09/06 01:47 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
What do you mean remove the on ban section?

#160315 27/09/06 02:01 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
Riamus2 Those this lock good to you?

on @*:unban:#: {
if (%sticky.ban == off || !%sticky.ban) { return }
if ($hget($chan,$banmask) && $nick != $me) {
mode # +b $banmask
}

}
alias MakeHash {
hmake $1 100
if ($isfile($1 $+ .hsh)) {
hload $1 $+ .hsh
}
}

alias AddBan {
if (!$hget($chan,0).item) {
MakeHash $chan
}
hadd $chan $$?="Enter banmask" $ctime
hsave $chan $chan $+ .hsh
}

Last edited by Garou; 27/09/06 02:02 PM.
#160316 27/09/06 08:57 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes, it looks right.


Invision Support
#Invision on irc.irchighway.net
#160317 27/09/06 09:40 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
Thx very much Riamus2
Last question please. Is it possible to have a menu like this one for this code?

menu nicklist {
-
BanList Settings
.Add Nick: banlist add $$?="Nick To Add"
.Add $1: banlist add $iif(!$snicks,$$?="Nick(s) To Add",$snicks)
.-
.Remove Nick: banlist del $$?="Nick To Remove"
.Remove $1: banlist del $iif(!$snicks,$$?="Nick To Remove",$snicks)
.-
.View BanList: .hsave -o NB NB.txt | run NB.txt
.Clear Ban NickList: .hfree NB | $iif($exists(NB.txt),remove NB.txt)
}

#160318 27/09/06 10:04 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
One problem with that... if you enter a NICK to ban, then it will never be the same as $banmask when checking the unban. Even if you set it up with a specific mask, it may not match the actual $banmask. For example, if you set a nick to nick!*ident@*.host and the nick gets banned as *!*ident@*.host.com, it will not trigger the unban check. This is why it is better to only add a banmask based on people who are already banned (view your channel's ban list). Then you can make sure it is set to the correct mask.

For the view/clear, you can use that same code, just replace NB with $chan and NB.txt with $chan $+ .txt ... you could avoid writing it to a file, but that probably will be the easiest way to see it if it's large.

For removing a banmask, you'll need to know the correct banmask and then you can use this in the menu:

Remove Ban:hdel $chan $$?+"Enter a banmask"

Granted, that doesn't have error checking in case your banmask isn't there... it'll just display mIRC's error message if it doesn't match a mask in the hash table.

For adding, just have the Add mask menu item call the alias I included.


Invision Support
#Invision on irc.irchighway.net
#160319 27/09/06 10:32 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
The only thing not working is the Add Sticky Ban menu.
What did i do wrong here?


menu nicklist {
-
Sticky Ban Settings
.Add Sticky Ban:addban $chan $$?="Enter a banmask" $ctime
.-
.Rem Sticky Ban:hdel $chan $$?+"Enter a banmask"
.-
.View Sticky Ban: .hsave -o $chan $chan $+ .hsh | run $chan $+ .hsh
.-
.Clear Sticky Ban: .hfree $chan | $iif($exists($chan $+ .hsh),remove $chan $+ .hsh)
-
}

Last edited by Garou; 27/09/06 11:29 PM.
#160320 28/09/06 12:38 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You only need AddBan... you don't need the rest of the line after that. Try with just AddBan and see if it works.


Invision Support
#Invision on irc.irchighway.net
#160321 28/09/06 12:45 AM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
You are right it works fine now, thx very much Riamus2...

#160322 28/09/06 12:51 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
No problem. laugh


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard