mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
1.)For an on input event, where I $replace words.
var %a = $1-
while ($findtokcs(%a,i,32)) %a = $puttok(%a,I,$ifmatch,32) | while ($findtokcs(%a,id,32)) %a = $puttok(%a,I'd,$ifmatch,32) | while ($findtokcs(%a,im,32)) %a = $puttok(%a,I'm,$ifmatch,32)

This replaces 'i' with 'I', 'id' with "I'd" and etc.

How can I format it into one code without using the | while | while etc. Just basically combine the whole thing.

2.)I have a cussword scriptl which looks like this.

if ($istok($1-,cussword1,32) == $true) {
/ban 30 secs
if ($istok($1-,cussword2,32) == $true) {
/ban 60 secs

Then,

if ($istok($1-,cussword1 cussword2,32) == $true) {
/ban 90 secs

Notice that I had to manually type in the added ban length, 60 + 30 secs = 90 secs.

But, I have 9 cussword with different ban lengths, so how I be able to have mirc add each individual cussword once?

With 9 different cusswords, one can say any of the 9, 2 of the 9, 3 of the 9, and up to 9 of the 9.

So I have like, 9! combinations, or 362,880 different ways. Clearly a shortcut is what I'd like.

Basically what I need is to set a variable of ban secs per word and if all are said in a $1- text mirc will add up the bans secs, but only counting the same cussword once.

3.)I have a seen script. For on text event,

write -w" [ $nick ] $+ :*" seen.txt $nick $+ : $+ [ $ctime ] $+ : $+ [ $chan ] $+ :saying " $+ [ $1- ] $+ "

And the event to trigger,

%temp = $read(seen.txt,w,%seennick $+ :* )

That returns the last line of the user in a !seen nick.

How would i go about finding the second or third last seen text? I have tried $calc($readn +1) and no luck.

4.)Centisecond timestamp, for on start event.

/.timercentisecond -om 0 1 .timestamp -f $!+([mmmm dd yyyy dddd hh:nn:ss:,$mid($ticks,-3,2) TT,])

But using $ticks is a bad idea, for $ticks does not start at 000 centiseconds.

Although this timestamp is good to determine the centisecond from one log to another (for as good as mIRC's timers go), they are not actual centiseconds of time.
What the means is the centisecond timestamp of the same second could decrease, rather than increase.

5.)For the raw event of /mode # b, where it lists the channel bans, it goes like

$banmask1 set by $nick at $time ($duration)
$banmask2 set by $nick at $time ($duration)
$banmask3 set by $nick at $time ($duration)

I would like to add a $ibl(#,0) to return the total number of bans. Is it possible via an /echo -s Channel bans of $2 $ibl($2,0), and then list the bans?

So instead,

Channel bans of #: 3
$banmask1 set by $nick at $time ($duration)
$banmask2 set by $nick at $time ($duration)
$banmask3 set by $nick at $time ($duration)

6.)I have a way to add up the total nicks for all the channels you are in per network, via hash tables. However, does anyone have a method where you script to add up the total users in all the channels you are in, and subtract the users in common channels? That's so you don't add up the same person more than once in common channels.

Thanks in advance.., for anything.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Here's a way of doing the first one
I gotta run at the moment, will take a better look at the others when I can, however, I can't quickly think of any reason what you're asking for in any of them can't be done.
Code:
on *:input:*:{
while $istokcs($1-,i,32) { var %a = $reptokcs($1-,i,I,32) }
while $istokcs($1-,im,32) { var %a = $reptokcs($1-,im,I'm,32) }
while $istokcs($1-,id,32) { var %a = $reptokcs($1-,id,I'd,32) }
}
 

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Couldn't edit my previous reply due to the amount of time that had elapsed.

Regarding your 2nd query:
I'd suggest storing your "cusswords" in a text file followed by the amount of time that each word has allocated for the ban time. Then in your code try:
Code:
on *:text:*:#:{
var %text = $1-
while (%text) {
inc %bantime $read(cussword.txt,s,$gettok(%text,1,32))
var %text = $remove(%text,$gettok(%text,1,32))
}
if %bantime { .ban -ku $+ %bantime $chan $nick | unset %bantime }
}


Regarding #3, try $calc($readn - 1) for the 2nd last or $calc($readn - 2) for the 3rd last. Not knowing how the information is written to the file for your seen script, that's the best I can suggest at this point.

Regarding #4, the -m in the timer command & $ticks are measured in milliseconds, not centiseconds. There are 10 milliseconds in each centisecond.

Not a clue on #5, but I will give it further review.

Regarding #6, it would help if I could see the code as to how you're adding the information to the hash table(s).

Hope that this has been of some assistance, and I look forward to your reply, so that I can try to help with the others.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
1.
Code:
var %a = $gettok(  $replacexcs( $+($chr(32),$1-,$chr(32)) , $+($chr(32),i,$chr(32)) , $+($chr(32),I,$chr(32)) , $+($chr(32),id,$chr(32)) , $+($chr(32),I'd,$chr(32)))  ,1-,32)
or
var %a = $gettok(   $replacex(  $replacexcs( $+(.,$replacex($1-,.,$cr,$chr(32),.),.) [color:blue],.i.,.I.,.id.,.I'd.[/color])  ,.,$chr(32),$cr,.)   ,1-,32)

The first one is simple a find and replace of " i " with " I " and " id " with " I'd ", but its hard to see the things your replacing due to all the $chr(32)
The second is a complexe method of changing . to $cr then space to ., then .i. to .I. & .id. to .I'd, then changing . back to space and $cr back to . sound cracy I know but lets you have a nice blue section of find and replace values, using . in the place of spaces.

This replaces 'i' with 'I', 'id' with "I'd" and etc.

How can I format it into one code without using the | while | while etc. Just basically combine the whole thing.



2.)
Code:
var %banlength = 0
if ($istok($1-,cussword1,32)) { inc %banlength 30 }
if ($istok($1-,cussword2,32)) { inc %banlength 60 }
etc
if ($istok($1-,cussword2,32)) { inc %banlength 60 }
if (%banlength) { ban %banlength secs }

I add the ban length to a value then check if its set to anything at the end and ban them for that length.
I removed the == $true as you dont need it in this case. Simple the $istok() well be replaced with $true or $false and the inc occur if it was true



3.
I dont think you can.
write -w" [ $nick ] $+ :*" seen.txt $nick $+ : $+ [ $ctime ] $+ : $+ [ $chan ] $+ :saying " $+ [ $1- ] $+ "
^ that well do a -w" $nick:*" which searches out the current line that matches that, and then does the command on the line, namely replace it with a new one.



4.)Centisecond timestamp, for on start event.
Code:
alias centiseconds {
  if (!$var(%centiseconds.correction,0)) {
    var %time = $time
    while (%time == $time) { }
    echo $time : $ticks
    set -u1000000000 %centiseconds.correction $calc($ticks - 1000)
  }
  return $mid($calc($ticks - %centiseconds.correction),-3,2)
}

/.timercentisecond -om 0 1 .timestamp -f $!+([mmmm dd yyyy dddd hh:nn:ss:,$centiseconds TT,])
^ I dont agree with your use of this timer, it shouldnt be any lower than -om 0 10 since your timestamp isnt any finer than that.
However that said $centiseconds well return 00 to 99 inline with the second.
Note the first time its accessed it may pause for up to one second, this is as it waits for a second to change, and then it take note of the current $tick value (-1000) and then from then on removes that value from $ticks to sync up to the second.
IF there is a identifier for it, i didnt noticed it when i looked.


5.)Sorry i dont do much with bans etc

6.)Sounds like a good method you already had.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
After re-reading your 3rd query, as I understand it, your write command is working on the line found that starts with $nick and it overwrites that line, so the information that was there previously is lost, making it impossible to retrieve the information from a previous posting for that nick.

You'd have to change the format in which the information was written to the text file in order to be able to trace back.

Another option is to ensure that the room chat was logged.
mIRC Options - IRC - Logging - Automatically log: Channels (or Both)
Then you could search through the logs. Whichever method you decide to go with, if either, let me know and I'll see what I can do about getting you a new code for the method you decide.

Regarding #4, give this code a try:
Code:
on *:start:{
var %uptime = $calc(($uptime - ($uptime(mIRC,3) * 1000))/10)

.timercentisecond -om 0 10 .timestamp -f $!+([mmmm dd yyyy dddd hh:nn:ss:,%uptime TT,]) 
}
 

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
1)
var %a = $1-, %q = $regsub(%a,/\bi\b/g,I,%a) $regsub(%a,/\bid\b/g,I'd,%a) $regsub(%a,/\bim\b/g,I'm,%a)

This is just one line, you can add as many $regsub entries as you want. The variable %q is just garbage (a number for each regsub entry with the number of replacements), you just display %a
A short introduction to regex for mIRC might be advised smile
For the first: \b means word boundary, the empty gap between a letter (a-z) and a non-letter (digit, space, other symbol) or the other way around. \bi matches i or iukgj or i2 or i: but not ai
The / /g means to replace all entries, not just the first one.

2) Add all cusswords to a hash table:
:make hash
hmake cuss 20
; add first entry 'cussword1' to hash cuss with value 30 (seconds)
hadd cuss cussword1 30
hadd cuss cussword2 60

The on text script:
Code:
on *@:TEXT:*:#channelname: {
  var %time = 0, %t = $strip($1-)
  while ($regex(%t,\b([a-z]+)\b)) {
    if ($hget(cuss,$regml(1)) inc %time $v1
    %t = $remove(%t,$regml(1)
  }
  if (%time > 0) ban -ku $+ %time $nick Bad words: %time seconds ban
}


3) The write -w searches a previous line with that nick and replaces it with the new line. This means the previous action or that before aren't in the file anymore.

4) I have no idea what a centisecond is, but fractions of seconds don't really matter when I've seen messages be delayed 30 seconds and more. Needless to say, I wasn't winning that trivia game then, by the time the question arrived, the time was already up on the bot's side...

5) Since the number of bans isn't sent beforehand, you'll have to use some raw handler to catch the ban list, store it in a hash table or a file or something and when the end is reached, you can calculate the number of bans and display that message and list them.

6) It's also a hash table task I guess:
Code:
alias uniqueusercount {
  hfree unusli
  var %con = $scon(0), %count = 0
  while (%con > 0) {
    scon %con
    hmake unusli 40
    var %ch = $chan(0)
    while (%ch > 0) {
      var %chan = $chan(%ch), %n = $nick(%chan,0)
      while (%n > 0) {
        hadd unusli $nick(%chan,%n) 1
        dec %n
      }
      dec %ch
    }
    inc %count $hget(unusli,0)
    hfree unusli
    dec %con
  }
  echo -s A total number of %count different nicks found in all channels on all networks
}


Loop over all connections, channels and nicks and add them to hash table, the count number of items in hash table. Same nicks on different connections are counted double.

Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
From the /write -w for seen.txt, it seems to make sense of the lines overriding one another, but that would mean I would have only one last line per nick.

But apparently it stores every line, so I could find a nick and use the find next on Notepad, and keep searching forward all the lines stored in the file. The only thing is if I delete the line than my seen willhave to return the next previous text.

Or maybe I need to not override, perhaps forget the -w switch.

I'm going to test the centisecond timestamps, the $regsubs, and uniqueusercount and such. Thanks for your input all.

Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Okay, several problems.

First off, with the uniqueuserscount,

* /hfree: no such table 'unusli' (line 1559

Line 1559 is,

hfree unusli

And as for the centisecond timestamp, this one.

var %uptime = $calc(($uptime - ($uptime(mIRC,3) * 1000))/10).timercentisecond -om 0 1 .timestamp -f $!+([mmmm dd yyyy dddd hh:nn:ss:,%uptime TT,])

The only problem is the centisecond timestamp is exactly the same. While my normal timestamp works fine every centisecond timestamp is the same value, so it does not change.

As for this centisecond timestamp,

alias centiseconds {
if (!$var(%centiseconds.correction,0)) {
var %time = $time
while (%time == $time) {
}
echo $time : $ticks
set -u1000000000 %centiseconds.correction $calc($ticks - 1000) }
return $mid($calc($ticks - %centiseconds.correction),-3,2)
}

So I replace my $ticks with $centiseconds and the timestamp is just my regular timestamp, but no centisecond.

And as for the $regsub that works great thanks. Easy way of shortening stuff.

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
replace that line with:
if ($hget(unusli)) hfree unusli

for the second problem, try
var %uptime = $calc(($uptime - ($uptime(mIRC,3) * 1000))/10).timercentisecond -om 0 1 .timestamp -f $!+([mmmm dd yyyy dddd hh:nn:ss:,%!uptime TT,])

Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Hm uniqueuserscount actuall returns $scon(0) or $scid(0).

And no luck with %!uptime. Just has an extra : after the second.

Edit, that was for when I copy/pasted the code into a status window.

But from closing and reopening mirc to trigger on start event, the %!uptime didn't do anything.

I think perhaps we need an identifer so it can $!theuptime instead?

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Ok, that's what you get when you script in a forum reply editbox instead of mIRC blush

Change this line:
inc %count $hget(unusli,0).item
so it actually returns the size of the hashfile instead of $null crazy


For the other thing, try $!(%uptime) if that doesn't work then I'm out of ideas

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
* /hfree: no such table 'unusli' (line 1559
hfree unusli

hfree -w unusli


Quote:

var %uptime = $calc(($uptime - ($uptime(mIRC,3) * 1000))/10).timercentisecond -om 0 1 .timestamp -f $!+([mmmm dd yyyy dddd hh:nn:ss:,%uptime TT,])
The only problem is the centisecond timestamp is exactly the same. While my normal timestamp works fine every centisecond timestamp is the same value, so it does not change.

Low lost a | between commands there, but since %uptime is calculated once, its going to be the same thing each time its set in the timer anyway, cause and effect explained.


Quote:

alias centiseconds {
if (!$var(%centiseconds.correction,0)) {
var %time = $time
while (%time == $time) {
}
echo $time : $ticks <<<< remove this line, it only shows once but it was in for testing (not that it effects anything)
set -u1000000000 %centiseconds.correction $calc($ticks - 1000) }
return $mid($calc($ticks - %centiseconds.correction),-3,2)
}

So I replace my $ticks with $centiseconds and the timestamp is just my regular timestamp, but no centisecond.

"replace my $ticks with $centiseconds" I didnt tell you to do that. if you did no wonder its accting oddly i said do this
.timercentisecond -om 0 1 .timestamp -f $!+([mmmm dd yyyy dddd hh:nn:ss:,$centiseconds TT,])
(thats in a script not the command line, unless you use two //)

I know it works i just did it.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
var %uptime = $calc(($uptime - ($uptime(mIRC,3) * 1000))/10) | .timercentisecond -om 0 1 .timestamp -f $!+([mmmm dd yyyy dddd hh:nn:ss:,%!uptime TT,])

For the other thing, try $!(%uptime) if that doesn't work then I'm out of ideas


if u want to delay an evaluation of a varable its % $+ uptime not %!uptime, i think the second method works (havent tested it(, but your still stuick with the fact that %uptime isnt changing its just a fixed value, you would need it in the timer being calculated each time

The bigger thing is I dont think the uptime equation your using always works (might have some setting in mirc changing things becuase) when i do $uptime on its own im getting a SECONDS value rather than milliseconds. So my values are out a mile.
i assume this would fix that (also the /10 crated a decimal place value) so....
var %uptime = $int($calc(($uptime(mirc) - ($uptime(mIRC,3) * 1000))/10))
^^^ the last problem is still what he started with, at exactlly 12:00:00.500 (1/2 a second past 12) uptime in milliseconds might be 7654321 resultuing in a time 12:00:00:32 he needs 12:00:00:50

PS: I just detected mine isnt perfect either, its close but i just got some results with it being .02 of a second out, not much but disaster when you see
12:00:00:96 test
12:00:00:97 test
12:00:01:98 test
12:00:01:99 test
12:00:01:00 test
12:00:01:01 test
12:00:01:02 test

Hmm ran it again, and the error gone, looks like the displacement value i used can be incorrect if tasking on the pc while its set was high.

Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Quote:

[code]
set -u1000000000 %centiseconds.correction $calc($ticks -


Are all those 0's necessary? Don't I need just 2?

Anyways, thanks for all your help.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
i wouldnt have put them in there if i didnt want them dude, its so the variable remains globally set untell mirc is restarted., unless some yahoo script deletes it.

Setting it to -u100 is going to unset it in 100 seconds, then the next access of the identifier well lock up the mirc for upto 1 second as it reevaluates for the variable.

Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Oh, so that centisecond timestamp will last for 31.something years. Nice.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
yes then you well experence a 1 second delay and it well be reset for another 31 years smile


Link Copied to Clipboard