mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Greetings to the visitors and staff of mIRC Forum,

I'm needing help in adding an alias which pulls up the current Bans in that chat channel and writes those to a text file, so I can later compare those to a preset list of unwanted folks.

Currently, we have just been reloading a preset list of unwanted folks into the chat channel, however in some cases where they already exist, that can lead to flooding us off that server or needlessly giving a chat server a request which is a duplicate.

Thanks for your help and consideration,
MDA

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Hey there MDA, do you mean something like this?

/getbans

This writes to #Bans.In.#Opers for example and lists the bans. Each time you issue the command the file is cleared to prevent any duplications.

Code:
alias getbans {
  if ($active ischan) {
    set -u10 %chan $chan
    if ($exists($+(GetBans\Bans.In.,%chan,.txt))) { write -c $+(GetBans\Bans.In.,%chan,.txt) }
    .enable #GetBans
    .mode $chan +b
  } 
}

#GetBans off
Raw 367:*: {
  mkdir GetBans
  echo %chan $3
  write $+(GetBans\Bans.In.,%chan,.txt) $3
  halt
}

Raw 368:*: {
  .disable #GetBans
  halt
}
#GetBans end


Hope this helps,

All the best.

-Andy.

Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Greetings and much appreciation SladeKraven,

That is precisely what I was searching for. After I ran a raw session into a window, I was able to see what server commands were being used. Mode $channel +b and the raws listing the bans, 367 and end 368.

Do you or someone else have a quick and easy method to compare each line of a text file to another. What I'll have is the preset Ban's in one text file (PresetBan.txt) and each of those would be listed in a single $1 string for each line. And I wish to compare that with the resulting output text file using the routine similar to what you posted SladeKraven (CurrentBans.txt). Based upon that comparison, those missing in the CurrentBans.txt file, but found in the PresetBan.txt file would be written into AddBans.txt file where I'll go ahead and add them.

The problem I have is the coding I use to do a comparison of two text files is long, tedious and slow. I want to output whatever is missing in the CurrentBans.txt file compared with the PresetBan.txt file to a third text file (AddBans.txt) which I'll then use to add the remaining or missing Preset Bans back into that chat channel.

Do you or someone else have a elequent and quick way to compare the lines of two text files and write those missing to the AddBans.txt file?

Thanks again for your consideration,
MDA

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Not sure about elequent, this isn't going to be fast (but will depend on your system speed and the size of the files)

If someone could do something like this, but reading both files into RAM, rather than comparing them on the hard drive, it would be significantly faster.

Usage: /compare

Code:
alias compare {
var %a = 1
while %a <= $lines(CurrentBans.txt)  {
if !$read(CurrentBans,w,$read(PresetBan.txt,%a)) {
.write -s $+ $read(PresetBan.txt,%a) AddBans.txt $read(PresetBan.txt,%a)
}
inc %a
}
}

Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Quote:

Code:
alias compare {
var %a = 1
while %a <= $lines(CurrentBans.txt)  {
if !$read(CurrentBans,w,$read(PresetBan.txt,%a)) {
.write -s $+ $read(PresetBan.txt,%a) AddBans.txt $read(PresetBan.txt,%a)
}
inc %a
}
}


Greetings RusselB,

Is something is missing or incorrect in that code, I cannot get it to output anything to the AddBans.txt file.

alias compare {
var %az = 1
while %az <= $lines(CurrentBans.txt) {
if !$read(CurrentBans,w,$read(PresetBan.txt,%az)) {
.write -s $+ $read(PresetBan.txt,%az) AddBans.txt $read(PresetBan.txt,%az)
}
inc %az
}
}

The CurrentBans.txt and PresetBan.txt are both in that main mIRC directory, it just seems something is missing in the code you listed so that it properly writes to the AddBans.txt file.

If you or someone else could help point out what is missing or incorrect, I'd appreciate it.

Thanks,
MDA

Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Greetings,

That was quite funny, took me a long time to realize you had named your alias after a command, so it couldn't possibly work. I looked and prodded the alias and couldn't see anything wrong with it simply running, the file order appeared incorrect but it should at least run I thought. NOPE, lol, have to rename that alias to Compared to function at all.

Then I rewrote the code to work with the proper files sequence of files, and changed the nesting routines so they would work properly also.

alias compared {
set %az 1
while %az <= $lines(C:\tc-chat\PresetBan.txt) {
set %Addban $read(C:\tc-chat\PresetBan.txt,%az)
if (!$read(C:\tc-chat\CurrentBans.txt,w,* $+ %Addban $+ *)) {
.write C:\tc-chat\AddBans.txt %Addban
}
inc %az
}
}

Finished Working Routines appear as this:

alias Denys {
.write -c C:\tc-chat\CurrentBans.txt
.write -c C:\tc-chat\AddBans.txt
mode %roomname +b
.timer.compared 1 30 /compared
}

raw 367:*: {
.write C:\tc-chat\CurrentBans.txt $3
}

alias compared {
set %az 1
while %az <= $lines(C:\tc-chat\PresetBan.txt) {
set %Addban $read(C:\tc-chat\PresetBan.txt,%az)
if (!$read(C:\tc-chat\CurrentBans.txt,w,* $+ %Addban $+ *)) {
.write C:\tc-chat\AddBans.txt %Addban
}
inc %az
}
}

Thanks to each for your suggestions and help,
MDA

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Sorry about the name problem on the alias in my script. However, I'm glad you managed to get something that works.

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
You're welcome. grin


Link Copied to Clipboard