mIRC Home    About    Download    Register    News    Help

Topic Options
#264531 - 12/12/18 05:18 PM Logging Kicks From Multiple Channels
VitaminAforAweso Offline
Nutrimatic drinks dispenser

Registered: 12/12/18
Posts: 5
I need help with a script and have been unable to solve it myself so I finally joined here to get some help.

I have a very simple script to log every time a user is kicked into a custom window so I can reference who was kicked and when.

Code:

on *:KICK:#: {
if (You have been kicked isin $1-) {
/echo @KICK $fulldate $knick was kicked from $chan by $nick reason: $1-
}



This works well when a user is kicked from one channel, but when a user is banned, they get kicked from all channels on the server and the script triggers for each individual kick and floods my window for each channel the person is kicked from.

Is there a good way to condense this so it will only trigger once, but the $chan will output all the channels the person was kicked from in one message? The user could be kicked from one channel or could be kicked from five and because of how the bans/kicks work there is sometimes a few seconds of delay from getting kicked from the first channel and getting kicked from the last channel.

Top
#264532 - 12/12/18 07:42 PM Re: Logging Kicks From Multiple Channels [Re: VitaminAforAweso]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
Code:
on *:kick:{
  if (you have been kicked isin $1-) && (!$($+(%,kick.,$cid,$knick),2)) { 
    inc -u5 $+(%,kick.,$cid,$knick) 
    echo @kick $fulldate $knick was kicked from $chan by $nick reason: $1-
  }
}


This will still show a message for each network. If you’d rather make it so only one message appears altogether, just get rid of the $cid so the code becomes:

Code:
on *:kick:{
  if (you have been kicked isin $1-) && (!$($+(%,kick.,$knick),2)) { 
    inc -u5 $+(%,kick.,$knick) 
    echo @kick $fulldate $knick was kicked from $chan by $nick reason: $1-
  }
}


This works by setting a temporary variable when someone is kicked and their nickname is included in the name of the variable. It checks if a variable already exists. If it does, that means they have been kicked in the last five seconds and it won’t display another message. It then sets a variable for five seconds so that the code won’t trigger again until the variable unseats.

Top
#264533 - 12/12/18 08:15 PM Re: Logging Kicks From Multiple Channels [Re: hixxy]
VitaminAforAweso Offline
Nutrimatic drinks dispenser

Registered: 12/12/18
Posts: 5
Thank you. I have two questions though.

1: what does(!$($+(%,kick.,$cid,$knick),2)) do?

2: is there a way to get the script to out put the different channels that the user was kicked from, or will it just state the first channel from before the timer was activated?

Top
#264535 - 12/12/18 09:03 PM Re: Logging Kicks From Multiple Channels [Re: VitaminAforAweso]
Dazuz Offline
Vogon poet

Registered: 01/12/15
Posts: 114
Loc: Finland
Code:
on *:kick:#: {
  if (You have been kicked isin $1-) {

    ;Stores the kick reason in %reason variable
    set -l %reason $1-

    ;Takes the last line from the log and tokenizes it
    tokenize 32 $line(@kick,$line(@kick,0))

    ;#1 Checks if the time between the last event and current time is less than 10 seconds
    ;#2 checks if knick is same as last time
    ;#3 checks if nick is same as last time
    if ($calc($ctime -$ctime($1-5)) < 10) && ($6 == $knick) && ($12 == $nick) {

      ;Replaces the last line with a new line that contains the new channel name (#chan1,#chan2,#chan3...)
      rline @kick $line(@kick,0) $fulldate $knick was kicked from $10 $+ , $+ # by $nick reason: %reason
      
    }
    else {

      ;Normal new line
      aline @kick $fulldate $knick was kicked from # by $nick reason: %reason
      
    }
  }
}


Didn't test it, but it should work.


Edited by Dazuz (12/12/18 09:05 PM)
Edit Reason: Brainfart

Top
#264536 - 12/12/18 09:59 PM Re: Logging Kicks From Multiple Channels [Re: Dazuz]
VitaminAforAweso Offline
Nutrimatic drinks dispenser

Registered: 12/12/18
Posts: 5
It doesn't seem to work for me. It still writes a line for each channel. What $1- are you working with where $6 is the knick and $12 is the nick?

Top
#264537 - 12/12/18 10:51 PM Re: Logging Kicks From Multiple Channels [Re: VitaminAforAweso]
Dazuz Offline
Vogon poet

Registered: 01/12/15
Posts: 114
Loc: Finland
The one it creates with the tokenize line.

You can test which one of the ifs failed by adding a little echo line above it:
Code:
echo -st * $calc($ctime -$ctime($1-5)) < 10 && $6 == $knick && $12 == $nick

Top
#264542 - 13/12/18 06:58 PM Re: Logging Kicks From Multiple Channels [Re: Dazuz]
VitaminAforAweso Offline
Nutrimatic drinks dispenser

Registered: 12/12/18
Posts: 5
After playing with the parts of the if, it seems the first one always fails. What is it supposed to be calculating?

Also, if $12 is supposed to be the nick of the person doing the kicking, won't that be getting changed if multiple channels are added in front of it in the output?

Top
#264543 - 13/12/18 09:04 PM Re: Logging Kicks From Multiple Channels [Re: VitaminAforAweso]
Dazuz Offline
Vogon poet

Registered: 01/12/15
Posts: 114
Loc: Finland
The first one takes the first 5 tokens ($fulldate = Thu Dec 13 22:22:22 2018) and converts it to $ctime and then compares it to the current $ctime, which gives you the number of seconds that have elapsed since the event was added.

See what this gives you if you add it above the if:
Code:
echo -st * FULLDATE: $1-5 CTIME: $ctime($1-5) CURRENT CTIME: $ctime


It doesn't add spaces when adding channels, it separates them with a comma, so you'll get: #channel1,#channel2,#channel3... which counts as a single token.


EDIT:
To add to the first one: it checks if the entry is less than 10 seconds old. If it's over 9 seconds, it adds a new line.

You can change it to anything you want, or even remove it. It'll just keep adding to the same line as long as the targets are the same.


Edited by Dazuz (13/12/18 09:13 PM)

Top
#264544 - 13/12/18 09:40 PM Re: Logging Kicks From Multiple Channels [Re: Dazuz]
VitaminAforAweso Offline
Nutrimatic drinks dispenser

Registered: 12/12/18
Posts: 5
Thanks for explaining. I wasn't aware you could convert $fulldate to $ctime that way.

After testing it, all the different things in the condition matched up with the echo, but the output came from the else statement and output 2 lines, not the if with all the conditions. If the if is rewriting the last line in the @window then shouldn't the conditions come later?


Edited by VitaminAforAweso (13/12/18 09:41 PM)

Top
#264547 - 13/12/18 10:09 PM Re: Logging Kicks From Multiple Channels [Re: VitaminAforAweso]
Dazuz Offline
Vogon poet

Registered: 01/12/15
Posts: 114
Loc: Finland
I fed it some lines, and it seems to be working like it should:
Quote:

Thu Dec 13 23:56:30 2018 KNICK was kicked from #CHANNEl by KICKER reason: test 1 2 3
Thu Dec 13 23:56:45 2018 KNICK was kicked from #CHANNEl,#CHANNEl,#CHANNEl,#CHANNEl by KICKER reason: test 1 2 3
Thu Dec 13 23:57:09 2018 KNICK was kicked from #CHANNEl by KICKER reason: test 1 2 3



It only rewrites the line if the conditions are met, so they must come first.

I assume the problem is that more than 9 seconds separates the events, so here's the script without any time limit:
Code:
on *:kick:#: {
  if (You have been kicked isin $1-) {

    ;Stores the kick reason in %reason variable
    set -l %reason $1-

    ;Takes the last line from the log and tokenizes it
    tokenize 32 $line(@kick,$line(@kick,0))

    ;#1 checks if knick is same as last time
    ;#2 checks if nick is same as last time
    if ($6 == $knick) && ($12 == $nick) {

      ;Replaces the last line with a new line that contains the new channel name (#chan1,#chan2,#chan3...)
      rline @kick $line(@kick,0) $fulldate $knick was kicked from $10 $+ , $+ # by $nick reason: %reason
      
    }
    else {

      ;Normal new line
      aline @kick $fulldate $knick was kicked from # by $nick reason: %reason
      
    }
  }
}

Top