mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Well, when a player joins a game server, this is produced from a bot in the channel called #CnR|LV

Quote:
[23:16] <%CnR|LV> Bill(3) Has Joined Cops & Robbers v4.3 Visits: 0


Bill = Player name
(3) = Player ID

I want to be able get the number in the brackets (ID), and then use it in a "!getip <ID>" command to be sent to the channel #admin.

Which then another bot will show that players IP.

I came up with this,

Code:
on *:text:*Has Joined Cops & Robbers*:#CnR|LV:{
msg #admin !getip
} 


Than here I am stuck. I don't know what to put after !getip.

Somebody help me, either with this code or re-write it to make sense and work please ?

Could you also explain what you have done just to help ? If not its okay.

Thanks,

Bill.


Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
using $gettok and $left, and re-check if it's a number:
Code:
on *:text:*Has Joined Cops & Robbers*:#CnR|LV:{
  if ($left($gettok($1,-1,40),-1) isnum) { msg #admin !getip $v1 }
}
$gettok(text,-1,X) is getting the "rightmost token" of a text that is separated by $chr(X). X is an ascii value.
In the code here, $1 is used for text ($1 is the first word in the processed message). "40" is the ascii value for "(", and therefore the "rightmost token of Bill(3) separated by opening bracket" is: Bill(3) .
$left(text,-1) is "text" without the rightmost character - to get rid of the closing bracket: "3)" becomes "3".
Finally, a "if (something isnum)" comparison, to play safe.
$v1 used in the message command refers to "something" in the previous check "if (something isnum)".



using regex: (grabbing the digit in brackets directly)
Code:
on $*:text:/^\S+\((\d+)\) Has Joined Cops & Robbers/:#CnR|LV: { msg #admin !getip $regml(1) }
This one is looking for one or more non-space characters (the nick) at the beginning of the line, followed directly by an opening bracket, followed directly by one or more digits (the ID), followed directly by a closing bracket, and then followed the text "Has Joined Cops & Robbers".
There are brackets arround the digit part: (\d+) who are "capturing" the enclosed part of the match, thus it can be used (refered to) in the "msg #admin" part: it's the first (and only) capture to refer to: $regml(1)

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Wow thanks a lot man, such a quick reply too.

EDIT, Can you help me some more, please.

After the !getip <id> has been done in #admin,

The bot returns like this,

Code:
 Magnus (ID:2)'s Ip is 83.68.68.204.


Is it possible you can help make it log the name and the IP to a file, then allow people in the channel to use a command such as !ip <nickname>.

I have no idea how to do it myself.

Thanks in advance, Bill.

Last edited by Billl; 31/10/08 11:47 PM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Hm, all people in the channel?

And I think it should contain some "cleaning", or the file will be ever-growing, containing many out-dated IPs.
Is there a message by the bot to trigger this? If not: under what circumstances should an IP be cleared - e.g. if the respective user parts the channel, or after a certain period of time?


Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
I don't quite understand.

It's not the IP's of people who are on the channel I want my bot the log, its IP's of people in the game server. It will be used to get ban evaders. So !getip Bill would return all the IP's the player Bill has used.

Thanks.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Ok, hope I got you right smile
It's made of 3 main parts: one on text event and 2 triggers.

- the on text event that grabs the Players Names and IPs, and adds them to an ini file ("ips.ini" in an "ini" subfolder of your $mircdir). The ini is tracking all Ips the bot is messaging: which nick used what IP - and when. If a player is using a "new" IP, the IP is added to the database. If he's using an IP already known for him, the entry for that IP is only updated.

- the trigger "!ip <name>" will search the ini file for all IPs of that player, starting with the last known IP... the string of IPs is sorted youngest to oldest. As the output string might become quite long, the script will split it at a certain point (thus nothing is chopped off).
For a more verbose output, use "!ip <name> full" - returning the IPs, together with the date and time they had been added (or updated) in the file.

- a trigger !cleanips <deadline>", to remove ALL entrys that are older than <deadline> from the file, e.g. all IP-entrys older than 2hrs, 5days or 10weeks. I set this trigger to ops of channel #CnR|LV to prevent abuse, but maybe you want to change it to #admins, or restrict the trigger to some trusted users or the like...

Code:
; text event: add IPs announced in channel #admin to an ini-file
on $*:text:/^(\S+) \(ID\W\d+\)'s Ip is ((\d{1,3}\.){3}\d{1,3})\.$/:#admin: {
  var %ini = $qt($shortfn($mircdirini\ips.ini))
  ; remove existing entry of that user and that ip
  if ($ini(%ini,$regml(1))) { 
    var %n = 1
    while ($ini(%ini,$regml(1),%n)) {
      if ($readini(%ini,$regml(1),$v1) == $regml(2)) {
        remini -n %ini $regml(1) $ini(%ini,$regml(1),%n) 
        break
      }
      inc %n
    }
  }
  ; and readd (updating the "timestamp") or simply add the entry to to the ini
  writeini -n %ini $regml(1) $ctime $regml(2)
}



; trigger to scan the database for ips: !ip <Name> or !ip <Name> full
on *:text:!ip*:#CnR|LV: {
  var %ini = $qt($shortfn($mircdirini\ips.ini))
  ; no match / error outputs
  if (!$ini(%ini,0)) { msg $chan IP-database is empty. }
  elseif (!$2) { msg $chan No nickname given. Use !ip <nick> }
  elseif (!$ini(%ini,$2,0)) { msg $chan No entry for $qt($2) found. }
  ; loop matches for player
  else {
    var %t = $ini(%ini,$2,0), %ips = IPs used by $2 $+ :
    while ((%t > 0) && ($ini(%ini,$2,%t))) {
      var %stamp = $v1, %ip = $readini(%ini,$2,%stamp)
      var %ips = %ips $iif(($3 == full),$asctime(%stamp,(dd.mm.yy, HH:nn)) $+($chr(2),%ip,$chr(2)),%ip) 
      ; output of matches
      if ($len(%ips) > 300) {
        msg $chan $makestring(%ips)
        var %ips
      }
      dec %t
    }
    if (%ips) { msg $chan $makestring($v1) }
  }
}

; text formatting routine (IP output of !ip)
alias -l makestring { return $regsubex($1-,/(?<=\d\x2|\d)\s/g,$+($chr(32),-,$chr(32))) }



; text trigger for database cleanup: !cleanips <deadline>.
; (restricted to opped users at #CnR|LV) 
on @*:text:!cleanips*:#CnR|LV: { 
  if (($2 !isnum) && ($duration($2-) > 0)) {
    var %ini = $qt($shortfn($mircdirini\ips.ini))
    msg $chan There are currently $ini(%ini,0) players in the database. $&
      Start removing all IPs older than $duration($v1) ...
    set -e %ips.c.duration $v1
    set -e %ips.c.kept 0
    set -e %ips.c.removed 0
    ; init the cleaning (filter through an alias)
    if ($window(@ips.c)) { window -c @ips.c }
    window -h @ips.c
    filter -fk %ini clean.ips
    filter -wfc @ips.c %ini
    window -c @ips.c
    ; remove "dead" nick topics in the ini as well
    var %n = 1
    while ($ini(%ini,%n)) {
      var %name = $v1
      if (!$ini(%ini,%name,1)) { writeini -n %ini %name x y | remini -n %ini %name }
      inc %n
    }
    msg $chan ... Done. IPs kept: %ips.c.kept • IPs removed: %ips.c.removed • $&
      Players remaining in database: $ini(%ini,0) $+ .
    unset %ips.c.*
  }
  else {
    msg $chan Syntax is: !cleanips <deadline> 
    msg $chan e.g. "!cleanips 3d" will remove all entries older than 3 days; $&
      "!cleanips 2 weeks 3 hrs"
  }
}

; ip cleaning routine (filter-alias for !cleanips)
alias -l clean.ips {
  if ($gettok($1,1,61) isnum) { 
    if ($v1 >= $calc($ctime - %ips.c.duration)) { aline @ips.c $1- | inc %ips.c.kept }
    else { inc %ips.c.removed }
  }
  elseif ($1) { aline @ips.c $1- }
}


Edit: trigger names fixed

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Thanks a lot, but it doesn't work.

I joined the game, Tyson (my bot) saw from the in #cnr|lv that i joined, then said !getip 4 and 2 cause I joined twice, returning my ip, so I then trt !p and i get told theres no entries, after the firs one I checked if the .ini had already been created, but it hadn't, so i created it.

Quote:
[23:36] <&Tyson> !getip 4
[23:36] <+CnR|LV> [BT]_Bill (ID:4)'s Ip is 90.206.244.137.
[23:36] <&Tyson> !getip 2
[23:36] <+CnR|LV> [BT]_Bill (ID:2)'s Ip is 90.206.244.137.
[23:37] <&Bill_[BT]> !ip
[23:37] <&Tyson> IP-database is empty


Please help me, also is t possible that people could use !ip <ip> to return nicks that have used the same IP ?

Thanks a lot for your help and replys.

Bill.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Hm, let's do some debugging...
right at the start of the new script part:
Code:
on $*:text:/^(\S+) \(ID\W\d+\)'s Ip is ((\d{1,3}\.){3}\d{1,3})\.$/:#admin: {
  var %ini = $qt($shortfn($mircdirini\ips.ini))


... please change it to (insert a line):
Code:
on $*:text:/^(\S+) \(ID\W\d+\)'s Ip is ((\d{1,3}\.){3}\d{1,3})\.$/:#admin: {
  msg $chan Name: $regml(1) IP: $regml(2)
  var %ini = $qt($shortfn($mircdirini\ips.ini))

... does it now message something (does it 'detected' the text at #admin that says "<Name> (ID: <number>)'s IP is: <someip>.")?
if not, please provide an exact sample of what the bot says (you can change the digits of IPs of course - but keep e.g. control codes, if there are some) smile


Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
I joined the game, it said

Quote:
[00:32] <&Tyson> !getip 2
[00:32] <+CnR|LV> [BT]_Bill (ID:2)'s Ip is 90.206.244.137.
[00:32] <&Tyson> Name: [BT]_Bill IP: 90.206.244.137

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Ok.
The bad news: You (well: we) run into a little problem regarding ini files... They may not contain square bracktes in the section title, but they are a part of your nickname. Something I learned today smile
The script *should* work for nicks w/o square brackets right now...

The good news: It's not hard to fix. I'll post an updated version of the whole script tomorrow (It's already 01:42AM here *g), including the option to scan for "!IP ipnumber" to return matching names.

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Ah ok,
Problem is this;

In #cnr|lv
Quote:
[00:51] <%CnR|LV> Flex(0) Has Joined Cops & Robbers v4.3 Visits: 0


Then is #admin
Quote:
[00:52] <&Tyson> !getip 0
[00:52] <+CnR|LV> Flex (ID:0)'s Ip is 77.100.93.166.
[00:52] <&Tyson> Name: Flex IP: 77.100.93.166


Then back in #cnr|lv
Quote:
[00:52] <&Bill_[BT]> !ip
[00:52] <&Tyson> IP-database is empty.


Also tried
Quote:
[00:54] <&Bill_[BT]> !ip Flex
[00:54] <&Tyson> IP-database is empty.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Disregarding the current $time, here we go again (replace the lengthy recent code with this one) smile

Code:
; text event: add IPs announced in channel #admin to an ini-file
on $*:text:/^(\S+) \(ID\W\d+\)'s Ip is ((\d{1,3}\.){3}\d{1,3})\.$/:#admin: {
  var %ini = $qt($shortfn($mircdirini\ips.ini)), %name = $replace($regml(1),[,$chr(40),],$chr(41))
  ; remove existing entry of that user and that ip
  if ($ini(%ini,%name)) { 
    var %n = 1
    while ($ini(%ini,%name,%n)) {
      if ($readini(%ini,%name,$v1) == $regml(2)) {
        remini -n %ini %name $ini(%ini,%name,%n) 
        break
      }
      inc %n
    }
  }
  ; and readd (updating the "timestamp") or simply add the data to to the ini
  writeini -n %ini %name $ctime $regml(2)
}



; trigger in chan #CnR|LV  to scan the database for ips (!ip <Name> [full]) or names (!ip <IP> [full]) 
on *:text:!ip*:#CnR|LV: {
  var %ini = $qt($shortfn($mircdirini\ips.ini)), %name = $replace($2,[,$chr(40),],$chr(41))
  var %reg = /^(?:\d{1,3}\.){3}\d{1,3}$/, %isIP = $iif($regex(%name,%reg),$true,$false)
  ; no match / error outputs
  if (!$2) {
    msg $chan No nickname/IP given. Use !ip <name> to get matching IPs, $&
    or !ip <IP> to get matching names. You can use "full" as second parameter.
  }
  elseif (!$ini(%ini,0)) { msg $chan IP-database is empty. }

  ; scan for name matches
  elseif (!%isIP) {
    if (!$ini(%ini,%name,0)) { msg $chan No entry for Name $qt($2) found. }
    ; loop matches for player name
    else {
      var %t = $ini(%ini,%name,0), %ips = $+($chr(31),IPs used by $2,$chr(15),:)
      while ((%t > 0) && ($ini(%ini,%name,%t))) {
        var %stamp = $v1, %ip = $readini(%ini,%name,%stamp)
        var %ips = %ips $iif(($3 == full),$+($chr(2),%ip,$chr(2)) $asctime(%stamp,(dd.mm.yy, HH:nn)),%ip) 
        ; output of matches
        if ($len(%ips) > 300) {
          msg $chan $makestringIP(%ips)
          var %ips
        }
        dec %t
      }
      if (%ips) { msg $chan $makestringIP($v1) }
    }
  }

  ; scan for IP matches
  else {
    var %reg = $+(/^\[|,$replace(%name,.,\.),$/), %tempini = $qt($shortfn($mircdirini\ipsTEMP.ini))
    ; filter the ini to a temporary ini, removing everything that's no ini topic or IP match
    filter -ffcg %ini %tempini %reg
    ; replace the matched IP in the data part of ini items with the player name (ini topic)
    var %n = 1
    while ($ini(%tempini,%n)) {
      var %topic = $v1
      if ($ini(%tempini,%topic,1)) { writeini -n %tempini %topic $v1 %topic }
      inc %n
    }
    ; filter tempini to remove ini topics (no longer needed), sort it (get timestamps in order)
    filter -ffcgxteu 1 61 %tempini %tempini ^\[
    ; no matches (no lines left)
    if (!$read(%tempini,1)) { msg $chan No entry for IP %name found. }
    ; loop and output the filtered matches 
    else {
      var %n = 1, %names = $+($chr(31),Names used on IP %name,$chr(15),:)
      while ($read(%tempini,%n)) {
        var %stamp = $gettok($v1,1,61), %player = $replace($gettok($v1,2,61),$chr(40),[,$chr(41),])
        var %names = %names $iif(($3 == full),$+($chr(2),%player,$chr(2)) $asctime(%stamp,(dd.mm.yy, HH:nn)),%player) 
        if ($len(%names) > 300) {
          msg $chan $makestringN(%names)
          var %names
        }
        inc %n
      }
      if (%names) { msg $chan $makestringN(%names) }
      .remove %tempini
    }
  }
}

; text formatting routines (output of !ip)
alias -l makestringIP { return $regsubex($1-,/(?<=\d\51|\d)\s/g,$+($chr(32),-,$chr(32))) }
alias -l makestringN { return $regsubex($1-,/(?<=\d\51)\s/g,$+($chr(32),-,$chr(32))) }



; text trigger for database cleanup: !cleanips <deadline>.
; (restricted to opped users at #CnR|LV) 
on @*:text:!cleanips*:#CnR|LV: { 
  if (($2 !isnum) && ($duration($2-) > 0)) {
    var %ini = $qt($shortfn($mircdirini\ips.ini))
    msg $chan There are currently $ini(%ini,0) players in the database. $&
      Start removing all IPs older than $duration($v1) ...
    set -e %ips.c.duration $v1
    set -e %ips.c.kept 0
    set -e %ips.c.removed 0
    ; init the cleaning (filter through an alias)
    if ($window(@ips.c)) { window -c @ips.c }
    window -h @ips.c
    filter -fk %ini clean.ips
    filter -wfc @ips.c %ini
    window -c @ips.c
    ; remove "dead" nick topics in the ini as well
    var %n = 1
    while ($ini(%ini,%n)) {
      var %name = $v1
      if (!$ini(%ini,%name,1)) { writeini -n %ini %name x y | remini -n %ini %name }
      inc %n
    }
    msg $chan ... Done. IPs kept: %ips.c.kept • IPs removed: %ips.c.removed • $&
      Players remaining in database: $ini(%ini,0) $+ .
    unset %ips.c.*
  }
  else {
    msg $chan Syntax is: !cleanips <deadline> 
    msg $chan e.g. "!cleanips 3d" will remove all entries older than 3 days; $&
      "!cleanips 2 weeks 3 hrs"
  }
}

; ip cleaning routine (filter-alias for !cleanips)
alias -l clean.ips {
  if ($gettok($1,1,61) isnum) { 
    if ($v1 >= $calc($ctime - %ips.c.duration)) { aline @ips.c $1- | inc %ips.c.kept }
    else { inc %ips.c.removed }
  }
  elseif ($1) { aline @ips.c $1- }
}


According to my tests it's working now as expected. Note that I was testing in a single channel (changing the #channels in the on text definition), but this shouldn't be an issue. And note that I act like the "bot" (the one with the script), while I use [Bot] to trigger the inputs :-)

[&Bot] •• !ip test
<~Horstl> IP-database is empty.

now I was first adding some IPs (10) and nicks (6)

[&Bot] •• Testnick (ID:123)'s Ip is 123.123.123.1.
[&Bot] •• Testnick (ID:123)'s Ip is 123.123.123.2.
[&Bot] •• {weird}|nick[x] (ID:77)'s Ip is 77.77.77.7.
[&Bot] •• Testnick (ID:123)'s Ip is 321.321.321.3.
[&Bot] •• {weird}|nick[x] (ID:77)'s Ip is 88.88.88.8.
[&Bot] •• XYZ (ID:5)'s Ip is 2.2.2.2.
[&Bot] •• {weird}|nick[x] (ID:77)'s Ip is 99.99.99.9.
[&Bot] •• Faker (ID:10)'s Ip is 321.321.321.3.
[&Bot] •• Faker2 (ID:11)'s Ip is 88.88.88.8.
[&Bot] •• Faker3 (ID:99)'s Ip is 321.321.321.3.

And started the testing...

<~Horstl> !ip testnick
[&Bot] •• !ip testnick
<~Horstl> IPs used by testnick: 321.321.321.3 - 123.123.123.2 - 123.123.123.1
[&Bot] •• !ip {weird}|nick[x]
<~Horstl> IPs used by {weird}|nick[x]: 99.99.99.9 - 88.88.88.8 - 77.77.77.7
[&Bot] •• !ip {weird}|nick[x] full
<~Horstl> IPs used by {weird}|nick[x]: 99.99.99.9 (02.11.08, 02:58) - 88.88.88.8 (02.11.08, 02:57) - 77.77.77.7 (02.11.08, 02:57)
[&Bot] •• !ip 88.88.88.8
<~Horstl> Names used on IP 88.88.88.8: Faker2 {weird}|nick[x]
[&Bot] •• !ip 88.88.88.8 full
<~Horstl> Names used on IP 88.88.88.8: Faker2 (02.11.08, 02:59) - {weird}|nick[x] (02.11.08, 02:57)
[&Bot] •• !ip 5.5.5.5
<~Horstl> No entry for IP 5.5.5.5 found.
[&Bot] •• !ip
<~Horstl> No nickname/IP given. Use !ip <name> to get matching IPs, or !ip <IP> to get matching names. You can use "full" as second parameter.
[&Bot] •• !ip Abc
<~Horstl> No entry for Name "Abc" found.
[&Bot] •• !ip Faker
<~Horstl> IPs used by Faker: 321.321.321.3
[&Bot] •• !ip Faker2
<~Horstl> IPs used by Faker2: 88.88.88.8
[&Bot] •• !cleanips 3hrs
<~Horstl> There are currently 6 players in the database. Start removing all IPs older than 3hrs ...
<~Horstl> ... Done. IPs kept: 10 • IPs removed: 0 • Players remaining in database: 6.
[&Bot] •• !cleanips 5mins
<~Horstl> There are currently 6 players in the database. Start removing all IPs older than 5mins ...
<~Horstl> ... Done. IPs kept: 5 • IPs removed: 5 • Players remaining in database: 5.

The only -minor- issue I found is the "players removed in database" info showing a "wrong" value due to strange /remini behaviour (It the ini topic holds no items, /remini refuses to remove the topic - I'm thus adding a dummy value in the cleaning procedure and /remove the topic right after, but sometimes this is failing, too). Repetitive cleaning will show the right count.

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Thank you, but it still isnt working, for me.

Do I have to create the "ips.ini" ?

If so, where ?

EDIT;


Just to show what it does..

Quote:
[13:36] <&Bill_[BT]> !ip
[13:36] <&Tyson> No nickname/IP given. Use !ip <name> to get matching IPs, or !ip <IP> to get matching names. You can use "full" as second parameter.
[13:36] <&Bill_[BT]> !ip [BT]Eirike93

Last edited by Billl; 02/11/08 01:36 PM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
The ini *should* be created by the script itself, and *should* have accumulated some data in the meantime as well.
It's located at a subdirectory of your mIRCS "main" directory (the place where mirc is storing basic settings in e.g. the mirc.ini).
To see the exact location the script is pointing to, type (or paste) in a window:
Code:
//echo -a $mircdirini\ips.ini

The script itself is refering to:
Code:
//echo -a $qt($shortfn($mircdirini\ips.ini))
...which is technically the same, just a "short filename" version of that location with quotation marks arround it, to play safe (as there may be spaces in a file path that else can cause errors in connection with certain script commands etc).

Do you find the ips.ini there?
If yes, is it empty?
If it's not empty - please remove it, the script will create it again.

I can hardly think of a reason why the script should not write to it, maybe someone else reading this post has...
The text event which performs the /writeini is working as well,'cause you confirmed yesterday that the "extra" line produced messages at #admins.

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Okay, well, I created the folder "ini" and put ips.ini in thee, it wors like a charm now, if I have any problems ill post back here.

Thank you so much.

Bill.

EDIT;

Quote:
[18:50] <&Bill_[BT]> !ip Jojo
[18:50] <&Tyson> IPs used by Jojo: 92.236.254.125
[18:50] <&Bill_[BT]> !ip 92.236.254.125


Then nothing happend frown

Last edited by Billl; 02/11/08 06:50 PM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Weird... did you use the new code and replaced (deleted) the old one? (that is, replaced all the older code, besides the "small" on text event of your initial request, which is sending the player ID to #admins. The older code did not include a scan for IPs.)

Only if you already use the new code but without success, now replace in it ONLY the 2nd "on text" event with the following one - I added some "debugging echos" to it.

Code:
; trigger in chan #CnR|LV  to scan the database for ips (!ip <Name> [full]) or names (!ip <IP> [full]) 
on *:text:!ip*:#CnR|LV: {
  var %ini = $qt($shortfn($mircdirini\ips.ini)), %name = $replace($2,[,$chr(40),],$chr(41))
  var %reg = /^(?:\d{1,3}\.){3}\d{1,3}$/, %isIP = $iif($regex(%name,%reg),$true,$false)
  ECHO 7 -a scan for %name at ini= %ini - isIP= %isIP
  ; no match / error outputs
  if (!$2) {
    msg $chan No nickname/IP given. Use !ip <name> to get matching IPs, $&
      or !ip <IP> to get matching names. You can use "full" as second parameter.
  }
  elseif (!$ini(%ini,0)) { msg $chan IP-database is empty. }

  ; scan for name matches
  elseif (!%isIP) {
    ECHO 7 -a scan for name matches
    if (!$ini(%ini,%name,0)) { msg $chan No entry for Name $qt($2) found. }
    ; loop matches for player name
    else {
      var %t = $ini(%ini,%name,0), %ips = $+($chr(31),IPs used by $2,$chr(15),:)
      while ((%t > 0) && ($ini(%ini,%name,%t))) {
        var %stamp = $v1, %ip = $readini(%ini,%name,%stamp)
        var %ips = %ips $iif(($3 == full),$+($chr(2),%ip,$chr(2)) $asctime(%stamp,(dd.mm.yy, HH:nn)),%ip) 
        ; output of matches
        if ($len(%ips) > 300) {
          msg $chan $makestringIP(%ips)
          var %ips
        }
        dec %t
      }
      if (%ips) { msg $chan $makestringIP($v1) }
    }
  }

  ; scan for IP matches
  else {
    ECHO 7 -a scan for IP matches
    var %reg = $+(/^\[|,$replace(%name,.,\.),$/), %tempini = $qt($shortfn($mircdirini\ipsTEMP.ini))
    ; filter the ini to a temporary ini, removing everything that's no ini topic or IP match
    filter -ffcg %ini %tempini %reg
    ECHO 7 -a TEMPINI $iif(($isfile(%tempini)),created (filter) at %tempini - $lines(%tempini) lines,not created)
    ; replace the matched IP in the data part of ini items with the player name (ini topic)
    var %n = 1
    while ($ini(%tempini,%n)) {
      var %topic = $v1
      if ($ini(%tempini,%topic,1)) { writeini -n %tempini %topic $v1 %topic }
      inc %n
    }
    ; filter tempini to remove ini topics (no longer needed), sort it (get timestamps in order)
    filter -ffcgxteu 1 61 %tempini %tempini ^\[
    ECHO 7 -a results in tempini: $lines(%tempini)
    ; no matches (no lines left)
    if (!$read(%tempini,1)) { msg $chan No entry for IP %name found. }
    ; loop and output the filtered matches 
    else {
      var %n = 1, %names = $+($chr(31),Names used on IP %name,$chr(15),:)
      while ($read(%tempini,%n)) {
        ECHO 7 -a output match %n = $v1
        var %stamp = $gettok($v1,1,61), %player = $replace($gettok($v1,2,61),$chr(40),[,$chr(41),])
        var %names = %names $iif(($3 == full),$+($chr(2),%player,$chr(2)) $asctime(%stamp,(dd.mm.yy, HH:nn)),%player) 
        if ($len(%names) > 300) {
          msg $chan $makestringN(%names)
          var %names
        }
        inc %n
      }
      if (%names) { msg $chan $makestringN(%names) }
      ECHO 7 -a output done, removing tempini
      .remove %tempini
    }
  }
}

(the code you keep should continue with "; text formatting routines (output of !ip)")


Triggering an !ip <ip> now should show some extra info in the client with the script, like:

<user> !ip 92.236.254.125
scan for 92.236.254.125 at ini= "D:\PROGRA~1\mirc\ini\ips.ini" - isIP= $true
scan for IP matches
TEMPINI created (filter) at "D:\Programme\mirc\ini\ipsTEMP.ini" - 5 lines
results in tempini: 2
output match 1 = 1225655661=testnick
output match 2 = 1225652797=Jojo
<client with script> Names used on IP 92.236.254.125: testnick Jojo
output done, removing tempini

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
right, I put it in, now nothing at all.

Quote:
[23:30] <&Tyson> !getip 0
[23:30] <+CnR|LV> [BT]_Bill (ID:0)'s Ip is 90.206.230.106.
[23:31] <&Tyson> !getip 1
[23:31] <+CnR|LV> Sam_Smith (ID:1)'s Ip is 70.27.4.179.
[23:34] <&Bill_[BT]> !ip 90.206.230.106.
[23:35] <&Bill_[BT]> !ip [bt]_bill


did nothing frown
thanks

Bill.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I tested again with 2 diff. chans... unable to reproduce your problems.
I assume there's something mixed up in your current file.
I added all the parts of this thread again to a single scriptfile for you to download. Just remove everything (!) you have added so far (including the "msg #admin !getip" thing), and load this file instead.

playerips.mrc (right click > save as...)

If it's working finally, you can get rid of the additional messages if you remove every line that is starting with: "ECHO 7 $chan" (a total of 8 lines).

Edit: Ah, and the !ip and !cleanips triggers are set to the players channel, not the admins channel... not that a simple misapprehension caused the troubles smile

Last edited by Horstl; 03/11/08 01:25 AM.
Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Meh, it still isnt working.

Look;

Quote:
[02:01] <&Bill_[BT]> !ip testnick
[02:01] <&Tyson> IPs used by tertnick: 90.206.230.106
[02:01] <&Bill_[BT]> !ip 90.206.230.106
[02:01] <&Bill_[BT]> !ip 90.206.230.106
[02:01] <&Bill_[BT]> !ip 90.206.230.106.
[02:01] <&Tyson> No entry for Name "90.206.230.106." found.


:s

Thanks for the time your putting into this for me, Horstl.

Bill.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
There has to be extra "echo" outputs in the channel window (#CnR|LV ) of Tyson... 2 lines for !ip <testnick> and some more for !ip <an IP>. The latter are of most interrest.

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
when I do !ip <ip> i see this error in the status window -

Quote:
* No such identifier: $/ (line 80, playerips)


Which is this line;

Code:
    var %reg = $+(/^\[|,$replace(%name,.,\.),$/), %tempini = $qt($shortfn($mircdirini\ipsTEMP.ini))



Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Oh, my fault. replace it with:
Code:
var %reg = $+(/^\[|,$replace(%name,.,\.),$chr(36),/), %tempini = $qt($shortfn($mircdirini\ipsTEMP.ini))


I have identifier warnings disabled, thus it passed in my tests smile

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
heh:p

Okay, well it still doesnt work, but in the Bot's client windown this happens,

Quote:
[03:22] <Bill_[BT]> !ip 90.206.230.106
scan for 90.206.230.106 at ini= "C:\Users\Bill\Desktop\MIRCST~1.0\ini\ips.ini" - isIP= $true
scan for IP matches
tempini not created
results in tempini: 0
[03:23] <Bill_[BT]> !ip [BT]_Bill
scan for (BT)_Bill at ini= "C:\Users\Bill\Desktop\MIRCST~1.0\ini\ips.ini" - isIP= $false
scan for name matches
[03:23] <Tyson> IPs used by [BT]_Bill: 90.206.230.106


Bill.

EDIT;

This is in the status window,

Quote:
* $read: invalid parameters (line 94, ipstorage)


Which is this line;

Code:
    if (!$read(%tempini,1)) { msg $chan No entry for IP %name found. }

Last edited by Billl; 03/11/08 03:28 AM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
The regex was an annoying typo by me.

But I really don't understand why, on your system, it's not filtering the "ips.ini" to a "ipsTEMP.ini" - in the very same directory. The $read-error is successive, caused by the ini not being created - the main problem.
Whatever the regex is matching: all lines or no line at all ... the /filter command should create that tempini (maybe an empty one, indicating no matches).

Maybe someone in the forums may be able to provide help/insight on this. smile
(download-file updated (the fixed regex))

I picked a "filter, then writeini in matching lines, and filter again"-method as it should perform much faster than a while-loop through all entries of all ini topics for matching data parts...

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Guess we'l just have to wait and see if someone can help frown

Will the version of mirc I am running the bot on effect this ?

It's running of version 6.17

I really don't want to change the version as it would mean moving every script I have associated with it frown

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Why would you have to move the scripts?
Just run the installer for mIRC 6.35 and choose the Upgrade option. All of your scripts and setting will be retained for usage with 6.35.

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Well you see the base of my bot is a bot I downloaded called "mIRCStorm" and I've just been building to it adding scripts etc so it would confuse me, I'll only attempt it if I have to.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
The file below's now using the filter method like it did before, but is storing the "temp data" in a temporary, hidden mIRC window instead of a temporary .ini file - hopefully this will bypass your issue with !ip <ip>.

The !cleanips command uses the filter command too (again in connection with a hidden mIRC window). But as it seems to me that - on your system - the script is able to write data to the ips.ini, just unable to /filter that .ini to a ipsTEMP.ini, I suppose it will work none the less. (As !cleanips is filtering the cleaned data back to that already-existing ips.ini)

playerips(new).mrc

I removed the "ECHO 7 $chan" lines (orange color debug output) as well.


Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Horstl, Thank yo very much for all of your help with this script. It works fine now.

I will be able to catch the ban evaders so easily now. Thanks again.

Bill.

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Hi, sorry about this, but I am back.

I'm just wondering is it possible to make it so I can search with just part of an ip.

Example;
!ip 90.210.*.*
or just
!ip 90.210.30.*

It will then return the name's who were on the IP's starting wth the given digits, regardless of what the remaining, unwritten digits.

Thank you.

Bill.

Last edited by Billl; 05/11/08 05:24 PM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Wildcard matching itself isn't a big problem (as the script already uses /filter in the part that is scanning for IPs) - it's more the output part.
To make it clever/useful, I have to modify it in some way. I was thinking about:

1) if a wildcard mask was given: add which IP was matched (I intend to put this in the "full" part)
2) don't show the same name 5 times if 5 IPs of that name were matched by a wildmask. That is: not "Name1 Name1 Name2 Name1 Name3 Name1 Name3 Name3 Name1" but something like: "Name1 (5x) Name2 Name3 (3x)", for the regular output (not "full")

Besides that, someone triggering a *.*.*.* would spam the whole dataset to the channel...

If I only had known in the beginning, I'd have used hash tables and $hfind instead of a (more stable, but less flexible) ini storage approach. wink

I'll have a look at it later on.

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
Yeah sorry for not letting you know before.
It's just I was looking at it and I thought that's how it would work better.
Thanks for taking a look, dont take this as a priority.

Thanks, Bill.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559

playerips(new2).mrc

You now can use both the ? and * wildcards in "!ip <IP>" scans. I fixed some other things as well.
While "*" will match 1-3 digits, "?" will match exactly one digit and "???" exactly 3 digits. ?4* thus will match 14 and 347, but won't match 41 or 4.
Known limitation: I extended the "user wants an scan for IP" regex just a bit (quickly) - therefore, you have to provide one, two or three chars per IP 'octet' (be it digits or wildcards), to make a valid <IP> input. You cannot use e.g. *44*, but have to scan for both 44* and *44 separately - I hope that's no big prob smile
I did my best to keep the new outputs uniform - all matches remain sorted by "age". The output of a "verbose wildcard scan for IPs" with many matches may be hard to read, none the less...

request: !ip <Name>
reply: IPs used by <Name>: IP1 - IP2 - IP3 (...)
request: !ip <Name> full
reply: IPs used by <Name>: IP1 (date, time) - IP2 (date, time) - IP3 (date, time) (...)
request: !ip <IP>
reply: Names used on IP <IP>: Name1 - Name2 - Name3 (...)
request: !ip <IP> full
reply: Names used on IP <IP>: Name1 (date, time) - Name2 (date, time) - Name3 (date, time) (...)
request: !ip <wildmask>
reply: Names used on IPrange <wildmask>: Name1 (2x) - Name2 - Name3 (6x) - Name4 (...)
request: !ip <wildmask> full
reply: Names used on IPrange <wildmask>: Name1: IPmatch (date, time) - Name2: IPmatch (date, time) (...)

Regarding the aforementioned risk ((excess) flood) of "!ip *.*.*.*", wilcard scans will return the search result only if there are <= 20 matches. If there are more matches, a message "Try again with a more specific range" is given. (You can change this value at line 95)

Joined: Oct 2008
Posts: 26
B
Billl Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2008
Posts: 26
It works, perfect, Thank you so much Horstl.
I wish I was as good as you at this frown

Last edited by Billl; 06/11/08 02:27 PM.
Page 1 of 2 1 2

Link Copied to Clipboard