This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

get info of user on connect with bind raw notice

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

get info of user on connect with bind raw notice

Post by simo »

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: Select all


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.
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

Code: Select all

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
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

working nicely thanx heartbroken apreciated
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

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
puthelp "PRIVMSG #test :$nick $ident $host $ip $client $ssl"
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

Code: Select all

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
}
Last edited by heartbroken on Sun Mar 03, 2019 9:52 pm, edited 1 time in total.
Life iS Just a dReaM oN tHE wAy to DeaTh
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tried it and both ssl and non ssl users seem to output first one without the client and ssl
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

my bad! code edited.
Life iS Just a dReaM oN tHE wAy to DeaTh
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

hm same result i dont see any {} tho in the code since its used by {clients}
in:
*** Client connecting: nick (ident@host) [ip] {clients} [secure ECDHE-RSA-AES256-SHA]
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

Image

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
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

hm ok

all i get as output for both sll and non ssl is
nick ident host ip
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

the [lindex [split $text :] 1] part was off i changed to [lindex [split $text :] 2]

then it worked

excellent thank u very much apreciated
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

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

*** 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
*** Client connecting: RandomONE (uid304591@id-304591.tooting.irccloud.com) [2001:67c:2f08:4:0:0:4:a5cf] {clients}

using this:

Code: Select all

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:

RandomONE uid304591 id-304591.tooting.irccloud.com 2001
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tested again and it seems to work for ipv4 only for ipv6 it doesnt seem to get all the info
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

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: Select all

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: Select all

 {[regexp {CONNECT: Client connecting[.A-Za-z0-9 ]*: ([^ ]+) \\(([^@]+)@([^\\)]+)\\) \\[([0-9\\.]+)\\].*} $arg } 
but the variant does not work someone who can help please.
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

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: Select all

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
} 
Post Reply