mIRC Home    About    Download    Register    News    Help

Print Thread
#200470 06/06/08 03:24 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline OP
Hoopy frood
OP Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
I'm a channel op, and I manage to save the bans I've made into an ini file. What should I do to load it onto my Ban List from the ini file? Can anyone give me a pointer on this? Thank you.

Last edited by Tomao; 06/06/08 03:25 AM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Basically you have to loop through the entries in the ini file and re-ban each one. It'd be easier to provide an accurate code if you would provide a couple of examples of the format that the data is stored in.

Joined: Jul 2007
Posts: 1,129
T
Tomao Offline OP
Hoopy frood
OP Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Thanks much RusselB for you response. Below is the code I have so far, but it is not working 100% for me:

Code:
on *:Dialog:bans:sclick:2: { 
  var %f " $+ $$sfile($scriptdir $+ *.ini,please select a saved access list to import...) $+ "
  if ($hget(ChannelAccess)) { echo 2 -a * File loading in progress... | return }
  hmake ChannelAccess 100 | hload -n ChannelAccess %f | %list = 1 | did -rab $dname 1 Importing Access list, please wait... | did -r $dname 4 | Accessl Accesslist
}
alias accessl {
  if ($hget(ChannelAccess,%list) == $null) {
    elseif ($dialog(bans)) { did -ra Bans 1 Retrieving the file... | access $active }
    unset %List* | hfree ChannelAccess
  }
  else { access $active add $remove($hget($1,%List)) | inc %List }
}


The ini is stored as such:

Code:
[Jone]
DENY=Jone 0 hostie!fd0b6dcff51a8f0512d094ddcdd41e@XXXXXX Violation!


Code:
raw 804:*:{ writeini $2 $+ .ini $4 $3- }


Last edited by Tomao; 06/06/08 06:11 AM.
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline OP
Hoopy frood
OP Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
I'm still sort of hitting a wall here. I'm trying to import an ini file that I've saved into an access list, but I ended up getting an error: /timer ac.2 not active and nothing gets loaded onto the list either. Based on Russel's suggestion, I'm trying to use a while loop here, but perhaps there is something I have done wrong. Can anyone be kind enough to offer me some assistance or guidance?

Code:
on *:Dialog:access:sclick:2: { 
  var %f " $+ $$sfile($scriptdir $+ *.ini,please select a saved access list to import...) $+ "
  if ($hget(ChannelAccess)) { echo 2 -a * File loading in progress... | return }
  hmake ChannelAccess 100 | hload -n ChannelAccess %f
  var %x 2 | while (%x <= $lines(%f)) { tokenize 32 $hget(%f,%x).data | timerac. $+ %x 1 $calc(%x * 2) $lister(add $gettok($1,2,61) $4 $5 $6 $8-) | inc %x }
}
  alias lister { access $active list }
}


The ini file is stored as shown below:

Code:
[GuestGate]
DENY=GuestGate 1440 John!d094ddc2311e@chatnet
[ghdfgh]
DENY=ghdfgh 8 John!d094ddc2311e@chatnet test, reason Not allowed.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Could you post the full code as you have it. You seem to have a bracket mismatch someplace, as the code for alias lister is indented and it shouldn't be.

Joined: Jul 2007
Posts: 1,129
T
Tomao Offline OP
Hoopy frood
OP Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
These are two scripts I have tried, but they won't work as intended to get loaded onto my access list...

Code:
dialog accessload {
  title "ChanAccess"
  size -1 -1 88 24
  option dbu
  button "Load a Saved File", 2, 6 5 75 15, flat
}
on *:dialog:accessload:sclick:2: { 
  var %f " $+ $$sfile($scriptdir $+ *.ini,please select a saved access list to import...) $+ "
  if ($hget(Access,%f).data) { echo 2 -a * You already loaded this file. | return }
  else { hmake Access 100 | hload -n Access %f | echo 4 -a * You selected file has been loaded... | accesslist }
}
raw 804:*: { writeini $2 $+ .ini $4 $3- | halt }
alias accesslist { access $active list }


Code:
dialog access.loader {
  title "Access loader."
  size -1 -1 284 21
  option dbu
  combo 1, 1 1 282 160, size drop
  button "Load selected list.", 2, 228 12 55 8, flat
}
on *:Dialog:access.loader:init:0:{ access.files }
on *:Dialog:access.loader:sclick:*:{ 
  if ($did = 2) { hadd -m Acclist Filename $did(access.loader,1).seltext | doaccess }
}
alias access.loader { dialog -m access.loader access.loader }
alias access.files {
  var %x = 1
  while (%x <= $findfile($+("Access lists,\),*.ini,0")) {
    did -a access.loader 1 $findfile($+("Access lists,\),*.ini,%x,")
    inc %x
  }
  did -c access.loader 1 1
}
alias doaccess {
  if ($sock($gettok($hget(Acclist,Viewing),1,32))) { 
    var %doit = sockwrite -n $gettok($hget(Acclist,Viewing),1,32) ACCESS $gettok($hget(Acclist,Viewing),1,32)
    var %x = 1
    while (%x <= $lines($hget(Acclist,Filename))) {
      var %info = $read($hget(Acclist,Filename),%x) | tokenize 32 %info
      %doit add $1-2 0 $3-
      inc %x
    }
    hdel Acclist Filename
  }
  dialog -x access.loader access.loader
  halt
}


Link Copied to Clipboard