########################################################################
# BlackStats TcL 1.1
#
#This TCL shows the information about channels
#-number of users
#-number of ops
#-number of voices
#-the topic
#-the modes
#-number the bans from the channel`s banlist
#-number of bans from the bots banlist (for that chan)
#
#Version 1.1
#- added stats for the creation date of the channel
#
#To activate just use : .chanset #channel +blackstats (on DCC)
#                                     
#                                 BLaCkShaDoW ProductionS
#                               -= The Next Generation TCL =-
#######################################################################
#You have two commands , one is for those who have local access on the #chan the command is .stat
#The other one is for those who have global access, the command is #.stats <channel>
# .stats <canal> (for those who have global)
# .stat (for those who have local)
#Of course the bot has to be on the channels

#Here you can set the character of the commands
set stat(char) "."

#Here you can set the local flags needed to run commands

set stat(localflags) "olnMN"

#Here you can set the global flags needed to run commands

set stat(globalflags) "nmo"


#######################################################################
#
#                           Smile Mothafucka
#
#######################################################################
set Author "BLaCkShaDoW"
set sversion "1.1"
setudef flag blackstats

bind pub $stat(globalflags)|- $stat(char)stats statistics
bind pub $stat(globalflags)|$stat(localflags) $stat(char)stat statsu


proc creat { from keyword arguments } {
set chan $::chan
set date [lindex [split $arguments] 2]
set dates [ctime $date]
puthelp "PRIVMSG $chan :Date of creation of this channel :$dates"
unbind RAW - 329 creat
}

proc statistics {nick host hand chan arg} {
global stat botnick
set channel [lindex [split $arg 0]]
set ::chan $chan
if {[channel get $chan blackstats]} {
if {$arg == ""} { putquick "NOTICE $nick :Use $stat(char)stats <canal>"
return 0
}

if {![regexp {^[\\+!#&]} $channel]} {
puthelp "NOTICE $nick :$channel is not a valid channel"
return 0
 }
set listauseri [llength [chanlist $channel]]
set chanbans [llength [chanbans $channel]]
set botbans [llength [banlist $channel]]
set top [topic $channel]
set ops 0
set voices 0
set modes [getchanmode $channel]
foreach user [chanlist $channel] {
if {[isop $user $channel]} {
set ops [expr $ops +1]
}
if {[isvoice $user $channel]} {
set voices [expr $voices +1]
} 
}
if {$top == ""} { set top "There is no TOPIC" }
puthelp "PRIVMSG $chan :Information for $channel"
puthelp "PRIVMSG $chan :Number of users : $listauseri"
puthelp "PRIVMSG $chan :Users with op :$ops | Users with voice : $voices"
puthelp "PRIVMSG $chan :Total channel bans : $chanbans | Total BOT bans: $botbans"
puthelp "PRIVMSG $chan :The TOPIC is :$top"
puthelp "PRIVMSG $chan :The Mods of the channel are :$modes"
utimer 3 [list puthelp "PRIVMSG $chan :End of informations.."]
putquick "MODE $channel"
bind RAW - 329 creat
}
}

proc statsu {nick host hand chan arg} {
global stat
set ::chan $chan
set listauseri [llength [chanlist $chan]]
set chanbans [llength [chanbans $chan]]
set botbans [llength [banlist $chan]]
set top [topic $chan]
set modes [getchanmode $chan]
set ops 0
set voices 0
if {[channel get $chan blackstats]} {
foreach user [chanlist $chan] {
if {[isop $user $chan]} {
set ops [expr $ops +1]
}
if {[isvoice $user $chan]} {
set voices [expr $voices +1]
}
}
if {$top == ""} { set top "There is no TOPIC" }

puthelp "PRIVMSG $chan :Information for $chan"
puthelp "PRIVMSG $chan :Number of users : $listauseri"
puthelp "PRIVMSG $chan :Users with op :$ops | Users with voice : $voices"
puthelp "PRIVMSG $chan :Total channel bans : $chanbans | Total BOT bans: $botbans"
puthelp "PRIVMSG $chan :The TOPIC is :$top"
puthelp "PRIVMSG $chan :The Mods of the channel are :$modes"
utimer 3 [list puthelp "PRIVMSG $chan :End of informations.."]
putquick "MODE $chan"
bind RAW - 329 creat
}
}


putlog "BlackStats TcL $sversion by $Author Loaded"


