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 

Top 10 by country

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


Joined: 30 Dec 2010
Posts: 99

PostPosted: Wed Jul 13, 2011 11:54 am    Post subject: Top 10 by country Reply with quote

Just had an idea for a nice script:

You can add a host by !addhost <hosthere> and the bot will count users who join from that host.

Quote:

User: !addhost *!*@*.fi
Bot: *!*@*.fi Added and will be counted from now on


User: !count *!*@*.fi
Bot: I've counted 20 (15%) users joining from *!*@*.fi Since January 14th, 2010

User: !top10
Bot: Top 10 hosts: *!*@*.fi 20 (15%), *!*@*.de 16 (12%), *!*@*.com 13 (10%)...



please someone?
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Thu Jul 14, 2011 11:28 am    Post subject: Reply with quote

Code:

# domains.tcl

# probably not suitable for multiple fast moving channels because it reads/writes per each join
# automatically scans each join on each bot channel. no need for !addhost command
# ignores the botnick joining a channel
# ignores numeric ips
# so far lacks code to reset ?#channel? to zero

# !domains ?#channel? --- outputs top domains joining command source channel, or ?#channel? if specified

bind JOIN - * pDomainsJoin
bind PUB - !domains pDomainsPub

proc pDomainsPub {nick uhost hand chan text} {
    global vDomainsData
    switch -- [llength [split [string trim $text]]] {
        0 {set channel [string tolower $chan]}
        1 {set channel [string tolower [string trim $text]]}
        default {
            putserv "PRIVMSG $chan :correct syntax is !domains ?#channel?"
            return 0
        }
    }
    if {[regexp -- {^#} $channel]} {
        if {[validchan $channel]} {
            if {[botonchan $channel]} {
                pDomainsRead
                if {[info exists vDomainsData]} {
                    if {[llength $vDomainsData] != 0} {
                        for {set loop 0} {$loop < [llength $vDomainsData]} {incr loop} {
                            set c [lindex [split [lindex $vDomainsData $loop]] 0]
                            set d [lindex [split [lindex $vDomainsData $loop]] 1]
                            set n [lindex [split [lindex $vDomainsData $loop]] 2]
                            if {[string equal $c $channel]} {lappend data [list $d $n]}
                        }
                        if {[info exists data]} {
                            set data [join [lrange [lsort -decreasing -integer -index 1 $data] 0 9] "  "]
                            putserv "PRIVMSG $chan :$data"
                        } else {putserv "PRIVMSG $chan :nothing recorded for $channel"}
                    } else {putserv "PRIVMSG $chan :no data has been recorded"}
                } else {putserv "PRIVMSG $chan :no data has been recorded"}
            } else {putserv "PRIVMSG $chan :bot is not currently monitoring $channel"}
        } else {putserv "PRIVMSG $chan :bot does not have a channel record for $channel"}
    } else {putserv "PRIVMSG $chan :$channel is not a legal channel name"}
    return 0
}

proc pDomainsJoin {nick uhost hand chan} {
    global vDomainsData
    if {![isbotnick $nick]} {
        scan $uhost {%[^@]@%s} user host
        if {![regexp -- {([0-9]{1,3}\.){3}[0-9]{1,3}} $host]} {
            set domain .[string tolower [lindex [split $host .] end]]
            pDomainsRead
            if {[info exists vDomainsData]} {
                if {[llength $vDomainsData] != 0} {
                    set found 0
                    for {set loop 0} {$loop < [llength $vDomainsData]} {incr loop} {
                        set c [lindex [split [lindex $vDomainsData $loop]] 0]
                        set d [lindex [split [lindex $vDomainsData $loop]] 1]
                        set n [lindex [split [lindex $vDomainsData $loop]] 2]
                        if {([string equal $d $domain]) && ([string equal $c [string tolower $chan]])} {
                            set vDomainsData [lreplace $vDomainsData $loop $loop "$c $d [incr n]"]
                            set found 1
                            break
                        }
                    }
                    if {!$found} {lappend vDomainsData "[string tolower $chan] $domain 1"}
                } else {lappend vDomainsData "[string tolower $chan] $domain 1"}
            } else {lappend vDomainsData "[string tolower $chan] $domain 1"}
            pDomainsWrite
        }
    }
    return 0
}

proc pDomainsRead {} {
    global vDomainsData
    if {[file exists domains.txt]} {
        set fp [open domains.txt r]
        set vDomainsData [split [read -nonewline $fp] \n]
        close $fp
    }
    return 0
}

proc pDomainsWrite {} {
    global vDomainsData
    set fp [open domains.txt w]
    if {[info exists vDomainsData]} {
        if {[llength vDomainsData] != 0} {
            puts -nonewline $fp [join $vDomainsData \n]
        }
    }
    close $fp
    return 0
}

putlog "domains.tcl loaded"

# eof

_________________
I must have had nothing to do
Back to top
View user's profile Send private message
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Thu Jul 14, 2011 12:55 pm    Post subject: Reply with quote

Thanks arfer!

Will check it out!
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