Quick Status for Eggdrop

By sk68 on Apr 19, 2010

Adds public, private, and dcc commands to get (what I believe is) relevant information about channels or about the bot.

Information on channels
-Bot's current level
-Number of ops in the channel
-Number of users in the channel
-Current channel modes

Information on bot
-Bot's current address
-Owners (according to eggdrop.conf)
-Number of channels where the bot is OP, HalfOP, Voice, or Regular
-Channels that are set +inactive
-Channels that the bot is not on because of another restriction
-Channels that are below the user minimum (defined in configuration)

Syntax
/msg bot quickstatus [channel]
!status [channel]
In DCC: .quickstatus [channel]

#Configuration

#Flags required to use the status command
set pubstats(flags) "m|-"

#Public Command
set pubstats(pub) "!status"

#Allow DCC Command?
set pubstats(dcc) 1

#Allow Privmsg command?
set pubstats(pm) 1

#Log Commands?
set pubstats(log) 1

#Send method for private command
set pubstats(send) "NOTICE"

#Minimum users that must be in a channel before it is considered "empty"
set pubstats(min) 5

#Script
bind pub $pubstats(flags) $pubstats(pub) pub:status
if {$pubstats(dcc)} { bind dcc $pubstats(flags) quickstatus dcc:status }
if {$pubstats(pm)} { bind msg $pubstats(flags) quickstatus msg:status }

proc pub:status {nick uhost hand chan text} { 
global pubstats botname owner
set arg [string trim $text]
if {$arg == ""} {
putserv "PRIVMSG $chan :Gathering data..."
set chans(noton) ""
set chans(inactive) ""
set chans(lowusers) ""
set chans(op) 0
set chans(hop) 0
set chans(v) 0
set chans(reg) 0
set chans(num) [llength [channels]]
foreach channel [channels] { 
if {[channel get $channel inactive]} { lappend chans(inactive) $channel 
} elseif {![botonchan $channel]} { lappend chans(noton) $channel 
}
if {[botisop $channel]} { incr chans(op)
} elseif {[botishalfop $channel]} { incr chans(hop)
} elseif {[botisvoice $channel]} { incr chans(v) 
} else { incr chans(reg)
}
if {([llength [chanlist $channel]] < 15) && (![channel get $channel inactive] && [botonchan $channel])} { lappend chans(lowusers) $channel }
}
putserv "PRIVMSG $chan :Current Status:"
putserv "PRIVMSG $chan :Online as $botname"
putserv "PRIVMSG $chan :My owner(s) (according to my config file): $owner"
putserv "PRIVMSG $chan :I am op'd on $chans(op) channels, halfop on $chans(hop) channels, voice on $chans(v) channels, and regular on $chans(reg) channels"
if {$chans(noton) == "" && $chans(inactive) == ""} { putserv "PRIVMSG $chan :I am currently on all channels in my database" 
} else { if {$chans(inactive) != ""} { 
putserv "PRIVMSG $chan :The following channels are marked inactive: $chans(inactive)"
} 
if {$chans(noton) != ""} { 
putserv "PRIVMSG $chan :I am not on these channels for some reason: $chans(noton)"
}
}
if {$chans(lowusers) != ""} { putserv "PRIVMSG $chan :These channels are below the user minimum: $chans(lowusers)"
} else { putserv "PRIVMSG $chan :No channels are below user minimum" }
} elseif {[validchan $arg]} {
if {[channel get $arg inactive]} { putserv "PRIVMSG $chan :$arg is marked inactive"
} elseif {![botonchan $arg]} { putserv "PRIVMSG $chan :I am not on $arg"
} else {
putserv "PRIVMSG $chan :Information on $arg:"
putserv "PRIVMSG $chan :My current level: [getbotlevel $arg]"
putserv "PRIVMSG $chan :Number of users: [llength [chanlist $arg]]"
set numops 0
foreach checkop [chanlist $arg] { 
if {[isop $checkop $arg]} {incr numops}
}
putserv "PRIVMSG $chan :Number of OPs: $numops"
putserv "PRIVMSG $chan :Current mode: [getchanmode $arg]"
} 
} elseif {![validchan $arg]} { putserv "PRIVMSG $chan :$arg is an invalid channel" }
if {$pubstats(log)} { return 1 }
}

proc dcc:status {hand idx text} { 
global pubstats botname owner
set arg [string trim $text]
if {$arg == ""} {
putdcc $idx "Gathering data..."
set chans(noton) ""
set chans(inactive) ""
set chans(lowusers) ""
set chans(op) 0
set chans(hop) 0
set chans(v) 0
set chans(reg) 0
set chans(num) [llength [channels]]
foreach channel [channels] { 
if {[channel get $channel inactive]} { lappend chans(inactive) $channel 
} elseif {![botonchan $channel]} { lappend chans(noton) $channel 
}
if {[botisop $channel]} { incr chans(op)
} elseif {[botishalfop $channel]} { incr chans(hop)
} elseif {[botisvoice $channel]} { incr chans(v) 
} else { incr chans(reg)
}
if {([llength [chanlist $channel]] < 15) && (![channel get $channel inactive] && [botonchan $channel])} { lappend chans(lowusers) $channel }
}
putdcc $idx "Current Status:"
putdcc $idx "Online as $botname"
putdcc $idx "My owner(s) (according to my config file): $owner"
putdcc $idx "I am op'd on $chans(op) channels, halfop on $chans(hop) channels, voice on $chans(v) channels, and regular on $chans(reg) channels"
if {$chans(noton) == "" && $chans(inactive) == ""} { putdcc $idx "I am currently on all channels in my database" 
} else { if {$chans(inactive) != ""} { 
putdcc $idx "The following channels are marked inactive: $chans(inactive)"
} 
if {$chans(noton) != ""} { 
putdcc $idx "I am not on these channels for some reason: $chans(noton)"
}
}
if {$chans(lowusers) != ""} { putdcc $idx "These channels are below the user minimum: $chans(lowusers)"
} else { putdcc $idx "No channels are below user minimum" }
} elseif {[validchan $arg]} {
if {[channel get $arg inactive]} { putdcc $idx "$arg is marked inactive"
} elseif {![botonchan $arg]} { putdcc $idx "I am not on $arg"
} else {
putdcc $idx "Information on $arg:"
putdcc $idx "My current level: [getbotlevel $arg]"
putdcc $idx "Number of users: [llength [chanlist $arg]]"
set numops 0
foreach checkop [chanlist $arg] { 
if {[isop $checkop $arg]} {incr numops}
}
putdcc $idx "Number of OPs: $numops"
putdcc $idx "Current mode: [getchanmode $arg]"
} 
} elseif {![validchan $arg]} { putdcc $idx "$arg is an invalid channel" }
if {$pubstats(log)} { return 1 }
}

proc msg:status {nick uhost hand text} { 
global pubstats botname owner
set arg [string trim $text]
if {$arg == ""} {
putserv "$pubstats(send) $nick :Gathering data..."
set chans(noton) ""
set chans(inactive) ""
set chans(lowusers) ""
set chans(op) 0
set chans(hop) 0
set chans(v) 0
set chans(reg) 0
set chans(num) [llength [channels]]
foreach channel [channels] { 
if {[channel get $channel inactive]} { lappend chans(inactive) $channel 
} elseif {![botonchan $channel]} { lappend chans(noton) $channel 
}
if {[botisop $channel]} { incr chans(op)
} elseif {[botishalfop $channel]} { incr chans(hop)
} elseif {[botisvoice $channel]} { incr chans(v) 
} else { incr chans(reg)
}
if {([llength [chanlist $channel]] < 15) && (![channel get $channel inactive] && [botonchan $channel])} { lappend chans(lowusers) $channel }
}
putserv "$pubstats(send) $nick :Current Status:"
putserv "$pubstats(send) $nick :Online as $botname"
putserv "$pubstats(send) $nick :My owner(s) (according to my config file): $owner"
putserv "$pubstats(send) $nick :I am op'd on $chans(op) channels, halfop on $chans(hop) channels, voice on $chans(v) channels, and regular on $chans(reg) channels"
if {$chans(noton) == "" && $chans(inactive) == ""} { putserv "PRIVMSG $chan :I am currently on all channels in my database" 
} else { if {$chans(inactive) != ""} { 
putserv "$pubstats(send) $nick :The following channels are marked inactive: $chans(inactive)"
} 
if {$chans(noton) != ""} { 
putserv "$pubstats(send) $nick :I am not on these channels for some reason: $chans(noton)"
}
}
if {$chans(lowusers) != ""} { putserv "$pubstats(send) $nick :These channels are below the user minimum: $chans(lowusers)"
} else { putserv "$pubstats(send) $nick :No channels are below user minimum" }
} elseif {[validchan $arg]} {
if {[channel get $arg inactive]} { putserv "$pubstats(send) $nick :$arg is marked inactive"
} elseif {![botonchan $arg]} { putserv "$pubstats(send) $nick :I am not on $arg"
} else {
putserv "$pubstats(send) $nick :Information on $arg:"
putserv "$pubstats(send) $nick :My current level: [getbotlevel $arg]"
putserv "$pubstats(send) $nick :Number of users: [llength [chanlist $arg]]"
set numops 0
foreach checkop [chanlist $arg] { 
if {[isop $checkop $arg]} {incr numops}
}
putserv "$pubstats(send) $nick :Number of OPs: $numops"
putserv "$pubstats(send) $nick :Current mode: [getchanmode $arg]"
} 
} elseif {![validchan $arg]} { putserv "$pubstats(send) $nick :$arg is an invalid channel" }
if {$pubstats(log)} { return 1 }
}

#Note: This proc can be used in other scripts
proc getbotlevel {chan} {
if {[botisop $chan]} { return op 
} elseif {[botishalfop $chan]} { return "halfop" 
} elseif {[botisvoice $chan]} { return "voice"
} else { return "regular" }
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.