egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Connect LookUp

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Furbs
Voice


Joined: 01 Oct 2008
Posts: 7
Location: Adealide, South Australia, Australia

PostPosted: Wed Oct 01, 2008 9:39 pm    Post subject: Connect LookUp Reply with quote

Hey all, long time visitor, first time poster Wink

was wondering if i could get a bit of help

what i want is, my eggdrop will get a line, example: [03:01] <OperServ> 4CONNECT on server 12nick!host@stuff (ip) and i want it to, dns the IP, and if it resolves to Australian or New Zealand, to increase a variable (Based on the resolution of their IP). Kiwi = New Zealand and aussie = Australian Smile

its pretty simple and that, but just having problems Sad

so far i've got

Code:

bind pubm f * check:connect

proc check:connect { nick host hand chan arg } {
        global kiwi,aussie
        putlog [lindex $arg 0]
        if { "4CONNECT" == [lindex $arg 0] } {
                putserv "PRIVMSG #sl-oceania :woahh new increase $counter"
        }
}


FYI, the putlog [lindex $arg 0] is returning [03:05] 4CONNECT

and its not getting pass the if

Thanks for the help Smile
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Furbs
Voice


Joined: 01 Oct 2008
Posts: 7
Location: Adealide, South Australia, Australia

PostPosted: Wed Oct 01, 2008 10:23 pm    Post subject: Reply with quote

ok i've made some more improvements,

it catches when Operserv says CONNECT

so now i just need someone to make it dns the IP and determine where its from Smile

heres what i've got so far

Code:

bind pubm f * check:connect

proc check:connect { nick host hand chan arg } {
        if {([string match -nocase "*connect*" [lindex $arg 0]])} {
                regexp "(\[0-9]{1,3})\.(\[0-9]{1,3})\.(\[0-9]{1,3})\.(\[0-9]{1,3})" [lindex $arg 4] all first second third fourth
                putserv "PRIVMSG #sl-oceania :$all"
        }
}


and it msg's the channel with

[11:52:13] <@Shiela> 123.456.789.011 (Example IP address Smile )
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Oct 02, 2008 9:26 am    Post subject: Reply with quote

Use the dnslookup function and appropriate callback. This skeleton code should help you get started.

Code:
proc dns_callback {ip host status args} {
 global kiwi aussie
 if {$status} {
  switch -glob $host {
   *.nz {incr kiwi}
   *.au {incr aussie}
  }
 }
}

proc yourproc ....
...
 dnslookup $thehost
...
}


Also, a comment on both posts: don't use lindex and other list operations on strings. If you have to convert a string into a list, use the split command. It seems you are having problems with control-codes (ctrl+c for colors in this case), consider scrubbing the string using the stripcodes command.

Both dnslookup and stripcodes are documented in doc/tcl-commands.doc, and lindex and split are documented in the tcl manual ("man n lindex" or http://www.tcl.tk/man/tcl8.3/TclCmd/lindex.htm)
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Furbs
Voice


Joined: 01 Oct 2008
Posts: 7
Location: Adealide, South Australia, Australia

PostPosted: Thu Oct 02, 2008 10:36 am    Post subject: Reply with quote

Code:

bind pubm f * check:connect

set aussie "0"
set kiwis "0"

proc check:connect { nick host hand chan arg } {
        if {([string match -nocase "*connect*" [lindex $arg 0]])} {
                set nick [lindex $arg 5]
                regexp "(\[0-9]{1,3})\.(\[0-9]{1,3})\.(\[0-9]{1,3})\.(\[0-9]{1,3})" [lindex $arg 4] all
                putserv "PRIVMSG #sl-oceania :$all"
                dnslookup $all resolve_rep
        }
        if {[string match -nocase "*join*" [lindex $arg 2]]} {
                putserv "PRIVMSG #sl-oceania :$arg !"
        }
}

proc resolve_rep {ip host status} {
        global aussie kiwis
        if {!$status} { putlog "Unable to resolve \037\002$ip\017 ."
        } else {
                if {[string match -nocase "*.au" $host]} {
                        set newnumber [expr $aussie + 1]
                        set aussie $newnumber
                        putserv "privmsg #sl-oceania :Aussie's Connected: $aussie Woah!!!"
                } elseif {[string match -nocase "*.nz" $host]} {
                        set newnumber [expr $kiwis + 1]
                        set kiwis $newnumber
                        putserv "privmsg #sl-oceania :Kiwi's Connected: $kiwis Woah!!!!"
                }
        }
}


Smile

now i want to make it a bit better, and have absolutely no idea if it'll work or how to do it....

i know its possible, at that much Smile

Connect to a MySQL DB
then insert information when it comes in, stored by times
i.e. if its 1:30 and it gets the information, it UPDATES a field, named 1-30, the stuff in it and adds for example, "hello"

an then if its 2:45 it gets the information, it UPDATES the field, 2-30, and yeah.... done in half hour brackets.....

heres like a PHP Version if thats helpful

Code:

$qry = "UPDATE `2-30` SET `kiwis`='$kiwis',`aussies`='$aussies'";
mysql_query($qry);
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Oct 02, 2008 11:31 am    Post subject: Reply with quote

You'll need some myqsl-package such as mysqltcl for this..
Creating the time-stamp would probably be best done something like this:
Code:
set now [clock seconds]
set time "[clock format $now -format "%k"]-[expr [clock format $now -format "%M"]<30?"0":"3"]0"


As for your SQL-query, are you using one table (with one row) for each time-period? If so, wouldn't it be more intuitive to just have one table with several rows (not to mention more efficient)?
Also, if you only wish to store the statistical data in the database, you could simply use SQL's own facilities to increase values, rather than keeping a duplicate in your eggdrop...

A few things tho;
Why use multiple string match's instead of a single switch structure? If you need case-insensitive matching, you could simply replace $host with [string tolower $host] as switch-string...

Why this huge block, instead of the very simple incr command?
Code:
set newnumber [expr $aussie + 1]
set aussie $newnumber
#vs
incr aussie
#or incr aussie 1

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber