| View previous topic :: View next topic |
| Author |
Message |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sat Mar 02, 2019 6:55 pm Post subject: get info of user on connect with bind raw notice |
|
|
greetings we have an opered bot on an unrealircd 4 server and wanted to get the nick ident host ip from this server notice
-some.irc.server- : *** Client connecting: Nick (ident@host) [IP] {clients}
we where using this for another ircd type (not unrealircd) i was wondering if someone famliar with regexp to alter it to get the mentioned info fields out of the regex would be apreciated
we wanted to get: NICK IDENT HOST IP
output on channel with
puthelp "PRIVMSG #test :$nick $ident $host $ip
| Code: |
bind raw - NOTICE serv:connectnick
proc serv:connectnick {from keyword text} {
global outputchan
if {[string match -nocase "*client connecting*" $text]} {
set nick [lindex [split $text] 3]
set ident [lindex [split $text] 4]
set host [lindex [split $text] 5]
set ip [lindex [split $text] 6]
putquick "PRIVMSG #test : $nick $ident $host $ip"
return 0
}
}
|
Last edited by simo on Sun Mar 03, 2019 1:46 pm; edited 4 times in total |
|
| Back to top |
|
 |
heartbroken Op

Joined: 23 Jun 2011 Posts: 106 Location: somewhere out there
|
Posted: Sat Mar 02, 2019 9:56 pm Post subject: |
|
|
| Code: | bind raw - NOTICE serv:connectnick
proc serv:connectnick {from key text} {
if {[string match *!*@* $from] || ![string match -nocase "*Client connecting*" $text]} { return }
if {[scan [lindex [split $text :] 2] {%[^(](%[^@]@%[^)]) [%[^]]} Nick ident host IP] == 4} {
puthelp "PRIVMSG #test :$Nick $ident $host $IP"
}
return 0
} |
_________________ Life iS Just a dReaM oN tHE wAy to DeaTh |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sun Mar 03, 2019 12:01 pm Post subject: |
|
|
| working nicely thanx heartbroken apreciated |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sun Mar 03, 2019 6:10 pm Post subject: |
|
|
i forgot to ask about ssl as well as some clients connect with ssl
and that changes the output i fiddled with it somewhat but couldnt get it to proper output
*** Client connecting: nick (ident@host) [ip] {clients} [secure ECDHE-RSA-AES256-SHA]
to output
| Quote: |
puthelp "PRIVMSG #test :$nick $ident $host $ip $client $ssl"
|
|
|
| Back to top |
|
 |
heartbroken Op

Joined: 23 Jun 2011 Posts: 106 Location: somewhere out there
|
Posted: Sun Mar 03, 2019 8:58 pm Post subject: |
|
|
| Code: | bind raw - NOTICE serv:connectnick
proc serv:connectnick {from key text} {
if {[string match *!*@* $from] || ![string match -nocase "*Client connecting*" $text]} { return }
if {[scan [lindex [split $text :] 1] {%[^(](%[^@]@%[^)]) [%[^]]]%[^[][%[^]]} Nick ident host IP client ssl] == 6} {
puthelp "PRIVMSG #test :$Nick $ident $host $IP $client $ssl"
} else {
scan [lindex [split $text :] 2] {%[^(](%[^@]@%[^)]) [%[^]]} Nick ident host IP
puthelp "PRIVMSG #test :$Nick $ident $host $IP"
}
return 0
} |
_________________ Life iS Just a dReaM oN tHE wAy to DeaTh
Last edited by heartbroken on Sun Mar 03, 2019 9:52 pm; edited 1 time in total |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sun Mar 03, 2019 9:31 pm Post subject: |
|
|
| tried it and both ssl and non ssl users seem to output first one without the client and ssl |
|
| Back to top |
|
 |
heartbroken Op

Joined: 23 Jun 2011 Posts: 106 Location: somewhere out there
|
Posted: Sun Mar 03, 2019 9:57 pm Post subject: |
|
|
my bad! code edited. _________________ Life iS Just a dReaM oN tHE wAy to DeaTh |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sun Mar 03, 2019 10:01 pm Post subject: |
|
|
hm same result i dont see any {} tho in the code since its used by {clients}
in:
| Quote: |
*** Client connecting: nick (ident@host) [ip] {clients} [secure ECDHE-RSA-AES256-SHA] |
|
|
| Back to top |
|
 |
heartbroken Op

Joined: 23 Jun 2011 Posts: 106 Location: somewhere out there
|
Posted: Sun Mar 03, 2019 10:37 pm Post subject: |
|
|
it works on tclsh and should work with eggdrop too.
if you don't want to see {} around "clients" : [regsub -all {\{|\}} $client {}] _________________ Life iS Just a dReaM oN tHE wAy to DeaTh |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sun Mar 03, 2019 10:50 pm Post subject: |
|
|
hm ok
all i get as output for both sll and non ssl is
| Quote: |
nick ident host ip |
|
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sun Mar 03, 2019 10:53 pm Post subject: |
|
|
the [lindex [split $text :] 1] part was off i changed to [lindex [split $text :] 2]
then it worked
excellent thank u very much apreciated |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Tue Jun 09, 2020 7:50 pm Post subject: |
|
|
i tried this in unreal5 and it didnt seem to work no more
these are the 2 example server notices for ssl and non ssl
ssl
| Quote: |
*** Client connecting: RandomONE (uid304591@id-304591.tooting.irccloud.com) [2001:67c:2f08:4:0:0:4:a5cf] {clients} [secure ECDHE-RSA-AES256-GCM-SHA384]
|
non ssl
| Quote: |
*** Client connecting: RandomONE (uid304591@id-304591.tooting.irccloud.com) [2001:67c:2f08:4:0:0:4:a5cf] {clients}
|
using this:
| Code: |
bind raw - NOTICE serv:connectnick
proc serv:connectnick {from key text} {
if {[string match *!*@* $from] || ![string match -nocase "*Client connecting*" $text]} { return }
if {[scan [lindex [split $text :] 2] {%[^(](%[^@]@%[^)]) [%[^]]]%[^[][%[^]]} Nick ident host IP client ssl] == 6} {
puthelp "PRIVMSG #test :$Nick $ident $host $IP $client $ssl"
} else {
scan [lindex [split $text :] 2] {%[^(](%[^@]@%[^)]) [%[^]]} Nick ident host IP
puthelp "PRIVMSG #test :$Nick $ident $host $IP"
}
return 0
} |
when using both ssl and non ssl i get this output:
| Quote: |
RandomONE uid304591 id-304591.tooting.irccloud.com 2001
|
|
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Wed Jun 10, 2020 8:16 am Post subject: |
|
|
| i tested again and it seems to work for ipv4 only for ipv6 it doesnt seem to get all the info |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Sat Dec 11, 2021 10:46 pm Post subject: |
|
|
apparently the code only works in unrealircd but does not work in inspircd it is possible to use regex to work in both unreal and inspircd versions
| Code: |
bind raw - NOTICE serv:connectnick
proc serv:connectnick {from key text} {
if {[string match *!*@* $from] || ![string match -nocase "*Client connecting*" $text]} { return }
if {[scan [lindex [split $text :] 2] {%[^(](%[^@]@%[^)]) [%[^]]]%[^[][%[^]]} Nick ident host IP client ssl] == 6} {
puthelp "PRIVMSG #test :$Nick $ident $host $IP $client $ssl"
} else {
scan [lindex [split $text :] 2] {%[^(](%[^@]@%[^)]) [%[^]]} Nick ident host IP
puthelp "PRIVMSG #test :$Nick $ident $host $IP"
}
return 0
} |
example variant regex (compatibility for both unreal and inspircd)
| Code: | | {[regexp {CONNECT: Client connecting[.A-Za-z0-9 ]*: ([^ ]+) \\(([^@]+)@([^\\)]+)\\) \\[([0-9\\.]+)\\].*} $arg } |
but the variant does not work someone who can help please. _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Sun Dec 12, 2021 12:16 pm Post subject: |
|
|
each ircd has its own server notice for connections and disconnections
so u cant have 1 to work for both its either one or the other
this is for inspircd
| Code: |
bind raw - NOTICE serv:connectnick
proc serv:connectnick {from key text} {
if {[string match *!*@* $from]} { return }
if {![regexp -nocase { CONNECT: Client connecting on port (\d+) \(class (\S+)\): ([^!]+)!([^@]+)@(\S+) \(([0-9a-f.:]+)\) \[(.*)\]} $text -> port class nick ident host ip realname]} { return }
puthelp "PRIVMSG #test :$nick $ident $host $ip"
return 0
} |
|
|
| Back to top |
|
 |
|