- Home»
- Cod sursa: storm.bot.tcl
storm.bot.tcl
storm.bot.tcl
StormBot 3.1 - a TCL for Eggdrop 1.3.*, 1.4.*, 1.5.* and 1.6.*. Version 1.7 [which is currently in CVS only] requires the TCL module to run this script.
| Postat de | Copyright | Categorie | Review user | Vizualizari | Data |
|---|---|---|---|---|---|
| btc | Xone | protections | Cod netestat | 450 | 2023-12-25 12:09:17 |
#############################################################################
# StormBot 3.1 - a TCL for Eggdrop 1.3.*, 1.4.*, 1.5.* and 1.6.*.
# Version 1.7 [which is currently in CVS only] requires the TCL module to run
# this script.
#
# Copyright (C) 1998-2002 Xone / BService, #Bothouse @ ChatNet
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Or, you can read it at http://www.gnu.org/
#
# ********************************
#
# You can get the newest version at:
# http://get.stormbot.org/
#
# /Xone <xone@bothouse.org>
# - Admin for BService / #Bothouse @ ChatNet
#
# ~ Domino Rose-Mystagic <domino@bothouse.org>
# Admin for BService / #Bothouse @ ChatNet
#
# Online support and bug fix/information is available in #BotHouse on
# IRC.ChatNet.Org or on our StormBot list. For mailing list information, see
# http://www.bothouse.org/mailman/listinfo/stormbot/
#
# Note: due to changes in EGGDROP1.3.29 and TCL8.2, the [time] command
# no longer works universally. I've already compensated for this. If you
# use [currtime] instead of [time] and [currdate] instead of [date],
# STORMBOT.TCL will use whichever is appropriate for proper output.
#
#####
# Shortcut - If you leave this blank (default) it will create a shortcut for
# you, made by the first and last letter in the bot's nick.
# The other binds will be 'nick' and 'altnick'... think that should do it :>
if {![info exists shortcut]} {set shortcut "sdfgsfh"}
#####
# Home - The Home channel, where your bot will report things and stuff.
set thome #Team.eQ"
#####
# Group and User Status
set groupname "Stormbot"
set ownername "owner"
set mastername "master"
set techname "botnet technician"
set opname "op"
set halfopname "halfop"
set voicename "voice"
set homechanopname "home channel op"
set levels "chanfriend chanvoice chanop chanmaster chanowner friend voice op tech master owner full global"
#####
#Default Channel Options - when you use the join command!
set defchanoptions {
chanmode "+nt"
idle-kick 0
need-op { }
need-invite { }
need-key { }
need-unban { }
need-limit { }
flood-chan 0:0
flood-deop 0:0
flood-kick 0:0
flood-join 0:0
flood-ctcp 0:0
}
#####
#Default Channel Modes - when you use the join command!
set defchanmodes {
-clearbans
+enforcebans
+dynamicbans
+userbans
+autoop
-bitch
+greet
-protectops
-statuslog
-stopnethack
+revenge
+autovoice
-secret
-shared
+cycle
}
#####
# cycletime - The number of seconds given to a user who parts the channel to
# rejoin before they are automatically logged out
# NOTE **** Some Windows eggdrops do not run timers correctly, and you will
# be logged off as soon as you part the channel. The fix? Get a unix shell.
set cycletime 0
#####
#Just a bind for the global callcommand :P
#Don't mess with this one, unless you really really know what you are doing!
set globalcallcommand "***"
#####
#Set this to the nick of your network's channel services bot
set cserv ""
#####
#Set this to your server's "channel wallops" command. If the server doesn't
#have this (it's usually "wallchops"), then leave it blank; the script will
#work around it.
set chanwall ""
#############################################################################
#############################################################################
############################### STOP EDITING ################################
#############################################################################
#############################################################################
# Version number - DON'T TOUCH!
set stormver "3.1.beta.2.10"
# This trinket will make the bot update its home channel properly. this allows
# the $HOME channel to be defined in the CONFIG file [or elsewhere before this
# script is called], instead of EXPLICITLY by StormBot.TCL.
set h 0
if {![info exists home]} {set h 1} else {if {[string tolower $thome] != [string tolower $home]} {set h 1} }
if {($h)} {set home $thome}
set exempt "$home"
# Allows bot's true nick to be known even if the bot IRC's on the alt nick.
if {![info exists bnick]} {set bnick "StormBot"}
if {[validuser $nick]} {chnick $nick $bnick}
# Moves the internal bot information if this is an newer verison of the data
# capturing/storage system.
if {$shortcut == ""} {
if {[string length $nick] > 2} {set shortcut "[string index $nick 0][string index $nick [expr [string length $nick] - 1]]"
} else {set shortcut $nick}
}
if ![info exists timezone] {set timezone [clock format [clock seconds] -format "%Z"]}
if ![info exists bottimezone] {
if [string match -nocase windows* $tcl_platform(os)] {
set bottimezone "+0"; # Unable to calculate GMT offset.
} else {
set z [clock format [clock seconds] -format "%z"]
set bottimezone "[string index $z 0][string trim [string range $z 1 2] 0].[expr int([string range $z end-1 end] * ( 10 / 6. ))]"
}
}
if {![info exists cserv]} {set cserv ""}
proc checkseen { } {
foreach i [modules] { if {[lindex $i 0] == "seen"} {return 0} }
loadmodule seen; return 0
}
checkseen
if {[expr [clock seconds] - $uptime] < 5} { foreach a [userlist L] {chattr $a -L} }
# Make sure no users are logged-in by default because the bot died.
# This =WILL= clears-out all auths when REHASHing or RESTARTing. :(
# No way around that. :(
bind chon Z * dcc_suspend
proc dcc_suspend {handle idx} {
global home
putidx $idx "You're not allowed on the party line until you get unsuspended. See $home for help."
killdcc $idx
}
bind chon X * dcc_suspend
proc dcc_suspend {handle idx} {
global home
putidx $idx "You're not allowed on the party line. See $home for assistance."
killdcc $idx
}
# Timered save [since logins/logouts no longer trigger saves]
set saveall_timer 10; # will be every 10 minutes
timer $saveall_timer saveall
proc saveall { } {global saveall_timer; ktm "saveall"; timer $saveall_timer saveall; save; savechannels; writedata}
###
if {[lindex $version 1] < 1061300} {
# If this is before EGGDROP1.6.13, then activate MY custom HALFOP support!
# (See "political" statement in the README and NEWTO files.)
# Note: UnRealIRCd 3.1.2+Darshades has a known bug: the WHO reply will NOT
# show the "%" needed to calculate HALFOP status. Sorry; I can't correct
# for that.
#####
# Check for HALFOP/INVITE/EXEMPT server support.
proc modecheck_init { } {killbind raw 004 modecheck; bind raw - 004 modecheck}
proc modecheck {a b crap} {
global modeenable; set b "abcdefghijklmnopqrstuvwxyz"
foreach a "0 1" { foreach c [split [lindex "[stl $b] [stu $b]" $a] ""] {set modeenable($c) 0} }
set flags [lindex $crap end]; foreach a [split $flags ""] {set modeenable($a) 1}
return 0
}
#####
# General HALFOP support PROCs.
array set halfop ""
proc halfop_init { } {
global halfop
foreach a [stl [channels]] {set halfop($a) ""}
# Remove multiple BINDings.
killbind RAW 353 halfop_update
bind RAW - 353 halfop_update
}
proc halfop_update {junk command data} {
global halfop
set chan [sl2 $data]
set names [string range [l3e $data] 1 end]
foreach a $names {
if {[string first "%" $a] > -1} {
if {[lsearch -glob $halfop([stl $chan]) $a] < 0} {lappend halfop([stl $chan]) $a}
}
}
}
bind mode - "* +h" update_halfop
bind mode - "* -h" update_halfop
bind part - * part_halfop
bind sign - * quit_halfop
bind kick - * kick_halfop
bind nick - * nick_halfop
proc update_halfop {nick host handle chan mode victim} {
global halfop
set chan [stl $chan]
if {![info exists halfop($chan)]} {set halfop($chan) ""}
switch -exact -- $mode {
+h { if {![halfop $victim $chan]} {lappend halfop($chan) $nick} }
-h { set a [lsearch -glob $halfop($chan) $victim]; if {$a > -1} {set halfop($chan) [lreplace $halfop($chan) $a $a]} }
}
}
proc part_halfop {a b c d {e ""}} {update_halfop $a $b $c $d "-h" $a}
proc quit_halfop {a b c d e} {update_halfop $a $b $c $d "-h" $a}
proc kick_halfop {a b c d e f} {update_halfop $a $b $c $d "-h" $a}
proc nick_halfop {a b c d e} {update_halfop $a $b $c $d "-h" $a; update_halfop $a $b $c $d "-h" $e}
proc ishalfop {nick chan} {
global halfop
set a [lsearch -glob [stl $halfop([stl $chan])] [stl $nick]]
if {$a < 0} {return 0}
return 1
}
proc ishop {a b} {return "[ishalfop $a $b]"}
# Just makes ISHOP as a shortcut to ISHALFOP, since I typo ISHALFOP so often.
} else {
array set modeenable ""
set modeenable(h) 1
}
###
#Just the binds
bind pub - !version do_version
bind pub - $nick do_callcommand
bind pub - $altnick do_callcommand
bind pub - $shortcut do_callcommand
bind pub m $globalcallcommand do_callcommand
bind pub o !version pub_version
unbind dcc o|o say *dcc:say
bind dcc m|m say *dcc:say
unbind dcc o|- msg *dcc:msg
bind dcc m|- msg *dcc:msg
proc do_version {a b c d e} {call_version $a}
#LOGIN/LOGOUT
bind msg olHvf|olHvf xpass xpass
bind msg - login do_login
bind msg o xlogin do_xlogin
bind msg - auth do_login
bind msg o xauth do_xlogin
bind msg - logout do_logout
bind msg o xlogout do_xlogout
bind sign L * do_quit_logout
bind part L * do_part_timer_logout
bind kick L * do_kick_timer_logout
bind join P * do_join_cancel_logout
bind msg - authop do_authop
bind msg - xauthop do_xauthop
bind nick L * authnickchange
bind splt L * splitdeauth
proc authnickchange {nick host handle chan new} {
if {$nick != [getuser $handle XTRA "AUTH"]} {return 0}
setuser $handle XTRA "AUTH" "$new"
}
proc splitdeauth {nick host handle chan} {
setuser $handle XTRA "AUTH" ""
chattr $handle -L
putlog "$nick was logged-out due to a netsplit."
# DO =NOT= PUT A "SAVE" HERE ~ WILL CAUSE A HUNDRED SAVES PER NETSPLIT!!!!!
}
proc do_join_cancel_logout {nick host handle chan} {
global rehashlag
chattr $handle -P
# save
putlog "\002LOGIN\002 $nick ($handle) rejoined $chan, auto-logout aborted"
}
proc do_part_timer_logout {nick host handle chan {msg ""}} {
global cycletime
chattr $handle +P
putlog "\002LOGOUT\002 $nick ($handle) parted $chan, auto-logout initiated ($cycletime seconds)"
utimer $cycletime "do_part_logout [encrypt split $nick] $host [encrypt split $handle] [encrypt split $chan]"
}
proc do_kick_timer_logout {nick host handle chan victim reason} {
global cycletime
chattr $handle +P
set khandle [nick2hand $victim $chan]
putlog "\002LOGOUT\002 $victim ($khandle) got kicked $chan, auto-logout initiated ($cycletime seconds)"
utimer $cycletime "do_part_logout [encrypt split $victim] [encrypt split $host] [encrypt split $khandle] [encrypt split $chan]"
}
proc do_quit_logout {nick host handle chan arg} {
chattr $handle -LP
setuser $handle XTRA "AUTH" ""
# save
putlog "\002LOGOUT\002 $nick ($handle) automatically logged out (Quit IRC)"
}
proc do_part_logout {nick host handle chan} {
set nick [decrypt split $nick]
set host [decrypt split $host]
set handle [decrypt split $handle]
set chan [decrypt split $chan]
# To defer [NICK] issues; using [SPLIT $NICK] does =not= work in all cases.
if {![matchattr $handle P]} {return 0}
set onachan 0
foreach checkchan [channels] {
if {[onchan $nick $checkchan] && ($chan != $checkchan)} {
set onachan 1
}
}
# Adjusted to chattr -P if user is still on a bot-controlled channel.
chattr $handle -P
# Do NOT combine with -L below.
if {$onachan != 1} {
chattr $handle -L
# save
setuser $handle XTRA "AUTH" ""
putlog "\002LOGOUT\002 $nick ($handle) automatically logged out. Left last bot controlled channel ($chan)"
}
}
proc do_logout {nick host handle arg} {
notice $nick "\002LOGOUT\002 $nick was successfully logged out"
if {$handle != "" } {
chattr $handle -L
setuser $handle XTRA "AUTH" ""
# save
putlog "\002LOGOUT\002 $nick ($handle) logged out"
}
}
proc do_login {nick host handle arg} {
global botnick authop
if {[passwdok $handle [lindex $arg 0]]} {
notice $nick "\002LOGIN\002 Authentication successful..."
putlog "\002LOGIN\002 $nick logged in as $handle."
chattr $handle +L
setuser $handle XTRA "AUTH" "$nick"
# save
set authop 1
return 0
}
notice $nick "\002LOGIN\002\ Authentication failed..."
notice $nick "Usage: /msg $botnick login <yourpass>"
notice $nick "Or try ident yourself: /msg $botnick ident <yourpass>"
putlog "\002LOGIN ERROR\002 $nick failed logged in."
chattr $handle -L
setuser $handle XTRA "AUTH" ""
# save
set authop 0
}
set authop 0
proc do_authop {nick host handle arg} {
global botnick authop
set chan [lindex $arg 0]
set arg [lrange $arg 1 end]
if {($chan == "") || ![validchan $chan]} {notice $nick "Invalid channel specification. /msg $botnick authop <#channel> <PASSWORD>"; return 0}
set authop 0
do_login $nick $host $handle $arg
if {$authop == 1} {do_callcommand $nick $host $handle $chan "op"}
set authop 0
}
proc do_xlogin {nick host handle arg} {
global botnick authop home
if {![onchan $nick $home]} {
notice $nick "Get in the \"home\" channel before you do that!"
return 0
putlog "$nick ($handle) tried to XLOGIN, but wasn't in $home."
}
if {[passwdok $handle [lindex $arg 0]]} {
notice $nick "\002XLOGIN\002 Authentication successful..."
notice $nick "Please allow the other bots a few seconds to register the XLogin."
putlog "\002LOGIN\002 $nick xlogged in as $handle."
chattr $handle +L
setuser $handle XTRA "AUTH" "$nick"
msg $home "$nick XLOGGED-in as $handle."
# save
putallbots "xlogin $nick $handle [encrypt stormbot $arg]"
set authop 1
return 0
}
notice $nick "\002LOGIN\002\ Authentication failed..."
notice $nick "Usage: /msg $botnick login <yourpass>"
notice $nick "Or try ident yourself: /msg $botnick ident <yourpass>"
putlog "\002LOGIN ERROR\002 $nick failed logged in."
chattr $handle -L
setuser $handle XTRA "AUTH" ""
# save
}
proc do_xauthop {nick host handle arg} {
global botnick authop
set chan [lindex $arg 0]
set arg [lrange $arg 1 end]
if {($chan == "") || ![validchan $chan]} {notice $nick "Invalid channel specification. /msg $botnick authop #channel PASSWORD"; return 0}
set authop 0
do_xlogin $nick $host $handle $arg
if {$authop == 1} {do_callcommand $nick $host $handle $chan "op"}
set authop 0
}
bind bot - xlogin call_xlogin
proc call_xlogin {bot command arg} {
global botnick home
set nick [lindex $arg 0]
set handle [lindex $arg 1]
if {![onchan $nick $home]} {
# notice $nick "Get in the \"home\" channel before you do that!"
return 0
# putlog "$nick ($handle) tried to XLOGIN, but wasn't in $home."
}
if {[passwdok $handle [decrypt stormbot [lindex $arg 2]]]} {
putlog "\002LOGIN\002 $nick ($handle) XLOGGED-in."
chattr $handle +L
setuser $handle XTRA "AUTH" "$nick"
# save
return 0
}
}
proc do_xlogout {nick host handle arg} {
global botnick
notice $nick "\002XLOGOUT\002 Authentication successful..."
notice $nick "Please allow the other bots a few seconds to register the XLogout."
putlog "\002LOGIN\002 $nick ($handle) xlogged-out."
chattr $handle -L
setuser $handle XTRA "AUTH" ""
# save
putallbots "xlogout $handle"
}
bind bot - xlogout call_xlogout
proc call_xlogout {bot command arg} {
global botnick
putlog "\002LOGOUT\002 [lindex $arg 0] xlogged out."
set handle [lindex $arg 0]
chattr $handle -L
setuser $handle XTRA "AUTH" ""
# save
return 0
}
proc xpass {nick host handle arg} {
global botnick
notice $nick "Please allow the other bots a few seconds to register the XPASS."
putlog "\002XPASS\002 $nick set xpass as $handle."
if {[lindex $arg 1] != ""} {
set go "[encrypt stormbot [lindex $arg 0]] [encrypt stormbot [lindex $arg 1]]"
} else {
set go [encrypt stormbot [lindex $arg 0]]
}
putallbots "xpass $nick $host $handle $go"
*msg:pass $nick $host $handle $arg
save
return 1
}
bind bot - xpass bxpass
proc bxpass {bot command arg} {
if {[lindex $arg 4] != ""} {
set go "[decrypt stormbot [lindex $arg 3]] [decrypt stormbot [lindex $arg 4]]"
} else {
set go [decrypt stormbot [lindex $arg 3]]
}
putlog "\002XPASS\002: [lindex $arg 0] xpassed as [lindex $arg 2]."
set arg [decrypt stormbot $arg]
*msg:pass [lindex $arg 0] [lindex $arg 1] [lindex $arg 2] $go
set arg ""
save
return 1
}
bind bot - send bsend
proc bsend {bot command arg} {
global hold
set hold $arg
set arg [join $arg]
set nick "[lindex $arg 0]"
set host "[lindex $arg 1]"
set handle "[lindex $arg 2]"
set chan "[lindex $arg 3]"
set args "[lrange $hold 4 end]"
do_callcommand $nick $host $handle $chan $args
return 0
}
proc pub_version {nick host handle channel arg} {call_version $nick}
### Start Call Command
set invalidok {
join
unsuspendchan
uschan
}
set hold ""
proc do_callcommand {nick host handle channel arg} {
global stormver callcommand home botnick groupname ownername mastername techname opname halfopname voicename homechanopname defchanoptions defchanmodes invalidok special hold
set hold $arg
set command [string tolower [lindex $arg 0]]
if {$command == ""} {return 0}
set arg1 [lindex $arg 1]
if {[string match "#*" $arg1]} {
set chan $arg1
set misc1 [lindex $arg 2]
set misc2 [lindex $arg 3]
set misc3 [lindex $arg 4]
set misc4 [lindex $arg 5]
set misc1end [lrange $arg 2 end]
set misc2end [lrange $arg 3 end]
set misc3end [lrange $arg 4 end]
set misc4end [lrange $arg 5 end]
if {![validchan $arg1] && ([lsearch -glob $invalidok $command] < 0)} {notice $nick "$arg1 is not a registered channel."; return 0}
} else {
set chan $channel
set misc1 [lindex $arg 1]
set misc2 [lindex $arg 2]
set misc3 [lindex $arg 3]
set misc4 [lindex $arg 4]
set misc1end [lrange $arg 1 end]
set misc2end [lrange $arg 2 end]
set misc3end [lrange $arg 3 end]
set misc4end [lrange $arg 4 end]
}
switch -exact -- $command {
uptime {call_uptime $nick; return 1}
nick {call_nick $nick $handle $misc1; return 1}
help {call_help $nick $handle $chan $misc1; return 1}
time {call_time $nick; return 1}
date {call_date $nick; return 1}
ping {call_ping $nick $chan $misc1; return 1}
top {call_top $nick $chan $misc1 $misc2; return 1}
seen {call_seen $nick $host $handle $misc1end; return 1}
whois {call_whois $nick $chan $misc1; return 1}
stats {call_stats $nick $chan $misc1; return 1}
access {call_access $nick $chan $misc1; return 1}
info {call_info $nick $chan $misc1 $misc2; return 1}
levels {call_levels $nick $handle; return 1}
flags {call_flags $nick $misc1; return 1}
bantype {call_bantype $nick; return 1}
banlist {call_banlist $nick $chan $misc1 $misc2; return 1}
ignorelist {call_ignorelist $nick; return 1}
userlist {call_userlist $nick $chan; return 1}
}
# Command switches were changed from o|o to [o] || [&o] to faciliate the use
# of commands via SEND. If an "illegal channel" error were set-up via SEND,
# MATCHATTR will always return "0." The splitting of the global and channel
# flags will allow the script to continue to work without the error affecting
# processing.
if {[chkaccess $nick $handle fvHlomn|fvHlomn $chan]} {return 0}
# CHKACCESS will return non-zero codes for ERRORS, and "0" for OK!!
# Do =NOT= do -two- checks [one with global and one with |local]; the
# local version will FAIL [return code 3] with |local flags on unknown
# channels [$INVALIDOK] due to MATCHATTR's auto-0 for unknown channels.
switch -exact -- $command {
note {call_note $nick $host $handle $chan $misc1 $misc2end; return 1}
greet {call_greet $nick $handle $chan $misc1 $misc1end; return 1}
set {call_set $nick $handle $misc1 $misc2 $misc2end; return 1}
who {call_who $nick $handle $chan; return 1}
}
if {[matchattr $handle vo] || [matchattr $handle |vo $chan]} {
switch -exact -- $command {
voice {call_voice $nick $handle $chan $misc1 $misc1end; return 1}
devoice {call_devoice $nick $handle $chan $misc1 $misc1end; return 1}
}
}
if {[matchattr $handle o] || [matchattr $handle |o $chan]} {
switch -exact -- $command {
version {call_version $nick; return 1}
topic {call_topic $nick $chan $misc1end; return 1}
mode {call_mode $nick $chan $misc1end; return 1}
op {call_op $nick $chan $misc1 $misc1end; return 1}
deop {call_deop $nick $handle $chan $misc1 $misc1end; return 1}
kick {call_kick $nick $handle $chan $misc1 $misc2end; return 1}
ban {call_ban $nick $handle $chan $misc1 $misc2 $misc2end $misc3end; return 1}
unban {call_unban $nick $handle $chan $misc1; return 1}
wallops {call_wallops $nick $chan $misc1end; return 1}
wall {call_wallops $nick $chan $misc1end; return 1}
}
}
if {[matchattr $handle o] || [matchattr $handle |m $chan]} {
switch -exact -- $command {
invite {call_invite $nick $handle $chan $misc1; return 1}
}
}
if {[matchattr $handle t] || [matchattr $handle |m $chan]} {
switch -exact -- $command {
say {call_say $nick $chan $misc1end; return 1}
act {call_act $nick $chan $misc1end; return 1}
}
}
if {[matchattr $handle m] || [matchattr $handle |m $chan]} {
switch -exact -- $command {
adduser {call_adduser $nick $handle $chan $misc1 $misc2 $misc3; return 1}
remuser {call_remuser $nick $handle $chan $misc1 $misc2; return 1}
moduser {call_moduser $nick $handle $chan $misc1 $misc2 $misc3; return 1}
cycle {call_cycle $nick $handle $chan; return 1}
chaninfo {call_chaninfo $nick $handle $chan; return 1}
onjoin {call_onjoin $nick $chan $misc1 $misc2 $misc2end $misc3end; return 1}
}
}
if {[matchattr $handle m] || [matchattr $handle |n $chan]} {
switch -exact -- $command {
chanset {call_chanset $nick $handle $chan $misc1 $misc2 $misc1end $misc2end; return 1}
}
}
if {[matchattr $handle n] || [matchattr $handle |n $chan]} {
switch -exact -- $command {
addhost {call_addmask $nick $handle $chan $misc1 $misc2; return 1}
addmask {call_addmask $nick $handle $chan $misc1 $misc2; return 1}
delmask {call_remmask $nick $handle $chan $misc1 $misc2; return 1}
delhost {call_remmask $nick $handle $chan $misc1 $misc2; return 1}
remmask {call_remmask $nick $handle $chan $misc1 $misc2; return 1}
}
}
if {[matchattr $handle o]} {
switch -exact -- $command {
ignore {call_ignore $nick $chan $handle $misc1 $misc2end; return 1}
unignore {call_unignore $nick $misc1; return 1}
clear {call_clear $nick $chan; return 1}
opstat {call_opstat $nick $misc1; return 1}
lock {call_lock $nick $chan; return 1}
unlock {call_unlock $nick $chan; return 1}
dccme {call_dccme $nick $host $handle; return 1}
channels {call_channels $nick; return 1}
global {call_global $nick $handle $misc1 $misc2 $misc3 $misc4 $misc2end $misc3end $misc4end; return 1}
}
}
if {[matchattr $handle t]} {
switch -exact -- $command {
send {call_send $nick $host $handle $chan $misc1end; return 1}
save {call_save $nick; return 1}
banner {call_banner $nick $misc1end; return 1}
broadcast {call_banner $nick $misc1end; return 1}
msg {call_msg $nick $misc1 $misc2end; return 1}
notice {call_notice $nick $misc1 $misc2end; return 1}
log {call_log $nick $misc1end; return 1}
jump {call_jump $nick $misc1 $misc2 $misc3; return 1}
}
}
if {[matchattr $handle m]} {
switch -exact -- $command {
chhandle - chnick {call_chnick $nick $handle $misc1 $misc2; return 1}
xsend {call_xsend $nick $host $handle $chan $misc1end; return 1}
rehash {call_rehash $nick; return 1}
restart {call_restart $nick; return 1}
join {call_join $nick $chan; return 1}
part {call_part $nick $chan $misc1end; return 1}
remchan {call_part $nick $chan $misc1end; return 1}
suspend {call_suspend $nick $handle $chan $misc1 $misc2end; return 1}
unsuspend {call_unsuspend $nick $handle $chan $misc1; return 1}
}
}
if {[matchattr $handle n]} {
switch -exact -- $command {
die {call_die $nick $misc1end; return 1}
}
}
notice $nick "Unknown command or insufficient access for \"$command.\" For help: (/msg) $botnick (#channel) help"
return 0
}
#############################################################################
####################
### MSG Commands ###
####################
proc do_msgchancommand {nick uhost handle arg} {
global lastbind home ownername mastername techname opname halfopname voicename homechanopname groupname botnick bnick invalidok
set arg1 [lindex $arg 0]
if {![string match "#*" $arg1]} {notice $nick "You need to specify a channel name when you use a /msg $lastbind."; return 1}
if {[lsearch -glob $invalidok $lastbind] < 0} { if {![validchan $arg1]} {notice $nick "$arg1 is not a valid channel."; return 1} }
set chan [findchan $nick]
if {$chan == ""} {set chan $home} else {set chan [lindex $chan 2]}
do_callcommand $nick $uhost $handle $chan "$lastbind $arg"
return 1
}
proc do_msgnochancommand {nick uhost handle arg} {
global lastbind home ownername mastername techname opname halfopname voicename homechanopname groupname botnick bnick
do_callcommand $nick $uhost $handle $home "$lastbind $arg"
return 1
}
##########
# Channel-specific commands
set list ""
set list "$list access act adduser ban banlist banner broadcast chaninfo"
set list "$list chanset clear commands comment cycle deop devoice greet help"
set list "$list info invite join kick lock mass mode moduser onjoin op part"
set list "$list remchan remuser say seen stats top topic unban unlock"
set list "$list userlist voice wall wallops who whois"
foreach junk $list {bind msg - $junk do_msgchancommand}
#############################################################################
# Non channel-specific commands
set list ""
set list "$list addhost addmask bantype channels chans chhandle chnick date"
set list "$list dccme delhost delmask die flags global ignore ignorelist jump"
set list "$list levels log msg nick note notice opstat ping rehash remmask"
set list "$list restart save send set suspend time unignore unsuspend"
set list "$list uptime version"
foreach junk $list {bind msg - $junk do_msgnochancommand}
unset junk
unset list
#########################################
### All the procs for the callcommand ###
#########################################
### Help proc
proc call_help {nick handle chan misc1} {
global botnick stormver globalcallcommand groupname
set misc1 [string tolower $misc1]
### Global ###
if {$misc1 == "help"} {
notice $nick "Aw, c'mon, $nick! Don't be so silly."
return 0
}
if {$misc1 == ""} {
notice $nick "\006StormBot Help\006"
notice $nick "\002Global Command Access: Anyone\002"
notice $nick "time date ping version top seen stats whois userlist"
notice $nick "access info levels flags bantype banlist ignorelist"
notice $nick "nick uptime"
### ChanV ###
if {[matchattr $handle vo|vo $chan]} {
notice $nick ""
notice $nick "\002Channel Voice Access: ChanVoice\002"
notice $nick "voice devoice greet who set note"
}
### ChanO ###
if {[matchattr $handle o|o $chan]} {
notice $nick ""
notice $nick "\002Channel Op Access: ChanVoice/ChanOp\002"
notice $nick "topic mode op deop kick ban unban"
notice $nick "wallops (wall)"
}
### ChanM ###
if {[matchattr $handle m|m $chan]} {
notice $nick ""
notice $nick "\002Channel Master Access: ChanVoice/ChanOp/ChanMaster\002"
notice $nick "cycle invite chaninfo adduser remuser moduser say act onjoin"
}
### ChanN ###
if {[matchattr $handle n|n $chan]} {
notice $nick ""
notice $nick "\002Channel Owner Access: All Channel Levels\002"
notice $nick "chanset addmask remmask"
}
### O ###
if {[matchattr $handle o]} {
notice $nick ""
notice $nick "\002Global Op Access: ChanVoice/ChanOp\002"
notice $nick "ignore unignore clear opstat lock unlock dccme channels global"
}
### T ###
if {[matchattr $handle t]} {
notice $nick ""
notice $nick "\002Global Tech Access: ChanVoice/ChanOp\002"
notice $nick "msg save banner (broadcast) log send notice"
}
### M ###
if {[matchattr $handle m]} {
notice $nick ""
notice $nick "\002Global Master Access: ChanVoice/ChanOp/ChanMaster/ChanOwner\002"
notice $nick "rehash restart join part suspend unsuspend xsend chhandle chnick"
}
### N ###
if {[matchattr $handle n]} {
notice $nick ""
notice $nick "\002Global Owner Access:All Commands\002"
notice $nick "die"
}
return 0
}
### End of menu - Start of command help ###
###########################################
#########################
### GLOBAL / EVERYONE ###
#########################
### UPTIME ###
if {$misc1 == "uptime"} {
notice $nick "\002The UPTIME command\002"
notice $nick "Usage: (/msg) $botnick uptime"
notice $nick " "
notice $nick "The bot tells how long it's been up since being restarted."
return 0
}
### NOTE ###
if {$misc1 == "note"} {
notice $nick "\002The NOTE command\002"
notice $nick "Usage: (/msg) $botnick note <nick\[,nick2,nick3....\] | @level | *level | %level> <message>"
notice $nick " "
notice $nick "The bot sends a note to <nick>."
notice $nick " "
notice $nick "The @ and * options allow you to mass-note people of a certain access level"
notice $nick "(@chanop, *master, %chanowner or @botowner for example)."
return 0
}
### NICK ###
if {$misc1 == "nick"} {
notice $nick "\002The NICK command\002"
notice $nick "Usage: (/msg) $botnick nick <new nick>"
notice $nick " "
notice $nick "Makes the bot change your nick in the userlist."
return 0
}
### VERSION ###
if {$misc1 == "version"} {
notice $nick "\002The VERSION command\002"
notice $nick "Usage: (/msg) $botnick version"
notice $nick " "
notice $nick "The bot replies the version of StormBot."
return 0
}
### PING ###
if {$misc1 == "ping"} {
notice $nick "\002The PING command \002"
notice $nick "Usage: (/msg) $botnick ping me "
notice $nick "Usage: (/msg) $botnick ping <nickname> "
notice $nick " "
notice $nick "Pings you or someone else and tells you/them the lag. "
return 0
}
### STATS ###
if {$misc1 == "stats"} {
notice $nick "\002The STATS command\002"
notice $nick "Usage: (/msg) $botnick stats (#channel) <me> "
notice $nick "Usage: (/msg) $botnick stats (#channel) <nickname> "
notice $nick " "
notice $nick "Makes the Bot tell you the stats about you or an user. "
return 0
}
### WHOIS ###
if {$misc1 == "whois"} {
notice $nick "\002The WHOIS command\002"
notice $nick "Usage: (/msg) $botnick whois (#channel) <nickname> "
notice $nick " "
notice $nick "Makes the Bot tell you about a user. "
return 0
}
### INFO ###
if {$misc1 == "info"} {
notice $nick "\002The INFO command\002"
notice $nick "Usage: (/msg) $botnick info (#channel) <nickname> <type>"
notice $nick " "
notice $nick "Makes the Bot tell you a user's info about a subject. "
notice $nick "Valid types are: name, sex, bday, location, occupation, url, email, other"
return 0
}
### ACCESS ###
if {$misc1 == "access"} {
notice $nick "\002The ACCESS command\002"
notice $nick "Usage: (/msg) $botnick access <nickname> "
notice $nick " "
notice $nick "Makes the Bot tell you about a user's channel and global access. "
return 0
}
### USERLIST ###
if {$misc1 == "userlist"} {
notice $nick "\002The USERLIST command\002"
notice $nick "Usage (/msg) $botnick userlist (#channel)"
notice $nick " "
notice $nick "Bot gives a userlist for a channel."
return 0
}
### TIME ###
if {$misc1 == "time"} {
notice $nick "\002The TIME command\002"
notice $nick "Usage: (/msg) $botnick time"
notice $nick " "
notice $nick "Bot gives you the time."
notice $nick "\002Related Topics:\002 date"
return 0
}
### DATE ###
if {$misc1 == "date"} {
notice $nick "\002The DATE command\002"
notice $nick "Usage: (/msg) $botnick date"
notice $nick " "
notice $nick "Bot gives you the date."
notice $nick "\002Related Topics:\002 time"
return 0
}
### TOP ###
if {$misc1 == "top"} {
notice $nick "\002The TOP command\002"
notice $nick "Usage: (/msg) $botnick top (#channel) <time | talk | join> (# of results to display)"
notice $nick " "
notice $nick "Bot will tell you the top 10 for time, talk or join."
notice $nick "Default is top 10, but you can specify any positive value."
return 0
}
### SEEN ###
if {$misc1 == "seen"} {
notice $nick "\002The SEEN command\002"
notice $nick "Usage: (/msg) $botnick seen (#channel) <nickname> "
notice $nick " "
notice $nick "Bot will tell you when it last saw a person."
return 0
}
### IGNORELIST ###
if {$misc1 == "ignorelist"} {
notice $nick "\002The IGNORELIST command\002"
notice $nick "Usage: (/msg) $botnick ignorelist"
notice $nick " "
notice $nick "Bot will tell you who is currently being ignored"
notice $nick "\002Related Topics:\002 ignore unignore"
return 0
}
### FLAGS ###
if {$misc1 == "flags"} {
notice $nick "\002The FLAGS command\002"
notice $nick "Usage: (/msg) $botnick flags <channel | global>"
notice $nick " "
notice $nick "The bot lists all of the flags for channel or global access."
notice $nick "\002Related Topics:\002 access whois levels"
return 0
}
### LEVELS ###
if {$misc1 == "levels"} {
notice $nick "\002The LEVELS command\002"
notice $nick "Usage: (/msg) $botnick levels"
notice $nick " "
notice $nick "The bot lists all of the channel and global levels."
notice $nick "\002Related Topics:\002 adduser access whois flags"
return 0
}
### BANTYPE ###
if {$misc1 == "bantype"} {
notice $nick "\002The BANTYPE command\002"
notice $nick "Usage: (/msg) $botnick bantype"
notice $nick " "
notice $nick "The bot lists all of the bantypes (ban time) you can use."
notice $nick "\002Related Topics:\002 ban unban banlist"
return 0
}
### BANLIST ###
if {$misc1 == "banlist"} {
notice $nick "\002The BANLIST command\002"
notice $nick "Usage: (/msg) $botnick banlist (#channel) (wildcarded mask) (limiter)"
notice $nick " "
notice $nick "Gives you a banlist of bans made by the bot "
notice $nick "on a certain channel. (Will also list Global bans if you use ''global'' or ''all'') "
notice $nick "\002Related Topics:\002 ban unban bantype"
return 0
}
#################
### ChanVoice ###
#################
if {[matchattr $handle vo|vo $chan]} {
### GREET ###
if {$misc1 == "greet"} {
notice $nick "\002The GREET command\002"
notice $nick "Usage: (/msg) $botnick greet (#channel) <greet>"
notice $nick "To clear your greet: (/msg) $botnick greet (#channel) none"
notice $nick " "
notice $nick "The greet is a line of text, that the bot will say when "
notice $nick "you join a channel that it is in. "
return 0
}
### SET ###
if {$misc1 == "set"} {
notice $nick "\002The SET command\002"
notice $nick "Usage: (/msg) $botnick set <type> <settings>"
notice $nick "To clear your info: (/msg) $botnick set (#channel) <type> none"
notice $nick " "
notice $nick "Valid types: name, sex, bday, location, occupation, url, email, other "
notice $nick "The information shows up in a 'whois' and 'info'. "
return 0
}
### WHO ###
if {$misc1 == "who"} {
notice $nick "\002The WHO command\002"
notice $nick "Usage: (/msg) $botnick who (#channel) "
notice $nick " "
notice $nick "The bot lists who is in a channel"
return 0
}
### VOICE ###
if {$misc1 == "voice"} {
notice $nick "\002The VOICE command\002"
notice $nick "Usage: (/msg) $botnick voice (#channel) me "
notice $nick "Usage: (/msg) $botnick voice (#channel) <nickname> "
notice $nick " "
notice $nick "Tells the Bot to +v someone "
notice $nick "\002Related Topics:\002 devoice op deop"
return 0
}
### DEVOICE ###
if {$misc1 == "devoice"} {
notice $nick "\002The DEVOICE command\002"
notice $nick "Usage: (/msg) $botnick (#channel) devoice me "
notice $nick "Usage: (/msg) $botnick (#channel) devoice <nickname> "
notice $nick " "
notice $nick "Tells the Bot to -v someone "
notice $nick "\002Related Topics:\002 voice op deop"
return 0
}
}
##############
### ChanOp ###
##############
if {[matchattr $handle o|o $chan]} {
### WALLOPS ###
if {$misc1 == "wallops" || $misc1 == "wall"} {
notice $nick "\002The WALL/WALLOPS command\002"
notice $nick "Usage: (/msg) $botnick wall (#channel) <message>"
notice $nick "Usage: (/msg) $botnick wallops (#channel) <message>"
notice $nick " "
notice $nick "Makes the bot send a messages to all people oped on a channel."
return 0
}
### OP ###
if {$misc1 == "op"} {
notice $nick "\002The OP command\002"
notice $nick "Usage: (/msg) $botnick op (#channel) me"
notice $nick "Usage: (/msg) $botnick op (#channel) <nick>"
notice $nick "Usage: (/msg) $botnick op (#channel) <nick1> <nick2>"
notice $nick " "
notice $nick "Makes the bot op you or a person(s) "
notice $nick "\002Related Topics:\002 deop voice devoice"
return 0
}
### DEOP ###
if {$misc1 == "deop"} {
notice $nick "\002The DEOP command\020"
notice $nick "Usage: (/msg) $botnick deop (#channel) me"
notice $nick "Usage: (/msg) $botnick deop (#channel) <nick>"
notice $nick "Usage: (/msg) $botnick deop (#channel) <nick1> <nick2> "
notice $nick " "
notice $nick "Makes the bot deop you or a person(s) "
notice $nick "\002Related Topics:\002 op voice devoice"
return 0
}
### KICK ###
if {$misc1 == "kick"} {
notice $nick "\002The KICK command\002"
notice $nick "Usage: (/msg) $botnick kick (#channel) me <reason>"
notice $nick "Usage: (/msg) $botnick kick (#channel) <nick> <reason> "
notice $nick " "
notice $nick "Tells the Bot to Kick you or others "
notice $nick "\002Related Topics:\002 ban"
return 0
}
### TOPIC ###
if {$misc1 == "topic"} {
notice $nick "\002The TOPIC command\002"
notice $nick "Usage: (/msg) $botnick topic (#channel) <text for topic> "
notice $nick " "
notice $nick "Tells the Bot to set a topic. "
notice $nick "-- (/msg) $botnick topic (#channel) none "
notice $nick " this will remove the topic from the bot."
return 0
}
### MODE ###
if {$misc1 == "mode"} {
notice $nick "\002The MODE command\002"
notice $nick "Usage: (/msg) $botnick (#channel) mode (+ or - stinlk) "
notice $nick " "
notice $nick "Sets channel modes "
return 0
}
### BAN ###
if {$misc1 == "ban"} {
notice $nick "\002The BAN command\002"
notice $nick "Usage: (/msg) $botnick ban (#channel) <nickname> (bantype) <reason> "
notice $nick "Usage: (/msg) $botnick ban (#channel) <user@host> (bantype) <reason>"
notice $nick " "
notice $nick "tells the bot to ban someone"
notice $nick "See also: (/msg) $botnick bantype"
notice $nick "\002Related Topics:\002 unban kick"
return 0
}
### UNBAN ###
if {$misc1 == "unban"} {
notice $nick "\002The UNBAN command\002"
notice $nick "Usage: (/msg) $botnick unban (#channel) <user@host> "
notice $nick " "
notice $nick "Makes the Bot unban someone "
notice $nick "\002Related Topics:\002 unban kick"
return 0
}
}
##################
### ChanMaster ###
##################
if {[matchattr $handle m|m $chan]} {
### ADDUSER ###
if {$misc1 == "adduser"} {
notice $nick "\002The ADDUSER command\002"
notice $nick "Usage: (/msg) $botnick adduser (#channel) <nickname> <level> "
notice $nick " "
notice $nick "Adds a user to the Bot. "
notice $nick "(see also: (/msg) (!)$botnick levels)"
notice $nick "Use !nick for a static host add."
notice $nick "\002Related Topics:\002 remuser levels"
return 0
}
### REMUSER ###
if {$misc1 == "remuser"} {
notice $nick "\002The REMUSER command\002"
notice $nick "Usage: (/msg) $botnick remuser (#channel) <nickname> (global)"
notice $nick " "
notice $nick "Removes a user from the bots channel userlist "
notice $nick "Use 'global' to remove the user from the global userlist (Global masters only)"
notice $nick "\002Related Topics:\002 adduser levels"
return 0
}
### ONJOIN ###
if {$misc1 == "onjoin"} {
notice $nick "\002The ONJOIN command\002"
notice $nick "Usage: (/msg) $botnick onjoin (#channel) <clear | add | edit # | show > (text)"
notice $nick " "
notice $nick "Clears, adds to, or modifies a channel's onjoin message"
notice $nick "You can use \$nick, \$chan or \$bot as variables in your message."
notice $nick "\$nick = joinee's nick, \$chan = the channel name, and \$bot = the bot's nick."
return 0
}
### MODUSER ###
if {$misc1 == "moduser"} {
notice $nick "\002The MODUSER command\002"
notice $nick "Usage: (/msg) $botnick moduser (#channel) <nickname> <level>"
notice $nick " "
notice $nick "Modifies a user's access level in the bot's channel userlist "
notice $nick "\002Related Topics:\002 adduser remuser chattr levels"
return 0
}
### CYCLE ###
if {$misc1 == "cycle"} {
notice $nick "\002The CYCLE commmand\002"
notice $nick "Usage: (/msg) $botnick cycle (#channel)"
notice $nick " "
notice $nick "Bot parts a channel then rejoins "
return 0
}
### INVITE ###
if {$misc1 == "invite"} {
notice $nick "\002The INVITE command\002"
notice $nick "Usage: (/msg) $botnick invite (#channel) <nick>"
notice $nick " "
notice $nick "Tells the Bot to Invite a user to a channel "
return 0
}
### CHANINFO ###
if {$misc1 == "chaninfo"} {
notice $nick "\002The CHANINFO command\002"
notice $nick "Usage: (/msg) $botnick chaninfo (#channel)"
notice $nick " "
notice $nick "Shows information about a channel's settings. "
notice $nick " chanmode which modes are enforced on the channel, both + and -"
notice $nick " modes can be enforced. Specify \"none\" to make the"
notice $nick " bot stop enforcing modes"
notice $nick " idle-kick kick idle users (non +f's anyway) on the channel"
notice $nick " after how many minutes (use 0 to turn this off) "
notice $nick " "
notice $nick " The following can be set + or - "
notice $nick " (eg (/msg) $botnick chanset (#channel) -clearbans)"
notice $nick " clearbans clear all the channel bans when the bot joins the "
notice $nick " channel?"
notice $nick " enforcebans kicks people who match channel bans?"
notice $nick " dynamicbans only activate bans on channel when they are needed"
notice $nick " userbans allow other users to place bans on the channel"
notice $nick " autoop automatically op users when they join the channel"
notice $nick " bitch only allow users with the +o flag to be ops on the "
notice $nick " channel"
notice $nick " greet say a users info line when they join the channel"
notice $nick " protectops re-op a +o user who gets deopped?"
notice $nick " dontkickops never kick +o flag people"
notice $nick " statuslog log the channel status every 5 minutes"
notice $nick " stopnethack de-op anyone who enters the channel with server"
notice $nick " ops"
notice $nick " revenge take revenge on anyone who deops, kicks or"
notice $nick " bans the bot or any valid user"
notice $nick " secret don't provide info about the channel over the botnet"
notice $nick " shared share user settings for this channel "
notice $nick " (NOTE: this can only be set in the config file)"
notice $nick " autovoice this causes the bot to also monitor channel voice"
notice $nick " settings, using the +v/+q settings."
notice $nick " "
notice $nick " The following are flood settins, they are set by going"
notice $nick " (/msg) $botnick chanset (#channel) flood-type number:seconds"
notice $nick " where number & seconds are integers indicating the number of"
notice $nick " times in how many seconds the flood will be triggered."
notice $nick " flood-chan this defines the flood level for public chatter"
notice $nick " & actions"
notice $nick " flood-ctcp this defines the flood level for ctcp's to the"
notice $nick " channel (include PING & VERSION), except for ACTION's"
notice $nick " flood-join this defines the number of joins from a give "
notice $nick " user@host that constitutes a flood"
notice $nick " flood-kick how many kicks in the given time are a flood"
notice $nick " flood-deop deops in the given time"
if {[matchattr $handle m|n $chan]} {
notice $nick " See also: chanset"
}
return 0
}
}
###################
### ChanOwner 1 ###
###################
if {[matchattr $handle m|n $chan]} {
### CHANSET ###
if {$misc1 == "chanset"} {
notice $nick "\002The CHANSET commmand\002"
notice $nick "Usage: (/msg) $botnick chanset (#channel) <type> (args | none)"
notice $nick " "
notice $nick "Sets the channel settings."
notice $nick "To see the valid settings, type: (/msg) $botnick help chaninfo (#channel) "
return 0
}
}
###################
### ChanOwner 2 ###
###################
if {[matchattr $handle n|n $chan]} {
### ADDMASK ###
if {$misc1 == "addhost"} {set misc1 "addmask"}
if {$misc1 == "addmask"} {
notice $nick "\002The ADDMASK (ADDHOST) command\002"
notice $nick "Usage: (/msg) $botnick addmask <nick> <nick | mask>"
notice $nick " "
notice $nick "Adds the mask or <nick>'s current mask to <nick>."
return 0
}
### REMMASK ###
if {$misc1 == "delmask"} {set misc1 "remmask"}
if {$misc1 == "delhost"} {set misc1 "remmask"}
if {$misc1 == "remmask"} {
notice $nick "\002The REMMASK (DELHOST, DELMASK) command\002"
notice $nick "Usage: (/msg) $botnick remmask <nick> <mask>"
notice $nick " "
notice $nick "Removes <mask> from <user>. The mask you specify \002MUST\002"
notice $nick "exactly match the host you're trying to remove; the bot will"
notice $nick "not wildcard match a mask since the hosts are wildcarded anyway."
return 0
}
}
#################
### Global Op ###
#################
if {[matchattr $handle o]} {
### XLOGIN ###
if {$misc1 == "xlogin"} {
notice $nick "\002The XLOGIN command\002"
notice $nick "Usage: /msg $botnick xlogin (password) "
notice $nick " "
notice $nick "The bot will log you in on all bots in the botnet."
return 0
}
### OPSTAT ###
if {$misc1 == "opstat"} {
notice $nick "\002The OPSTAT command\002"
notice $nick "Usage: (/msg) $botnick opstat [check]"
notice $nick " "
notice $nick "The bot will list all the channels and list "
notice $nick "if he is op'd in each of them. "
return 0
}
### CHANNELS ###
if {$misc1 == "channels"} {
notice $nick "\002The CHANNELS command\002"
notice $nick "Usage: (/msg) $botnick channels "
notice $nick " "
notice $nick "Gives a list of channel that a bot is on. "
return 0
}
### IGNORE ###
if {$misc1 == "ignore"} {
notice $nick "\002The IGNORE command\002"
notice $nick "Usage: (/msg) $botnick ignore <user@host>"
notice $nick " "
notice $nick "Bot ignores a person at that user@host"
notice $nick "\002Related Topics:\002 unignore ignorelist"
return 0
}
### UNIGNORE ###
if {$misc1 == "unignore"} {
notice $nick "\002The UNIGNORE command\002"
notice $nick "Usage: (/msg) $botnick unignore <user@host>"
notice $nick " "
notice $nick "Bot Unignores a person at that user@host"
notice $nick "\002Related Topics:\002 ignore ignorelist"
return 0
}
### LOCK ###
if {$misc1 == "lock"} {
notice $nick "\002The LOCK command\002"
notice $nick "Usage: (/msg) $botnick lock <#channel> "
notice $nick " "
notice $nick "Tells the Bot to lock up the channel"
notice $nick "Mode changes to channel are +smnti"
notice $nick "\002Related Topics:\002 unlock"
return 0
}
### UNLOCK ###
if {$misc1 == "unlock"} {
notice $nick "\002The UNLOCK command\002"
notice $nick "Usage: (/msg) $botnick unlock <#channel> "
notice $nick " "
notice $nick "Tells the Bot to unlock the channel "
notice $nick "Mode changes to channel are -smi"
notice $nick "\002Related Topics:\002 lock"
return 0
}
### CLEAR ###
if {$misc1 == "clear"} {
notice $nick "\002The CLEAR command\002"
notice $nick "Usage: (/msg) $botnick clear (#channel)"
notice $nick " "
notice $nick "Clears the channel modes "
return 0
}
}
####################
### Global Techs ###
####################
if {[matchattr $handle t]} {
### LOG ###
if {$misc1 == "log"} {
notice $nick "\002The LOG command\002"
notice $nick "Usage: (/msg) $botnick log <message> "
notice $nick " "
notice $nick "Tells the Bot to add a note to the log file."
return 0
}
### SAVE ###
if {$misc1 == "save"} {
notice $nick "\002The SAVE command\002"
notice $nick "Usage: (/msg) $botnick save"
notice $nick " "
notice $nick "Bot saves user/channel files."
return 0
}
### SAY ###
if {$misc1 == "say"} {
notice $nick "\002The SAY command\002"
notice $nick "Usage: (/msg) $botnick say (#channel) <message> "
notice $nick " "
notice $nick "Tells the Bot to say something in channel "
return 0
}
### MSG ###
if {$misc1 == "msg"} {
notice $nick "\002The MSG command\002"
notice $nick "Usage: (/msg) $botnick msg <nickname> <message> "
notice $nick " "
notice $nick "Messages someone with a message. "
return 0
}
### NOTICE ###
if {$misc1 == "notice"} {
notice $nick "\002The NOTICE command\002"
notice $nick "Usage: (/msg) $botnick notice <nickname> <message> "
notice $nick " "
notice $nick "Notices someone with a message."
return 0
}
### BANNER ###
if {$misc1 == "banner" || $misc1 == "broadcast"} {
notice $nick "\002The BANNER command\002"
notice $nick "\002The BROADCAST command\002"
notice $nick "Usage: (/msg) $botnick banner <text> "
notice $nick "Usage: (/msg) $botnick broadcast <text> "
notice $nick " "
notice $nick "The bot will show <text> in all channels. "
return 0
}
### JUMP ###
if {$misc1 == "jump"} {
notice $nick "\002The JUMP command\002"
notice $nick "Usage: (/msg) $botnick jump <server> \[port \[password\]\]"
notice $nick " "
notice $nick "The bot will jump from its present server to <server>."
return 0
}
### SEND ###
if {$misc1 == "send"} {
notice $nick "\002The SEND command\002"
notice $nick "Usage: (/msg) $botnick send <botnick> #channel <command> \[args\]"
notice $nick " "
notice $nick "The bot will send the <command> to <botnick> to execute (as if"
notice $nick "the bot had normally received the command). This works well for sending"
notice $nick "commands to any bot lost in a netsplit or on another network. Do note"
notice $nick "that the target channel \002must\002 be specified, even if you're sending"
notice $nick "a non-channel specific command."
notice $nick " "
notice $nick "\002NOTICE\002: $botnick and <botnick> \002\037MUST\037 be in the same botnet\002 to make this command of any use."
return 0
}
}
######################
### Global Masters ###
######################
if {[matchattr $handle m]} {
### CHNICK ###
if {$misc1 == "chnick" || $misc1 == "chhandle"} {
notice $nick "\002The CHNICK command\002"
notice $nick "\002The CHHANDLE command\002"
notice $nick "Usage: (/msg) $botnick chnick <old nick> <new nick>"
notice $nick " "
notice $nick "Makes the bot change a person's nick in the bot's userfile."
return 0
}
### SUSPEND ###
if {$misc1 == "suspend"} {
notice $nick "\002The SUSPEND command\002"
notice $nick "Usage: (/msg) $botnick suspend <nickname | list> \[reason\]"
notice $nick " "
notice $nick "Suspends all access until user is unsuspended; they have no access to the bot."
notice $nick "An optional reason can be stated if desired. Use SUSPEND <list> to see a list of suspended"
notice $nick "users and the reasons."
notice $nick "\002Related Topics:\002 unsuspend"
return 0
}
### UNSUSPEND ###
if {$misc1 == "unsuspend"} {
notice $nick "\002The UNSUSPEND command\002"
notice $nick "Usage: (/msg) $botnick unsuspend <nickname> "
notice $nick " "
notice $nick "The bot unsuspends a suspended user. "
notice $nick "\002Related Topics:\002 suspend"
return 0
}
### REHASH ###
if {$misc1 == "rehash"} {
notice $nick "\002The REHASH command\002"
notice $nick "Usage: (/msg) $botnick rehash "
notice $nick " "
notice $nick "The bot will rehash it's config file. "
return 0
}
### RESTART ###
if {$misc1 == "restart"} {
notice $nick "\002The RESTART command\002"
notice $nick "Usage: (/msg) $botnick restart "
notice $nick " "
notice $nick "The bot will restart and load it's configfile and modules again. "
return 0
}
### JOIN ###
if {$misc1 == "join"} {
notice $nick "\002The JOIN command\002"
notice $nick "Usage: (/msg) $botnick join <#channel> "
notice $nick " "
notice $nick "The bot will join a channel. "
return 0
}
### PART ###
if {$misc1 == "part" || $misc1 == "remchan"} {
notice $nick "\002The PART command\002"
notice $nick "Usage: (/msg) $botnick part <#channel> \[reason\]"
notice $nick " "
notice $nick "The bot will leave a channel. You may add a reason if desired."
return 0
}
### XSEND ###
if {$misc1 == "xsend"} {
notice $nick "\002The XSEND command\002"
notice $nick "Usage: (/msg) $botnick xsend #channel <command> \[args\]"
notice $nick " "
notice $nick "The bot will send <command> to all bots on the botnet, similar to the"
notice $nick "\"$globalcallcommand\" command trigger. This works well for sending commands to bots lost"
notice $nick "in a netsplit or on other networks. Do note"
notice $nick "that the target channel \002must\002 be specified, even if you're sending"
notice $nick "a non-channel specific command."
notice $nick " "
notice $nick "\002NOTICE\002: $botnick \002\037MUST\037 be part of a botnet\002 to make this command of any use."
return 0
}
}
#####################
### Global Owners ###
#####################
if {[matchattr $handle n]} {
### DIE ###
if {$misc1 == "die"} {
notice $nick "\002The DIE command\002"
notice $nick "Usage: (/msg) $botnick die"
notice $nick " "
notice $nick "Kills the bot (the bot need to be started again from the shell)."
return 0
}
}
### End ###
###########
notice $nick "Sorry, you can't get any help on '$misc1'."
return 0
}
#############
### Procs ###
#############
### Jump proc
proc call_jump {nick misc1 misc2 misc3} {
global botnick servers
if {[string first "?" $misc1] > -1 || [string first "*" $misc1] > -1} {
set s [string tolower $servers]
set m ""
foreach a $s {
if {[string match [string tolower $misc1] $a]} {set m $a}
}
if {$m == ""} {
notice $nick "No match was made on $misc1."; return 0}
set m [lindex $m 0]
# Handles multiple ports per server ["blah.blah.org 6665 6666 6667"]
set m [lindex [split $m ":"] 0]
# Handles single port per server ["blah.blah.org:6667"]
set misc1 $m
putlog "Found $m in the server list."
}
set a $misc1
set s ""
if {$a == ""} {set a "the next default server"}
putlog "Jumping servers to $a (per $nick)."
if {$misc1 != ""} {set s $misc1}
if {$misc2 != ""} {append s " $misc2"}
if {$misc3 != ""} {append s " $misc3"}
if {$s != ""} {jump $s} else {jump}
return 0
}
### Uptime proc
proc call_uptime {nick} {
global startup uptime
notice $nick "I've been up since [ctv $uptime 3600] GMT."
return 0
# Bug exists w/the CT call
}
### Nick proc
proc call_nick {nick handle misc1} {
if {$misc1 == ""} {
notice $nick "I would help if you told me what nick you want to be."
return 0
}
if {[validuser $misc1]} {
notice $nick "There's already someone known by that nick."
return 0
}
if {[chnick $handle $misc1] == 0} {
notice $nick "Either \002$misc1\002 was already taken or is invalid."
return 0
}
notice $nick "You are now known as \002$misc1\002 to me."
save
return 1
}
### Chnick proc
proc call_chnick {nick handle misc1 misc2} {
if {$misc1 == ""} {
notice $nick "It would help if you told me whom you wanted me to rename."
return 0
}
if {$misc2 == ""} {
notice $nick "It would help if you told me what nick you want $misc1 to be."
return 0
}
if {[string tolower $misc1] == "me"} {set misc1 $nick}
if {![validuser $misc1]} {
notice $nick "Who the hell is $misc1?"
return 0
}
if {[validuser $misc2]} {
notice $nick "There's already someone known by that nick."
return 0
}
if {![checkglobalaccess $handle $misc2]} {
notice $nick "You don't have enough access to do that!"
return 0
}
if {[chnick $misc1 $misc2] == 0} {
notice $nick "Either \002$misc2\002 was already taken or is invalid."
return 0
}
notice $nick "$misc1 is now known as \002$misc2\002 to me."
save
return 1
}
### Note proc
proc call_note {nick host handle chan misc1 misc2end} {
global bnick groupname owner levels
if {[string tolower $misc1] == "me"} {set misc1 $nick}
if {[onchan $misc1 $chan]} {
set whoisnick $misc1
set whoishandle [nick2hand $misc1 $chan]
if {$whoishandle == "" || $whoishandle == "*"} {
notice $nick "\002$misc1\002 is \002NOT\002 a known user."
}
} elseif {[validuser $misc1]} {
set whoisnick $misc1
set whoishandle $misc1
} else {
notice $nick "\002$misc1\002 is \002NOT\002 a known user."
}
if {[matchattr $whoishandle b]} {
notice $nick "Sending a note to a bot?!"
return 0
}
set response [sendnote $handle $whoishandle $misc2end]
if {$response == "3"} {
notice $nick "Unable to add note to notefile. Please try again later."
return 0
}
if {$response == "0"} {
notice $nick "Note could not be delivered to $misc1."
return 0
}
if {[string tolower $whoisnick] != [string tolower $whoishandle]} {
set misc1 "$whoisnick ($whoishandle)"
}
notice $nick "Successfully sent note to $misc1."
return 0
}
### Time proc
proc call_time {nick} {notice $nick "The current time: [currtime] [strftime %Z]."}
### Date proc
proc call_date {nick} {notice $nick "The current date: [currdate]"}
### Ping proc
proc call_ping {nick chan misc1} {
global callcommand botnick
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick ping (#channel) <me | nick>"
return 0
}
if {[string tolower $misc1] == "me"} {
msg $nick "\001PING [clock seconds]\001"
putlog "ping me received from $nick"
return 0
}
if {[onchan $misc1 $chan]} {
notice $misc1 "$nick sent a ping to you."
msg $misc1 "\001PING [clock seconds]\001"
putlog "ping $misc1 received from $nick"
notice $nick "Sent a ping to $misc1"
return 0
}
notice $nick "$misc1 is not in $chan, and therefore can't be pinged. "
}
### Version proc
proc call_version {nick} {
global stormver
notice $nick "\002StormBot $stormver by Xone and Domino\002 - BService - #Bothouse @ ChatNet"
}
### Top proc
proc call_top {nick chan misc1 misc2} {
global botnick
set default 10
if {($misc2 == "") || ($misc2 < 1) || ($misc2 > 25)} {set misc2 $default}
if {$misc1 == "time"} {
set foolista [sort_time $chan]
set foo ""
for {set i 0} {$i < $misc2} {incr i} {
set totalyear [lindex [lindex $foolista $i] 0]
if {$totalyear != ""} {
set totalyear [expr 60 * $totalyear]
}
if {$totalyear >= 31536000} {
set yearsfull [expr $totalyear/31536000]
set years [expr int($yearsfull)]
set yearssub [expr 31536000*$years]
set totalday [expr $totalyear - $yearssub]
}
if {$totalyear < 31536000} {
set totalday $totalyear
set years 0
}
if {$totalday >= 86400} {
set daysfull [expr $totalday/86400]
set days [expr int($daysfull)]
set dayssub [expr 86400*$days]
set totalhour [expr $totalday - $dayssub]
}
if {$totalday < 86400} {
set totalhour $totalday
set days 0
}
if {$totalhour >= 3600} {
set hoursfull [expr $totalhour/3600]
set hours [expr int($hoursfull)]
set hourssub [expr 3600*$hours]
set totalmin [expr $totalhour - $hourssub]
}
if {$totalhour < 3600} {
set totalmin $totalhour
set hours 0
}
if {$totalmin >= 60} {
set minsfull [expr $totalmin/60]
set mins [expr int($minsfull)]
}
if {$totalmin < 60} {
set mins 0
}
if {$years < 1} {set yearstext ""} elseif {$years == 1} {set yearstext "$years year, "} {set yearstext "$years years, "}
if {$days < 1} {set daystext ""} elseif {$days == 1} {set daystext "$days day, "} {set daystext "$days days, "}
if {$hours < 1} {set hourstext ""} elseif {$hours == 1} {set hourstext "$hours hour, "} {set hourstext "$hours hours, "}
if {$mins < 1} {set minstext ""} elseif {$mins == 1} {set minstext "$mins min"} {set minstext "$mins mins"}
set output $yearstext$daystext$hourstext$minstext
set output [string trimright $output ", "]
if {$output != ""} {
append foo "\002[expr $i + 1].\002 [lindex [lindex $foolista $i] 1]"
append foo " ($output) "
}
}
notice $nick "\002Top $misc2 (time):\002 $foo"
return 1
}
if {$misc1 == "talk"} {
set foolista [sort_talk $chan]
set foo ""
for {set i 0} {$i < $misc2} {incr i} {
if {[lindex $foolista $i] != ""} {
append foo "\002[expr $i + 1].\002 [lindex [lindex $foolista $i] 1]"
append foo " ([expr [lindex [lindex $foolista $i] 0]/1024].[expr (($i%1024)*10)/1024] kb) "
}
}
notice $nick "\002Top $misc2 (talk):\002 $foo"
return 1
}
if {$misc1 == "join"} {
set foolista [sort_join $chan]
set foo ""
for {set i 0} {$i < $misc2} {incr i} {
if {[lindex $foolista $i] != ""} {
append foo "\002[expr $i + 1].\002 [lindex [lindex $foolista $i] 1]"
append foo " ([lindex [lindex $foolista $i] 0]) "
}
}
notice $nick "\002Top $misc2 (join):\002 $foo"
return 1
}
notice $nick "Usage: (/msg) $botnick top (#channel) <time | talk | join>"
return 0
}
### Seen proc
proc call_seen {nick uhost handle misc1end} {
*msg:seen $nick $uhost $handle [join $misc1end]
return 0
}
### Stats proc
proc call_stats {nick chan misc1} {
global botnick
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick stats (#channel) <me | nick>"
return 0
}
if {[string tolower $misc1] == "me"} {
set statswho $nick
} else {
set statswho $misc1
}
if {[validuser $statswho]} {
set statsnick $statswho
set statshandle $statswho
} elseif {[validuser [nick2hand $statswho $chan]]} {
set statsnick $statswho
set statshandle [nick2hand $statsnick $chan]
} else {
notice $nick "$statswho is Not a known User.."
return 0
}
if {[matchattr $statshandle +b]} {
notice $nick "I don't collect stats for bots!"
return 0
}
notice $nick "\002 - Stats for $statsnick - \002"
if {[getuser $statshandle XTRA "stat.[string tolower $chan]"] == ""} {
setdefaultstats $statshandle $chan
}
set timelist [sort_time $chan]
set j 0
foreach i $timelist {
incr j
if {[string tolower [lindex $i 1]] == [string tolower $statshandle]} {
set totalyear [expr [lindex $i 0] * 60]
if {$totalyear >= 31536000} {
set yearsfull [expr $totalyear/31536000]
set years [expr int($yearsfull)]
set yearssub [expr 31536000*$years]
set totalday [expr $totalyear - $yearssub]
}
if {$totalyear < 31536000} {
set totalday $totalyear
set years 0
}
if {$totalday >= 86400} {
set daysfull [expr $totalday/86400]
set days [expr int($daysfull)]
set dayssub [expr 86400*$days]
set totalhour [expr $totalday - $dayssub]
}
if {$totalday < 86400} {
set totalhour $totalday
set days 0
}
if {$totalhour >= 3600} {
set hoursfull [expr $totalhour/3600]
set hours [expr int($hoursfull)]
set hourssub [expr 3600*$hours]
set totalmin [expr $totalhour - $hourssub]
}
if {$totalhour < 3600} {
set totalmin $totalhour
set hours 0
}
if {$totalmin >= 60} {
set minsfull [expr $totalmin/60]
set mins [expr int($minsfull)]
}
if {$totalmin < 60} {
set mins 0
}
if {$years < 1} {set yearstext ""} elseif {$years == 1} {set yearstext "$years year, "} {set yearstext "$years years, "}
if {$days < 1} {set daystext ""} elseif {$days == 1} {set daystext "$days day, "} {set daystext "$days days, "}
if {$hours < 1} {set hourstext ""} elseif {$hours == 1} {set hourstext "$hours hour, "} {set hourstext "$hours hours, "}
if {$mins < 1} {set minstext ""} elseif {$mins == 1} {set minstext "$mins min"} {set minstext "$mins mins"}
set output $yearstext$daystext$hourstext$minstext
set output [string trimright $output ", "]
notice $nick "\002\037Time stats\037\002 "
notice $nick "\002Total time:\002 $output (#$j)"
break
}
}
set now [expr [clock seconds] - [lindex [getuser $statshandle XTRA "stat.[string tolower $chan]"] 3]]
set totaldays [expr (($now/86400)/7)+1]
set totalhours [expr (($now/3600)/24)+1]
set daytime ""
foreach i [lindex [lindex [getuser $statshandle XTRA "stat.[string tolower $chan]"] 0] 1] {
set thisday "[expr ($i/60)/$totaldays].[string index [expr ((($i%60)*10)/60)/$totaldays] 0]"
if {[string length $thisday] == 3} {
append daytime " $thisday"
} elseif {[string length $thisday] == 4} {
append daytime " $thisday"
} else {
append daytime " $thisday"
}
}
notice $nick "\002\037Days:\037 mon tue wed thu fre sat sun\002"
notice $nick " $daytime (hours/day)"
set hourtime ""
set hourtime2 ""
set j 0
foreach i [lindex [lindex [getuser $statshandle XTRA "stat.[string tolower $chan]"] 0] 2] {
set thishour [expr ($i)/$totalhours]
if {$j < 12} {
if {[string length $thishour] == 1} {
append hourtime " $thishour"
} elseif {[string length $thishour] == 2} {
append hourtime " $thishour"
} else {
append hourtime " $thishour"
}
} else {
if {[string length $thishour] == 1} {
append hourtime2 " $thishour"
} elseif {[string length $thishour] == 2} {
append hourtime2 " $thishour"
} else {
append hourtime2 " $thishour"
}
}
incr j
}
notice $nick "\002\037Hours:\037 00 01 02 03 04 05 06 07 08 09 10 11\002"
notice $nick " $hourtime (mins/hour)"
notice $nick "\002 12 13 14 15 16 17 18 19 20 21 22 23\002"
notice $nick " $hourtime2 (mins/hour)"
set talklist [sort_talk $chan]
set j 0
foreach i $talklist {
incr j
if {[string tolower [lindex $i 1]] == [string tolower $statshandle]} {
notice $nick "\002\037Talk stats\037\002 "
notice $nick "\002Total talk:\002 [expr [lindex $i 0]/1024].[string index [expr (([lindex $i 0]%1024)*10)/1024] 0]kb (#$j)"
break
}
}
set daytalk ""
foreach i [lindex [lindex [getuser $statshandle XTRA "stat.[string tolower $chan]"] 1] 1] {
set thisday "[expr ($i/1024)/$totaldays].[expr ((($i%1024)*10)/1024)/$totaldays]"
if {[string length $thisday] == 3} {
append daytalk " $thisday"
} elseif {[string length $thisday] == 4} {
append daytalk " $thisday"
} else {
append daytalk " $thisday"
}
}
notice $nick "\002\037Days:\037 mon tue wed thu fre sat sun\002"
notice $nick " $daytalk (kb/day)"
set hourtalk ""
set hourtalk2 ""
set j 0
foreach i [lindex [lindex [getuser $statshandle XTRA "stat.[string tolower $chan]"] 1] 2] {
if {$j < 12} {
set thishour "[expr ($i/1024)/$totalhours].[expr (($i%1024)*10)/1024]"
if {[string length $thishour] == 3} {
append hourtalk " $thishour"
} elseif {[string length $thishour] == 4} {
append hourtalk " $thishour"
} else {
append hourtalk "$thishour"
}
} else {
set thishour "[expr ($i/1024)/$totalhours].[expr (($i%1024)*10)/1024]"
if {[string length $thishour] == 3} {
append hourtalk2 " $thishour"
} elseif {[string length $thishour] == 4} {
append hourtalk2 " $thishour"
} else {
append hourtalk2 "$thishour"
}
}
incr j
}
notice $nick "\002\037Hours:\037 00 01 02 03 04 05 06 07 08 09 10 11\002"
notice $nick " $hourtalk (kb/hour)"
notice $nick "\002 12 13 14 15 16 17 18 19 20 21 22 23\002"
notice $nick " $hourtalk2 (kb/hour)"
set joinlist [sort_join $chan]
set j 0
foreach i $joinlist {
incr j
if {[string tolower [lindex $i 1]] == [string tolower $statshandle]} {
notice $nick "\002Total joins:\002 [lindex [getuser $statshandle XTRA "stat.[string tolower $chan]"] 2] (#$j)"
break
}
}
return 0
}
### Whois proc
proc call_whois {nick chan misc1} {
global botnick home groupname ownername mastername techname opname halfopname voicename homechanopname
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick whois (#channel) <me | nick>"
return 0
}
if {[string tolower $misc1] == "me"} {
set whois $nick
} else {
set whois $misc1
}
if {[onchan $whois $chan]} {
set whoisnick $whois
set whoishandle [nick2hand $whois $chan]
if {$whoishandle == "" || $whoishandle == "*"} {
notice $nick "\002$whois\002 is \002NOT\002 a known user."
return 0
}
} elseif {[validuser $whois]} {
set whoisnick $whois
set whoishandle $whois
} else {
notice $nick "\002$whois\002 is \002NOT\002 a known user."
return 0
}
set chanlevel "No access"
if {[matchattr $whoishandle |f $chan]} {
set chanlevel "Channel Friend (chanfriend)"
}
if {[matchattr $whoishandle |v $chan]} {
set chanlevel "Channel Voice (chanvoice)"
}
if {[matchattr $whoishandle |Hl $chan]} {
set chanlevel "Channel Halfop (chanhalfop)"
}
if {[matchattr $whoishandle |o $chan]} {
set chanlevel "Channel Op (chanop)"
}
if {[matchattr $whoishandle |m $chan]} {
set chanlevel "Channel Master (chanmaster)"
}
if {[matchattr $whoishandle |n $chan]} {
set chanlevel "Channel Owner (chanowner)"
}
set hosts [getuser $whoishandle HOSTS]
set info [getuser $whoishandle INFO]
set lastseen [lindex [getuser $whoishandle LASTON] 0]
set idle [getchanidle $whoisnick $chan]
if {$lastseen == 0} {
set lastseentime "Never seen"
} else {
set lastseentime [ctime $lastseen]
}
set lastseenwhere [lindex [getuser $whoishandle LASTON] 1]
notice $nick "\002 Whois $whoisnick on $chan\002"
notice $nick "\002 Handle:\002 $whoishandle"
if {!([getuser $whoishandle XTRA "name"] == "")} {
notice $nick "\002 Real name\002: [getuser $whoishandle XTRA "name"]"
}
if {!([getuser $whoishandle XTRA "sex"] == "")} {
notice $nick "\002 Sex\002: [getuser $whoishandle XTRA "sex"]"
}
if {!([getuser $whoishandle XTRA "bday"] == "")} {
set sbday [getuser $whoishandle XTRA "bday"]
if {[expr [lindex $sbday 0] == 1]} {
set month "January"
} elseif {[expr [lindex $sbday 0] == 2]} {
set month "Febuary"
} elseif {[expr [lindex $sbday 0] == 3]} {
set month "March"
} elseif {[expr [lindex $sbday 0] == 4]} {
set month "April"
} elseif {[expr [lindex $sbday 0] == 5]} {
set month "May"
} elseif {[expr [lindex $sbday 0] == 6]} {
set month "June"
} elseif {[expr [lindex $sbday 0] == 7]} {
set month "July"
} elseif {[expr [lindex $sbday 0] == 8]} {
set month "August"
} elseif {[expr [lindex $sbday 0] == 9]} {
set month "September"
} elseif {[expr [lindex $sbday 0] == 10]} {
set month "October"
} elseif {[expr [lindex $sbday 0] == 11]} {
set month "November"
} else {
set month "December"
}
notice $nick "\002 Birthday\002: $month [lindex $sbday 1], [lindex $sbday 2]"
}
if {!([getuser $whoishandle XTRA "location"] == "")} {
notice $nick "\002 Location\002: [getuser $whoishandle XTRA "location"]"
}
if {!([getuser $whoishandle XTRA "occupation"] == "")} {
notice $nick "\002 Occupation\002: [getuser $whoishandle XTRA "occupation"]"
}
if {!([getuser $whoishandle XTRA "url"] == "")} {
notice $nick "\002 Homepage\002: [getuser $whoishandle XTRA "url"]"
}
if {!([getuser $whoishandle XTRA "picurl"] == "")} {
notice $nick "\002 Picture URL\002: [getuser $whoishandle XTRA "picurl"]"
}
if {!([getuser $whoishandle XTRA "email"] == "")} {
notice $nick "\002 E-mail\002: [getuser $whoishandle XTRA "email"]"
}
if {!([getuser $whoishandle XTRA "other"] == "")} {
notice $nick "\002 Other info\002: [getuser $whoishandle XTRA "other"]"
}
set baduser ""
set bad ""
if {[matchattr $whoishandle k]} {append bad " Perm-banned"}
if {[matchattr $whoishandle d]} {append bad " Auto-deoped"}
if {[matchattr $whoishandle q]} {append bad " Auto-devoiced"}
if {$bad != ""} {
set baduser "("
append baduser $bad
append baduser " )"
}
notice $nick "\002 Global Flags\002: [chattr $whoishandle] $baduser"
set bad ""
if {[matchattr $whoishandle |k $chan]} {append bad " Perm-banned"}
if {[matchattr $whoishandle |d $chan]} {append bad " Auto-deoped"}
if {[matchattr $whoishandle |q $chan]} {append bad " Auto-devoiced"}
if {$bad != ""} {
set baduser "("
append baduser $bad
append baduser " )"
}
notice $nick "\002 Channel Level\002: $chanlevel $baduser"
set knownon ""
foreach a [channels] {
if {[matchattr $whoishandle |+d $a] || [matchattr $whoishandle |+f $a]} {
if {$a != $chan} {append knownon " " $a}
}
}
if {$knownon != ""} {notice $nick "\002 Also Known On\002:$knownon"}
# The space is intentionally missing.
notice $nick "\002 Known Hosts:\002 $hosts"
if {$info != ""} {
notice $nick "\002 Greet:\002 $info"
}
set onchans ""
for {set channum 0} {$channum < [llength [channels]]} {incr channum} {
set checkchan [lindex [channels] $channum]
if {[onchan $whoisnick $checkchan]} {
append onchans " " $checkchan
}
}
if {$idle != 0} {
notice $nick "\002 Idle time:\002 $idle minutes on $chan."
}
if {$onchans == ""} {
notice $nick "\002 Last seen:\002 $lastseentime"
notice $nick "\002 Where:\002 $lastseenwhere"
} else {
notice $nick "\002 Online at:\002 $onchans"
}
if {[checkbot $whoishandle]} {
notice $nick "\002 Bot:\002 $whoisnick is a bot."
} else {
if {[matchattr $whoishandle Z]} {
set e ""
if {[matchattr $whoishandle E]} {set e " (setting their email will auto-unsuspend)"}
notice $nick "\002 Suspended:\002 $whoisnick (Handle: $whoishandle) is suspended$e."
} else {
if {[matchattr $whoishandle a|a $chan]} {
notice $nick "\002 AutoOp:\002 AutoOp ON"
} else {
notice $nick "\002 AutoOp:\002 AutoOp OFF"
}
if {[matchattr $whoishandle L]} {
notice $nick "\002 Logged in:\002 $whoisnick is logged in as $whoishandle."
} else {
notice $nick "\002 Logged in:\002 $whoisnick is not logged in."
}
}
if {[matchattr $whoishandle +d $chan]} {
notice $nick "\002 Status:\002 shitlisted for bot abuse."
}
if {[matchattr $whoishandle p] && ![matchattr $whoishandle o|o $home]} {
notice $nick "\002 Status:\002 $whoisnick is a Guest User."
}
if {!([matchattr $whoishandle v] || [matchattr $whoishandle o]) && [matchattr $whoishandle |o $home]} {
notice $nick "\002 Status:\002 $whoisnick is a $homechanopname for $groupname."
}
if {[matchattr $whoishandle v] && ![matchattr $whoishandle o]} {
notice $nick "\002 Status:\002 $whoisnick is a $voicename for $groupname."
}
if {[matchattr $whoishandle Hl] && ![matchattr $whoishandle o]} {
notice $nick "\002 Status:\002 $whoisnick is a $halfopname for $groupname."
}
if {[matchattr $whoishandle o] && ![matchattr $whoishandle t]} {
notice $nick "\002 Status:\002 $whoisnick is a $opname for $groupname."
}
if {[matchattr $whoishandle t] && ![matchattr $whoishandle m]} {
notice $nick "\002 Status:\002 $whoisnick is a $techname for $groupname."
}
if {[matchattr $whoishandle m] && ![matchattr $whoishandle n]} {
notice $nick "\002 Status:\002 $whoisnick is a $mastername for $groupname."
}
if {[matchattr $whoishandle n]} {
notice $nick "\002 Status:\002 $whoisnick is an $ownername for $groupname."
}
}
return 0
}
### Access proc
set ctcp-version "StormBot.TCL $stormver by Xone & Domino (coders@stormbot.org)"
proc call_access {nick chan misc1} {
global botnick home groupname homechanopname voicename halfopname opname techname mastername ownername
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick access (#channel) <me | nick>"
return 0
}
if {[string tolower $misc1] == "me"} {
set acswho $nick
} else {
set acswho $misc1
}
if {[onchan $acswho $chan]} {
set acsnick $acswho
set acshandle [nick2hand $acswho $chan]
if {$acshandle == "" || $acshandle == "*"} {
notice $nick "\002$acswho\002 is \002NOT\002 a known user."
return 0
}
} elseif {[validuser $acswho]} {
set acsnick $acswho
set acshandle $acswho
} else {
notice $nick "\002$acswho\002 is \002NOT\002 a known user."
return 0
}
set chanlevel "No access"
if {[matchattr $acshandle |f $chan]} {
set chanlevel "Channel Friend (chanfriend)"
}
if {[matchattr $acshandle |v $chan]} {
set chanlevel "Channel Voice (chanvoice)"
}
if {[matchattr $acshandle |o $chan]} {
set chanlevel "Channel Op (chanop)"
}
if {[matchattr $acshandle |m $chan]} {
set chanlevel "Channel Master (chanmaster)"
}
if {[matchattr $acshandle |n $chan]} {
set chanlevel "Channel Owner (chanowner)"
}
notice $nick "\002 Access $acsnick \002"
notice $nick "\002 Handle:\002 $acshandle"
set baduser ""
set bad ""
if {[matchattr $acshandle k]} {append bad " Perm-banned"}
if {[matchattr $acshandle d]} {append bad " Auto-deoped"}
if {[matchattr $acshandle q]} {append bad " Auto-devoiced"}
if {$bad != ""} {
set baduser "("
append baduser $bad
append baduser " )"
}
notice $nick "\002 Global Flags\002: [chattr $acshandle] $baduser"
set bad ""
if {[matchattr $acshandle |k $chan]} {append bad " Perm-banned"}
if {[matchattr $acshandle |d $chan]} {append bad " Auto-deoped"}
if {[matchattr $acshandle |q $chan]} {append bad " Auto-devoiced"}
if {$bad != ""} {
set baduser "("
append baduser $bad
append baduser " )"
}
notice $nick "\002 Channel Level\002: $chanlevel $baduser"
if {[checkbot $acshandle]} {
notice $nick "\002 Bot:\002 $acsnick is a bot."
} else {
if {[matchattr $acshandle Z]} {
set e ""
if {[matchattr $acshandle E]} {set e " (setting their email will auto-unsuspend)"}
notice $nick "\002 Suspended:\002 $acsnick (Handle: $acshandle) is suspended$e."
} else {
if {[matchattr $acshandle a|a $chan]} {
notice $nick "\002 AutoOp:\002 AutoOp ON"
} else {
notice $nick "\002 AutoOp:\002 AutoOp OFF"
}
}
if {[matchattr $acshandle -pf|+d $chan]} {
notice $nick "\002 Status:\002 shitlisted for bot abuse."
}
if {[matchattr $acshandle p] && ![matchattr $acshandle o|o $home]} {
notice $nick "\002 Status:\002 $acsnick is a Guest User."
}
if {!([matchattr $acshandle v] || [matchattr $acshandle o]) && [matchattr $acshandle |o $home]} {
notice $nick "\002 Status:\002 $acsnick is a $homechanopname for $groupname."
}
if {[matchattr $acshandle v] && ![matchattr $acshandle o]} {
notice $nick "\002 Status:\002 $acsnick is a $voicename for $groupname."
}
if {[matchattr $acshandle Hl] && ![matchattr $acshandle o]} {
notice $nick "\002 Status:\002 $acsnick is a $halfopname for $groupname."
}
if {[matchattr $acshandle o] && ![matchattr $acshandle t]} {
notice $nick "\002 Status:\002 $acsnick is a $opname for $groupname."
}
if {[matchattr $acshandle t] && ![matchattr $acshandle m]} {
notice $nick "\002 Status:\002 $acsnick is a $opname for $groupname."
}
if {[matchattr $acshandle m] && ![matchattr $acshandle n]} {
notice $nick "\002 Status:\002 $acsnick is a $mastername for $groupname."
}
if {[matchattr $acshandle n]} {
notice $nick "\002 Status:\002 $acsnick is an $ownername for $groupname."
}
}
return 0
}
### Info proc
proc call_info {nick chan misc1 misc2} {
global botnick
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick info (#channel) <me | nick> <setting>"
notice $nick "Valid settings: name, sex, bday, location, occupation, url, email, other"
notice $nick "For more info, type: (/msg) $botnick help (#channel) info"
return 0
}
if {[string tolower $misc1] == "me"} {
set infowho $nick
} else {
set infowho $misc1
}
if {[onchan $infowho $chan]} {
set infonick $infowho
set infohandle [nick2hand $infonick $chan]
} else {
set infonick $infowho
set infohandle $infowho
}
if {[validuser $infohandle]} {
if {[string tolower $misc2] == "name"} {
if {[getuser $infohandle XTRA "name"] == ""} {
notice $nick "$infowho has no info on \"name\"."
return 0
}
notice $nick "$infowho\'s real name: [getuser $infohandle XTRA "name"]."
return 0
}
if {[string tolower $misc2] == "sex"} {
if {[getuser $infohandle XTRA "sex"] == ""} {
notice $nick "$infowho has no info on \"sex\"."
return 0
}
notice $nick "$infowho\'s sex: [getuser $infohandle XTRA "sex"]."
return 0
}
if {[string tolower $misc2] == "bday"} {
if {[getuser $infohandle XTRA "bday"] == ""} {
notice $nick "$infowho has no info on \"bday\"."
return 0
}
set sbday [getuser $infohandle XTRA "bday"]
if {[expr [lindex $sbday 0] == 1]} {
set month "January"
} elseif {[expr [lindex $sbday 0] == 2]} {
set month "Febuary"
} elseif {[expr [lindex $sbday 0] == 3]} {
set month "March"
} elseif {[expr [lindex $sbday 0] == 4]} {
set month "April"
} elseif {[expr [lindex $sbday 0] == 5]} {
set month "May"
} elseif {[expr [lindex $sbday 0] == 6]} {
set month "June"
} elseif {[expr [lindex $sbday 0] == 7]} {
set month "July"
} elseif {[expr [lindex $sbday 0] == 8]} {
set month "August"
} elseif {[expr [lindex $sbday 0] == 9]} {
set month "September"
} elseif {[expr [lindex $sbday 0] == 10]} {
set month "October"
} elseif {[expr [lindex $sbday 0] == 11]} {
set month "November"
} else {
set month "December"
}
notice $nick "$infowho\'s birthday: $month [lindex $sbday 1], [lindex $sbday 2]"
return 0
}
if {[string tolower $misc2] == "location"} {
if {[getuser $infohandle XTRA "location"] == ""} {
notice $nick "$infowho has no info on \"location\"."
return 0
}
notice $nick "$infowho\'s location: [getuser $infohandle XTRA "location"]."
return 0
}
if {[string tolower $misc2] == "occupation"} {
if {[getuser $infohandle XTRA "occupation"] == ""} {
notice $nick "$infowho has no info on \"occupation\"."
return 0
}
notice $nick "$infowho\'s occupation: [getuser $infohandle XTRA "occupation"]."
return 0
}
if {[string tolower $misc2] == "url"} {
if {[getuser $infohandle XTRA "url"] == ""} {
notice $nick "$infowho has no info on \"url\"."
return 0
}
notice $nick "$infowho\'s homepage: [getuser $infohandle XTRA "url"]."
return 0
}
if {([string tolower $misc2] == "picurl") || ([string tolower $misc2] == "pictureurl")} {
if {[getuser $infohandle XTRA "picurl"] == ""} {
notice $nick "$infowho has no info on \"picurl\"."
return 0
}
notice $nick "$infowho\'s picture URL: [getuser $infohandle XTRA "picurl"]."
return 0
}
if {([string tolower $misc2] == "email") || ([string tolower $misc2] == "e-mail")} {
if {[getuser $infohandle XTRA "email"] == ""} {
notice $nick "$infowho has no info on \"email\"."
return 0
}
notice $nick "$infowho\'s E-mail: [getuser $infohandle XTRA "email"]."
return 0
}
if {([string tolower $misc2] == "other")} {
if {[getuser $infohandle XTRA "email"] == ""} {
notice $nick "$infowho has no info on \"other\"."
return 0
}
notice $nick "$infowho\'s other information: [getuser $infohandle XTRA "other"]."
return 0
}
notice $nick "Usage: (/msg) $botnick info (#channel) <me | nick> <setting>"
notice $nick "Valid settings: name, sex, bday, location, occupation, url, email, other"
notice $nick "For more info, type: (/msg) $botnick help (#channel) info"
return 0
} else {
notice $nick "$infowho is not a valid user in my database."
return 0
}
}
### Levels proc
proc call_levels {nick handle} {
global botnick
if {[matchattr $handle f]} {
notice $nick "\002 Global Access Levels \002"
notice $nick " "
notice $nick "\002 full:\002 Full Access User. Global flags: fhjmnoptx"
notice $nick "\002 owner:\002 Global Owner. Global flags: fhmnopx"
notice $nick "\002 master:\002 Global Master. Global flags: fhmopx"
notice $nick "\002 tech:\002 Global Tech. Global flags: fhtopx"
notice $nick "\002 op:\002 Global Op. Global flags: fhopx"
notice $nick "\002 voice:\002 Global Voice. Global flags: fhvpx"
notice $nick " "
}
notice $nick "\002 Channel Access Levels \002"
notice $nick " "
notice $nick "\002 chanowner:\002 Channel Owner. Global flags: hpx. Channel Flags: fmno"
notice $nick "\002 chanmaster:\002 Channel Master. Global flags: hpx. Channel Flags: fmo"
notice $nick "\002 chanop:\002 Channel Op. Global flags: hpx. Channel Flags: fo"
notice $nick "\002 chanvoice:\002 Channel Voice. Global flags: hpx. Channel Flags: fv"
notice $nick " "
notice $nick " See also: $botnick flags"
}
### Flags proc
proc call_flags {nick misc1} {
global botnick
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick flags <channel | global>"
return 0
}
if {[string tolower $misc1] == "global"} {
notice $nick "\002 Global Flags \002"
notice $nick " "
notice $nick "\002 o\002 global op (bot will op this user on any channel)"
notice $nick "\002 m\002 global master (user is a bot master)"
notice $nick "\002 n\002 global owner (user is the bot owner)"
notice $nick "\002 t\002 botnet master (user is a botnet master)"
notice $nick "\002 x\002 xfer (user has file-area access)"
notice $nick "\002 j\002 janitor (user is a file-area master)"
notice $nick "\002 p\002 party-line (user has party-line access)"
notice $nick "\002 c\002 common (user record is a common-access site)"
notice $nick "\002 u\002 unshared (not sent to other share-bots)"
notice $nick "\002 b\002 bot (user is another bot)"
notice $nick "\002 d\002 global deop (user cannot get ops)"
notice $nick "\002 k\002 global auto-kick (user kick & banned automatically)"
notice $nick "\002 f\002 global friend"
notice $nick "\002 v\002 global voice (user get +v automatically on +autovoice channels)"
notice $nick "\002 a\002 global auto-op (always op this user on join)"
notice $nick "\002 h\002 high-light flag (user sees highlighting in text output)"
notice $nick " "
notice $nick "\002 «•» Special Global Flags «•» \002"
notice $nick " "
notice $nick "\002 L\002 Logged in (the user is logged in to the bot)"
notice $nick "\002 Z\002 Suspended (the user is globally suspended to the bot)"
return 0
}
if {[string tolower $misc1] == "channel"} {
notice $nick "\002 Channel Flags \002"
notice $nick " "
notice $nick "\002 m\002 master (user is a master for the channel) "
notice $nick "\002 n\002 owner (user is an owner for the channel) "
notice $nick "\002 o\002 op (bot will give this user chanop)"
notice $nick "\002 d\002 deop (bot will not allow this user to become a chanop)"
notice $nick "\002 f\002 friend (user is not punished for doing bad things)"
notice $nick "\002 k\002 kick (user is auto-kicked)"
notice $nick "\002 v\002 voice (user get +v automatically on channel)"
notice $nick "\002 q\002 quiet (user never gets +v on channel)"
notice $nick "\002 a\002 auto-op (always op this user on join)"
return 0
}
notice $nick "Usage: (/msg) $botnick flags <channel | global>"
}
### Bantype proc
proc call_bantype {nick} {
notice $nick "\002 Ban Types \002"
notice $nick " "
notice $nick "\002 B1\002: 1 hour"
notice $nick "\002 B2\002: 6 hours"
notice $nick "\002 B3\002: 24 hours"
notice $nick "\002 B4\002: 3 days"
notice $nick "\002 B5\002: 7 days"
notice $nick "\002 B6\002: 30 days"
notice $nick "\002 B7\002: 3 months"
notice $nick "\002 B8\002: 6 months"
notice $nick "\002 B9\002: 1 year"
notice $nick "\002 perm\002: Perm Ban"
}
### Banlist proc
proc call_banlist {nick chan misc1 misc2} {
if {([banlist $chan] == "") && ([chanbans $chan] == "")} {
notice $nick "\002 There are no channel bans on $chan \002"
return 0
}
set accept [string tolower "global all chan channel active"]
set misc2 [string tolower $misc2]
if {[lsearch -glob $accept $misc1] != -1} {
set a $misc1
set misc1 $misc2
set misc2 $a
}
# Swap $misc1 and $misc2 if "global/all/etc" is in the 1st position
# Allows for "BOT BANLIST CHAN" to list all chanbans (presumed * for mask)
# Then, process as normal
if {$misc1 == ""} {set misc1 "*"}
if {$misc2 == ""} {
set misc2 "chan"
} else {
if {[lsearch -glob $accept $misc2] == -1} {
notice $nick "$misc2 isn't an acceptable value. Choices are: $accept."
return 0
}
}
if {($misc2 == "") || ($misc2 == "all") || ($misc2 == "chan") || ($misc2 == "channel")} {
if {!([banlist $chan] == "")} {
notice $nick "\002 Current bans on $chan (placed by bot) \002"
set a 0
foreach ban [banlist $chan] {
set banmask [lindex $ban 0]
if {[string match [string tolower $misc1] [string tolower $banmask]]} {
set bancomment [lindex $ban 1]
set banexpire [lindex $ban 2]
set banadded [lindex $ban 3]
set banlastused [lindex $ban 4]
set bancreator [lindex $ban 5]
set banexpire_ctime [ctime $banexpire]
set banadded_ctime [ctime $banadded]
set banlastused_ctime [ctime $banlastused]
if {$banexpire == "0"} {
set banexpire_ctime "perm ban"
}
if {$banlastused == "0"} {
set banlastused_ctime "never used"
}
notice $nick " "
notice $nick "Mask: $banmask Banned by: $bancreator."
notice $nick "Reason: $bancomment"
notice $nick "Created: $banadded_ctime. Banned until: $banexpire_ctime. "
notice $nick "Last Active: $banlastused_ctime."
incr a
}
}
if {($a == 0) && ($misc1 != "*")} {notice $nick "No bans found matching $misc1"}
notice $nick " "
}
}
if {($misc2 == "all") || ($misc2 == "active")} {
if {[chanbans $chan] != ""} {
notice $nick "\002 Active bans on $chan \002"
set a 0
foreach ban [chanbans $chan] {
set banmask [lindex $ban 0]
if {[string match [string tolower $misc1] [string tolower $banmask]]} {
set bancreator [lindex $ban 1]
notice $nick " "
notice $nick "Mask: $banmask Banned by: $bancreator."
incr a
}
}
if {($a == 0) && ($misc1 != "*")} {notice $nick "No active channel bans found matching $misc1"}
notice $nick " "
}
}
if {[banlist] == ""} {
notice $nick "\002 There are no global bans \002"
} else {
if {($misc2 == "all") || ($misc2 == "global")} {
notice $nick "\002 Current global bans (can only be removed by global ops) \002"
set a 0
foreach ban [banlist] {
set banmask [lindex $ban 0]
if {[string match [string tolower $misc1] [string tolower $banmask]]} {
set bancomment [lindex $ban 1]
set banexpire [lindex $ban 2]
set banadded [lindex $ban 3]
set banlastused [lindex $ban 4]
set bancreator [lindex $ban 5]
set banexpire_ctime [ctime $banexpire]
set banadded_ctime [ctime $banadded]
set banlastused_ctime [ctime $banlastused]
if {$banexpire == "0"} {
set banexpire_ctime "perm ban"
}
if {$banlastused == "0"} {
set banlastused_ctime "never used"
}
notice $nick " "
notice $nick "Mask: $banmask Banned by: $bancreator."
notice $nick "Reason: $bancomment"
notice $nick "Created: $banadded_ctime. Banned until: $banexpire_ctime. "
notice $nick "Last Active: $banlastused_ctime."
incr a
}
}
if {($a == 0) && ($misc1 != "*")} {notice $nick "No global bans found matching $misc1"}
}
}
notice $nick " "
notice $nick " End of banlist."
return 0
}
### Ignorelist proc
proc call_ignorelist {nick} {
if {[ignorelist] == ""} {
notice $nick "\002 There are no ignores \002"
} else {
notice $nick "\002 Current ignores (can only be removed by global ops) \002"
foreach ignore [ignorelist] {
set ignoremask [lindex $ignore 0]
set ignorecomment [lindex $ignore 1]
set ignoreexpire [lindex $ignore 2]
set ignoreadded [lindex $ignore 3]
set ignorecreator [lindex $ignore 4]
set ignoreexpire_ctime [ctime $ignoreexpire]
set ignoreadded_ctime [ctime $ignoreadded]
if {$ignoreexpire == 0} {
set ignoreexpire_ctime "perm"
}
notice $nick " "
notice $nick "Mask: $ignoremask Ignore by: $ignorecreator."
notice $nick "Reason: $ignorecomment"
notice $nick "Created: $ignoreadded_ctime. Ignore until: $ignoreexpire_ctime. "
}
}
}
### Userlist proc
proc call_userlist {nick chan} {
msg $nick "\002 Userlist for $chan \002"
foreach user [userlist |f $chan] {
set chanaccess "Channel Guest"
if {[matchattr $user |v $chan]} {
set chanaccess "Channel Voice (chanvoice)"
}
if {[matchattr $user |o $chan]} {
set chanaccess "Channel Op (chanop)"
}
if {[matchattr $user |m $chan]} {
set chanaccess "Channel Master (chanmaster)"
}
if {[matchattr $user |n $chan]} {
set chanaccess "Channel Owner (chanowner)"
}
set info [getuser $user info]
set hosts [getuser $user hosts]
set email [getuser $user XTRA "email"]
msg $nick " "
msg $nick "Handle: $user. Global flags: [chattr $user]"
if {$info != ""} {msg $nick "Greet: $info"}
if {$email != ""} {msg $nick "E-mail: $email"}
msg $nick "Hosts: $hosts"
msg $nick "Channel Access: $chanaccess"
}
msg $nick " "
msg $nick "End of $chan's userlist."
}
### Voice proc
proc call_voice {nick handle chan misc1 misc1end} {
global botnick
if {$misc1 == ""} {set misc1 $nick}
set vnicks $misc1end
if {![botisop $chan]} {
notice $nick "\002 I am not currently opped in $chan \002"
return 0
}
if {[string tolower [lindex $vnicks 0]] == "me"} {
putquick "MODE $chan +v $nick"
return 0
}
if {![matchattr $handle o|o $chan]} {
notice $nick "Negative on that, Houston. You can only voice yourself: $botnick voice (#channel) me"
return 0
}
foreach vnick $vnicks {
if {![onchan $vnick $chan]} {
notice $nick "$vnick is not on $chan."
} else {
if {[isvoice $vnick $chan]} {
notice $nick "$vnick already has voice."
} else {
pushmode $chan +v $vnick
}
}
}
flushmode $chan
}
### Devoice proc
proc call_devoice {nick handle chan misc1 misc1end} {
global botnick
if {$misc1 == ""} {set misc1 $nick}
set dvnicks $misc1end
if {![botisop $chan]} {
notice $nick "\002 I am not currently opped in $chan \002"
return 0
}
if {[string tolower [lindex $dvnicks 0]] == "me"} {
putquick "MODE $chan -v $nick"
return 0
}
if {![matchattr $handle o|o $chan]} {
notice $nick "Negative on that, Houston. You can only devoice yourself: $botnick devoice ($chan) me"
return 0
}
foreach dvnick $dvnicks {
if {![onchan $dvnick $chan]} {
notice $nick "$dvnick is not on $chan."
} else {
if {![isvoice $dvnick $chan]} {
notice $nick "$dvnick don't got voice."
} else {
pushmode $chan -v $dvnick
}
}
}
flushmode $chan
}
### Greet proc
proc call_greet {nick handle chan misc1 misc1end} {
global botnick
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick greet (#channel) <greet>"
notice $nick "Clear your greet: (/msg) $botnick greet (#channel) none"
return 0
}
if {[string tolower $misc1end] == "none"} {
setchaninfo $handle $chan ""
notice $nick "Removed your greet for $chan."
return 0
}
setchaninfo $handle $chan $misc1end
notice $nick "Your greet for $chan: $misc1end"
}
### Set proc
proc call_set {nick handle misc1 misc2 misc2end} {
global botnick home special
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick set <setting> <text>"
notice $nick "Clear your settings: (/msg) $botnick set <setting> none"
notice $nick "For more info, type: (/msg) $botnick help (#channel) set"
return 0
}
if {[string tolower $misc1] == "name"} {
if {[string tolower $misc2] == ""} {
notice $nick "Usage: (/msg) $botnick set name <your name>"
return 0
}
if {[string tolower $misc2] == "none"} {
setuser $handle XTRA "name" ""
notice $nick "Removed your \"Real name\"."
return 0
}
setuser $handle XTRA "name" $misc2end
notice $nick "Your \"Real name\" is: $misc2end"
return 0
}
if {[string tolower $misc1] == "sex"} {
if {[string tolower $misc2] == "none"} {
setuser $handle XTRA "sex" ""
notice $nick "Removed your \"Sex\"."
return 0
}
if {([string tolower $misc2] == "m") || ([string tolower $misc2] == "male")} {
setuser $handle XTRA "sex" "Male"
notice $nick "Your \"Sex\" is: Male"
return 0
}
if {([string tolower $misc2] == "f") || ([string tolower $misc2] == "female")} {
setuser $handle XTRA "sex" "Female"
notice $nick "Your \"Sex\" is: Female"
return 0
}
notice $nick "Usage: (/msg) $botnick set sex <\"male\" or \"female\">"
return 0
}
if {[string tolower $misc1] == "bday"} {
if {[string tolower $misc2] == ""} {
notice $nick "Usage: (/msg) $botnick set bday <MM/DD/YYYY>"
return 0
}
if {[string tolower $misc2] == "none"} {
setuser $handle XTRA "bday" ""
notice $nick "Removed your \"Birthday\"."
return 0
}
if {![string match "\[0-9\]\[0-9\]\/\[0-9\]\[0-9\]\/\[0-9\]\[0-9\]\[0-9\]\[0-9\]" $misc2]} {
notice $nick "Usage: (/msg) $botnick set bday <MM/DD/YYYY>"
return 0
}
set sbday [split $misc2 "/"]
if {[expr [nozero [lindex $sbday 0]] > 12] || [expr [nozero [lindex $sbday 0]] == 0]} {
notice $nick "We only have 12 months in a year, ace :>"
return 0
}
if {[expr [nozero [lindex $sbday 1]] > 31] || [expr [nozero [lindex $sbday 1]] == 0]} {
notice $nick "We only have up to 31 days in a month, ace :>"
return 0
}
if {[expr [lindex $sbday 2] < 1850]} {
notice $nick "You're not \002that\002 old!"
return 0
}
if {[expr [lindex $sbday 2] > [lindex [currdate] 2]]} {
notice $nick "Don't think that you are from the future, Einstein :>"
return 0
}
setuser $handle XTRA "bday" $sbday
notice $nick "Your \"Birthday\" is: $misc2end"
return 0
}
if {[string tolower $misc1] == "location"} {
if {[string tolower $misc2] == ""} {
notice $nick "Usage: (/msg) $botnick set location <your location>"
return 0
}
if {[string tolower $misc2] == "none"} {
setuser $handle XTRA "location" ""
notice $nick "Removed your \"Location\"."
return 0
}
setuser $handle XTRA "location" $misc2end
notice $nick "Your \"Location\" is: $misc2end"
return 0
}
if {[string tolower $misc1] == "occupation"} {
if {[string tolower $misc2] == ""} {
notice $nick "Usage: (/msg) $botnick set occupation <your occupation>"
return 0
}
if {[string tolower $misc2] == "none"} {
setuser $handle XTRA "occupation" ""
notice $nick "Removed your \"Occupation\"."
return 0
}
setuser $handle XTRA "occupation" $misc2end
notice $nick "Your \"Occupation\" is: $misc2end"
return 0
}
if {[string tolower $misc1] == "url"} {
if {[string tolower $misc2] == ""} {
notice $nick "Usage: (/msg) $botnick set url <http://www.isp.come/homepage/>"
return 0
}
if {[string tolower $misc2] == "none"} {
setuser $handle XTRA "url" ""
notice $nick "Removed your \"Homepage\"."
return 0
}
if {![string match "http://*" $misc2]} {
notice $nick "Usage: (/msg) $botnick set url <http://www.isp.come/homepage/>"
return 0
}
setuser $handle XTRA "url" $misc2
notice $nick "Your \"Homepage\" is: $misc2"
return 0
}
if {([string tolower $misc1] == "picurl") || ([string tolower $misc1] == "pictureurl")} {
if {[string tolower $misc2] == ""} {
notice $nick "Usage: (/msg) $botnick set picurl <http://www.isp.come/homepage/mypic.gif>"
notice $nick "Please note: the picture file must be a .gif or .jpg/.jpeg file."
return 0
}
if {[string tolower $misc2] == "none"} {
setuser $handle XTRA "picurl" ""
notice $nick "Removed your \"Picture URL\"."
return 0
}
if {[string match "http://*.gif" $misc2] || [string match "http://*.jpg" $misc2] || [string match "http://*.jpeg" $misc2] } {
setuser $handle XTRA "picurl" $misc2
notice $nick "Your \"Picture URL\" is: $misc2"
return 0
}
notice $nick "Usage: (/msg) $botnick set picurl <http://www.isp.come/homepage/mypic.gif>"
notice $nick "Please note: the picture file must be in .gif or .jpg/.jpeg format."
return 0
}
if {([string tolower $misc1] == "email") || ([string tolower $misc1] == "e-mail")} {
if {[string tolower $misc2] == ""} {
notice $nick "Usage: (/msg) $botnick set email <your@email.com>"
return 0
}
if {[string tolower $misc2] == "none"} {
setuser $handle XTRA "email" ""
notice $nick "Removed your \"E-mail\"."
return 0
}
if {![string match "*@*.*" $misc2]} {
notice $nick "Usage: (/msg) $botnick set email <your@email.com>"
return 0
}
setuser $handle XTRA "email" $misc2
notice $nick "Your \"E-mail\" is: $misc2"
return 0
}
if {[string tolower $misc1] == "other"} {
if {[string tolower $misc2] == ""} {
notice $nick "Usage: (/msg) $botnick set other <other information>"
return 0
}
if {[string tolower $misc2] == "none"} {
setuser $handle XTRA "other" ""
notice $nick "Removed your \"Other information\"."
return 0
}
setuser $handle XTRA "other" $misc2end
notice $nick "Your \"Other information\" is: $misc2end"
return 0
}
notice $nick "Usage: (/msg) $botnick set <setting> <text>"
notice $nick "Valid settings: name, sex, bday, location, occupation, url, email, other"
notice $nick "For more info, type: (/msg) $botnick help (#channel) set"
return 0
}
### Who proc
proc call_who {nick handle chan} {
global groupname voicename halfopname opname mastername ownername botnick modeenable
set users 0
set none 0; set nonelist ""
set bots 0; set botslist ""
set ops 0; set opslist ""
set half 0; set halfopslist ""
set voices 0; set voiceslist ""
output $nick $handle $chan "\002Current users on $chan\002"
output $nick $handle $chan " "
foreach user [chanlist $chan] {
incr users
set desc ""
set status ""
set userhandle [nick2hand $user $chan]
set handout ""
if {$userhandle != ""} {
if {[stl $userhandle] != [stl $user]} {set handout " ($userhandle)"}
if {[matchattr $userhandle b]} {set handout " (\037bot\037)"; incr bots}
if {$user == $botnick} {set handout " (\037ME!\037)"}
if {[matchattr $userhandle &n $chan]} {set user "\002$user\002"; #set handout " \002($userhandle)\002"}
}
if {[isop $user $chan]} {lappend opslist "@$user$handout"; incr ops
} elseif {[ishalfop $user $chan]} {lappend halfopslist "%$user$handout"; incr half
} elseif {[isvoice $user $chan]} {lappend voiceslist "+$user$handout"; incr voices
} else {lappend nonelist "$user"; incr none
}
# ELSEIF is required to take care of users with multiple modes [i.e.:
# voiced AND opped, or half-opped or voiced].
}
set list "{\002Ops:\002 $opslist}"; if {($modeenable(h))} {lappend list " {\002Half-ops:\002 $halfopslist}"}
append list " {\002Voices:\002 $voiceslist} {\002Others:\002 $nonelist}"
foreach sortlist $list {
set sort [lsort -increasing $sortlist]
if {[llength $sort] != 1} {
while {$sort != ""} {
set temp [lrange $sort 0 24]
set b ""
if {[string index $temp 0] == "\002"} {set b [join [lrange $temp 0 1]]; set temp [lrange $temp 2 end]}
foreach a $temp {lappend b $a}
set b [join $b ", "]
output $nick $handle $chan "$b"
set sort [lrange $sort 25 end]
}
}
}
output $nick $handle $chan " "
output $nick $handle $chan "\002Users in $chan: $users ($bots bots). Ops: $ops. Half-Ops: $half. Voices: $voices. \002"
}
### Topic proc
proc call_topic {nick chan misc1end} {
global botnick
if {$misc1end == ""} {
notice $nick "Usage: (/msg) $botnick topic (#channel) <topic>"
notice $nick "Unset topic: (/msg) $botnick topic (#channel) none"
return 0
}
set topic $misc1end
if {![botisop $chan]} {
notice $nick "\002 I am not currently opped in $chan \002"
return 0
}
if {[string tolower $topic] == "none"} {
set topic ""
putquick "TOPIC $chan :$topic"
return 0
}
putquick "TOPIC $chan :$topic"
}
### Mode proc
proc call_mode {nick chan misc1end} {
global botnick
if {$misc1end == ""} {
notice $nick "Usage: (/msg) $botnick MODE (#channel) <+/- i|n|t|m|p|s|k key|l limit>"
return 0
}
if {![botisop $chan]} {
notice $nick "\002 I am not currently opped in $chan \002"
return 0
}
putquick "MODE $chan $misc1end"
}
### Op proc
proc call_op {nick chan misc1 misc1end} {
global botnick
if {$misc1 == ""} {set misc1 "me"}
if {![botisop $chan]} {notice $nick "\002 «•» Status: I am not currently opped in $chan «•» \002"; return 0}
if {[string tolower $misc1] == "me"} {putquick "MODE $chan +o $nick"; return 0}
foreach onick $misc1end {
if {[isop $onick $chan]} {notice $nick "$onick is already opped."
} else {
if {[onchan $onick $chan]} {pushmode $chan +o $onick
} else {notice $nick "$onick is not on $chan."}
}
}
flushmode $chan
}
# Deop proc
proc call_deop {nick handle chan misc1 misc1end} {
global botnick
if {$misc1 == ""} {set misc1 "me"}
if {![botisop $chan]} {
notice $nick "\002 I am not currently opped in $chan \002"
return 0
}
if {[string tolower $misc1] == "me"} {
putquick "MODE $chan -o $nick"
return 0
}
if {[string tolower $misc1] == [string tolower $nick]} {
putquick "MODE $chan -o $nick"
return 0
}
if {[string tolower $misc1] == [string tolower $botnick]} {
notice $nick "I don't think deoping myself is such a good idea."
return 0
}
foreach donick $misc1end {
if {[onchan $donick $chan]} {
if {[isop $donick $chan]} {
set dohandle [nick2hand $donick $chan]
if {[checkbot $dohandle]} {
notice $nick "Don't deop $donick - it's a bot!"
} else {
if {[checkaccess $handle $chan $dohandle]} {
pushmode $chan -o $donick
} else {
notice $nick "You don't have enough access to deop $donick"
return 0
}
}
} else {
notice $nick "$donick is not opped."
}
} else {
notice $nick "$donick is not on $chan"
}
}
flushmode $chan
}
### Kick proc
proc call_kick {nick handle chan misc1 misc2end} {
global botnick
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick kick (#channel) <me | nick> <reason>"
return 0
}
if {![botisop $chan]} {
notice $nick "\002 I am not currently opped in $chan \002"
return 0
}
if {$misc1 == $botnick} {
notice $nick "I don't think kicking myself is such a good idea."
return 0
}
if {[string tolower $misc1] == "me"} {
if {$misc2end == ""} {
putquick "KICK $chan $nick :Okay dokay... you're out :P"
return 0
}
putquick "KICK $chan $nick :$misc2end"
return 0
}
if {[string tolower $misc1] == [string tolower $nick]} {
if {$misc2end == ""} {
putquick "KICK $chan $nick :Okay dokay... you're out :P"
return 0
}
putquick "KICK $chan $nick :$misc2end"
return 0
}
if {[onchan $misc1 $chan]} {
set kickhandle [nick2hand $misc1 $chan]
if {[checkbot $kickhandle]} {
notice $nick "Don't kick $misc1 - it's a bot!"
return 0
}
if {[checkaccess $handle $chan $kickhandle]} {
if {$misc2end == ""} {
putquick "KICK $chan $misc1 :Kicked: request"
return 0
}
putquick "KICK $chan $misc1 :$misc2end"
return 0
}
notice $nick "You don't have enough access to kick $misc1"
return 0
}
notice $nick "$misc1 is not on $chan"
}
### Ban proc
proc call_ban {nick handle chan misc1 misc2 misc2end misc3end} {
global home botnick
if {$misc1 == ""} {notice $nick "Usage: (/msg) $botnick ban (#channel) <nick | user@host> (B1 ... B9 | perm | # of minutes) <reason>. See also : (/msg) $botnick bantype"; return 0}
if {![botisop $chan]} {notice $nick "\002 Status: I am not currently opped in $chan \002"}
# "return 0" was snuffed so the bot will still SET the ban [in case the bot will be reopped later on.
if {[string tolower $misc1] == "me" || [string tolower $misc1] == [string tolower $handle]} {notice $nick "I don't think banning you is such a good idea."; return 0}
if {[string tolower $misc1] == [string tolower $botnick]} {notice $nick "I don't think banning myself is such a good idea."; return 0}
global home botnick strict-host botname version ban-time
set defaultbantime 120
if {[info exists ban-time]} {set defaultbantime ${ban-time}}
if {[lindex $version 1] >= 1061300} {set defaultbantime [channel get $chan ban-time]}
set bantime $defaultbantime
set bantimeword "(Default) 2 hours"; set banreason $misc2end
switch -glob -- [string tolower $misc2] {
perm {set bantime 0; set bantimeword "Perm Ban"; set banreason $misc3end}
b1 {set bantime 60; set bantimeword "(B1) 1 hour"; set banreason $misc3end}
b2 {set bantime 360; set bantimeword "(B2) 6 hours"; set banreason $misc3end}
b3 {set bantime 1440; set bantimeword "(B3) 24 hours"; set banreason $misc3end}
b4 {set bantime 4320;set bantimeword "(B4) 3 days";set banreason $misc3end}
b5 {set bantime 10080; set bantimeword "(B5) 7 days"; set banreason $misc3end}
b6 {set bantime 43200; set bantimeword "(B6) 30 days"; set banreason $misc3end}
b7 {set bantime 129600; set bantimeword "(B7) 3 months"; set banreason $misc3end}
b8 {set bantime 259200; set bantimeword "(B8) 6 months"; set banreason $misc3end}
b9 {set bantime 525600; set bantimeword "(B9) 1 year"; set banreason $misc3end}
}
if {$misc2 != ""} {
if {[string is integer $misc2]} {
if {$misc2 > "9999999"} {set misc2 "9999999"}; # Ceiling
set bantime $misc2; set bantimeword "$misc2 minutes"; set banreason $misc3end
# Values above $7FFF FFFF will FAIL since they are negative-signed integers
# [above 2,147,483,647 minutes]. But, who the hell needs a 68 year ban?????
}
}
# Checking for *!*@* [or alike] bans; this searches for the existance of any NON-"?!@*" character.
set c 0; foreach i [split $misc1 ""] { if {[string first $i "*?!@"] < 0} {incr c} }
if {$c == 0} {
if {[matchattr $handle o] || [matchattr $handle &n $chan]} {
msg $home "Lock-down ban being executed in $chan by $nick ($handle)."
# Allow "global" users to do *!*@* bans (channel recovery).
} else {
msg $home "Failed lock-down ban attempt by $nick ($handle) in $chan: $misc1"
notice $nick "Dumdidej! You can't set lock-down bans like that!"
return 0
}
}
set banhost $misc1
if {[onchan $misc1 $chan]} {
set q [nick2hand $misc1 $chan]
if {![checkaccess $handle $chan $q]} {notice $nick "You can't ban $misc1 (it's really $q)!"; return 0}
if {[checkbot $q]} {notice $nick "Don't ban $misc1 ($q) - it's a bot!"; return 0}
set bh [getchanhost $misc1 $chan]
if {[string index $bh 0] == "~"} {set bh "[string range $bh 1 end]"}
set banhost [maskhost "*$bh"]
} else {
set checkhandle [finduser $banhost]
if {[checkbot $checkhandle]} {notice $nick "Don't ban $misc1 ($checkhandle) - it's a bot!"; return 0}
if {![checkaccess $handle $chan $checkhandle]} {notice $nick "You don't have enough access to ban $misc1 (it is $checkhandle)"; return 0}
}
if {![string match "*@*" $banhost]} {notice $nick "Illogical ban being placed: $banhost. Ban off-channel nicks as: NICK!*@*"; return 0}
set newbanreason "\002($bantimeword)\002 request"
putquick "mode $chan +b $banhost" -next
if {$banreason != ""} {set newbanreason "\002($bantimeword)\002 $banreason"}
if {[onchan $misc1 $chan]} {putquick "KICK $chan $misc1 :$newbanreason" -next}
set banreason [join $banreason]
set newbanreason [join $newbanreason]
newchanban $chan $banhost $nick $newbanreason $bantime
if {$misc1 != $banhost} {set misc1 "$misc1 ($banhost)"}
set data "Added ban for $misc1 in $chan for: $newbanreason"
notice $nick $data; msg $home "$data ($nick)"
if {[string index $banreason 0] == "*"} {stick $banhost $chan}
return 0
}
### Unban proc
proc call_unban {nick handle chan misc1} {
global botnick
set a 0
set unbanned ""
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick unban (#channel) <user@host>"
return 0
}
if {![botisop $chan]} {
notice $nick "\002 I am not currently opped in $chan \002"
#return 0
}
# Snuffed so the bot will still UNSET the ban [in case the bot will be
# reopped soon.
set misc $misc1
foreach misc1 [banlist] {
set misc1 [lindex $misc1 0]
if {![string match [string tolower $misc] [string tolower $misc1]]} {continue}
if {[isban $misc1]} {
if {[matchattr $handle o]} {
if {[lsearch -glob $unbanned $misc1] == -1} {
append unbanned " $misc1"
killban $misc1
foreach a [channels] {
putquick "mode $chan -b $misc1"
}
notice $nick "$misc1 has successfully been unbanned."
}
set a 1
continue
} else {
notice $nick "$misc1 is a global ban, and you don't have enough access to remove a global ban."
continue
}
}
}
foreach misc1 [banlist $chan] {
set misc1 [lindex $misc1 0]
if {![string match [string tolower $misc] [string tolower $misc1]]} {continue}
if {[isban $misc1 $chan]} {
append unbanned " $misc1"
killchanban $chan $misc1
putquick "mode $chan -b $misc1"
notice $nick "$misc1 has successfully been unbanned."
set a 1
continue
}
}
foreach misc1 [chanbans $chan] {
set misc1 [lindex $misc1 0]
if {![string match [string tolower $misc] [string tolower $misc1]]} {continue}
if {([lsearch -glob $unbanned $misc1] == -1) || ($unbanned == "")} {
append unbanned " $misc1"
putquick "MODE $chan -b $misc1"
notice $nick "$misc1 was not placed by bot, but has successfully been unbanned."
set a 1
continue
}
}
if {$a == 0} {notice $nick "$misc is not a ban in $chan."}
}
### Wallops proc
proc call_wallops {nick chan misc1end} {
global botnick cserv chanwall
if {[info exists chanwall]} {
putquick "$chanwall $chan :\[\037from $nick\037\]: $misc1end"
} else {
foreach user [chanlist $chan] {
if {([isop $user $chan]) && ($user != $botnick) && ([nick2hand $user $chan] != $cserv)} {
notice $user "\002CHANWALL\002 (\037$nick@$chan\037): $misc1end"
}
}
}
}
### onjoin proc
# ONJOIN bind follows routine
proc call_onjoin {nick chan misc1 misc2 misc2end misc3end} {
# NOTE: ADD and CLEAR portions =follow= DELETE and INSERT for a reason!
global botnick groupname mastername ownername home bnick owner
set chan [string tolower $chan]
set fall 0
if {$misc1 == ""} {
notice $nick "And what would you like me to do with $chan's onjoin?"
notice $nick "Usage: (/msg) $botnick onjoin (#channel) <clear | add | edit # | show | scan> (text)"
return 0
}
if {[onjoin_account $chan] != 1} {
putlog "Problem creating/validating $botnick's internal STORMBOT account."
return 0
}
set index [getuser $bnick XTRA "onjoin-index-$chan"]
if {$index == ""} {set index 0}
# Adjust to make "clear #" delete [and shuffle] individual lines
if {$misc1 == "delete"} {set misc1 "del"}
if {$misc1 == "del" } {
if {$index == 0} {
notice $nick "There're no lines to delete\; the onjoin is blank."
return 0
}
if {($misc2 > $index) || ($misc2 < 1)} {
notice $nick "You want me to delete lines that don't exist? Baka!"
return 0
}
if {$index == 1} {
set misc1 "clear"
# Allow DEL for one-line ONJOIN to fall-through to CLEAR
} else {
incr index -1
for {set i $misc2} {$i <= $index} {incr i} {
set a [expr $i + 1]
setuser $bnick XTRA "onjoin-$chan-$i" [getuser $bnick XTRA "onjoin-$chan-$a"]
}
setuser $bnick XTRA "onjoin-index-$chan" "$index"
notice $nick "Line $misc2 deleted."
return 0
}
}
if {$misc1 == "ins"} {set misc1 "insert"}
if {$misc1 == "insert"} {
if {($index == 0) || ($misc2 > $index)} {
set misc1 "add"
set misc2end $misc3end
} else {
if {$misc2 < 1} {
notice $nick "You want me to insert lines into the void? Baka!"
return 0
}
if {$index >= 5} {
notice $nick "I'm already holding the maximum numbers of lines. Insert aborted."
return 0
}
incr index
for {set i $index} {$i > $misc2} {incr i -1} {
set a [expr $i - 1]
setuser $bnick XTRA "onjoin-$chan-$i" [getuser $bnick XTRA "onjoin-$chan-$a"]
}
setuser $bnick XTRA "onjoin-$chan-$misc2" "$misc3end"
setuser $bnick XTRA "onjoin-index-$chan" "$index"
notice $nick "Line $misc2 added: $misc3end"
return 0
}
}
if {$misc1 == "clear"} {
setuser $bnick XTRA "onjoin-index-$chan" ""
notice $nick "Onjoin for $chan cleared."
return 0
}
if {$misc1 == "add"} {
if {$index >= 5} {
notice $nick "You have the maximum number of lines for that channel already."
return 0
}
set index "[expr $index + 1]"
setuser $bnick XTRA "onjoin-$chan-$index" "$misc2end"
setuser $bnick XTRA "onjoin-index-$chan" "$index"
notice $nick "Line $index added: $misc2end"
return 0
}
if {$misc1 == "edit"} {
if {$misc2 < 1 || $misc2 > 5 || $misc2 > $index} {
notice $nick "Illegal value: $misc2."
return 0
}
setuser $bnick XTRA "onjoin-$chan-$misc2" "$misc3end"
notice $nick "Line $misc2 altered to: $misc3end"
return 0
}
if {$misc1 == "show"} {
set index [getuser $bnick XTRA "onjoin-index-$chan"]
if {$index == 0 || $index == ""} {
notice $nick "There is no onjoin set for $chan."
return 0
}
notice $nick "Onjoin for $chan:"
for {set onj 1} {$onj < [expr $index + 1]} {incr onj} {
notice $nick "Line $onj/$index: [getuser $bnick XTRA "onjoin-$chan-$onj"]"
}
notice $nick " End of onjoin $misc1."
return 0
}
}
bind join - * check_onjoin
proc check_onjoin {nick uhost handle chan} {
global botnick bnick
set chan [string tolower $chan]
if {[onjoin_account $chan] != 1} {
putlog "Problem creating/validating $bnick's account."
return 0
}
if {$nick == $botnick || [checkbot $handle]} {return 0}
set index [getuser $bnick XTRA "onjoin-index-$chan"]
if {$index == ""} {return 0}
if {$index > 5} {return 0}
for {set onj 1} {$onj < [expr $index + 1]} {incr onj} {
set a [getuser $bnick XTRA "onjoin-$chan-$onj"]
set i [string first "\{" [string tolower $a]]
while {$i != -1} {
set a "[string range $a 0 [expr $i - 1] ][string range $a [expr $i + 1] end]"
set i [string first "\{" [string tolower $a]]
}
set i [string first "\}" [string tolower $a]]
while {$i != -1} {
set a "[string range $a 0 [expr $i - 1] ][string range $a [expr $i + 1] end]"
set i [string first "\}" [string tolower $a]]
}
set i [string first "\\" [string tolower $a]]
while {$i != -1} {
set a "[string range $a 0 [expr $i - 1] ][string range $a [expr $i + 1] end]"
set i [string first "\\" [string tolower $a]]
}
set i [string first "\$nick" [string tolower $a]]
# The routine takes into account that the variable in the ONJOIN line
# becomes "{$nick}" instead of "$nick"
while {$i != -1} {
set a "[string range $a 0 [expr $i - 1] ]$nick[string range $a [expr $i + 5] end]"
set i [string first "\$nick" [string tolower $a]]
}
set i [string first "\$chan" [string tolower $a]]
while {$i != -1} {
set a "[string range $a 0 [expr $i - 1] ]$chan[string range $a [expr $i + 5] end]"
set i [string first "\$chan" [string tolower $a]]
}
set i [string first "\$bot" [string tolower $a]]
while {$i != -1} {
set a "[string range $a 0 [expr $i - 1] ]$botnick[string range $a [expr $i + 4] end]"
set i [string first "\$bot" [string tolower $a]]
}
notice $nick "$a"
}
}
### adduser proc
proc call_adduser {nick handle chan misc1 misc2 misc3} {
global home groupname botnick numversion strict-host levels
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick adduser (#channel) <nick> <friend | voice | bot | op | master | owner | full | bot | chanvoice | chanowner | chanmaster | chanop>"
notice $nick "See also : (/msg) $botnick levels"
return 0
}
if {$misc2 == ""} {notice $nick "You need to specify a level. Try: (/msg) $botnick levels" ; return 0}
set available [string tolower "bot $levels"]
if {[lsearch -glob $available [string tolower $misc2]] == -1} {notice $nick "$misc2 doesn't exist, you idiot!"; return 0}
set strict 0
if {[string index $misc1 0] == "!"} {set misc1 [string range $misc1 1 end]; set strict 1}
if {![onchan $misc1 $chan]} {notice $nick "$misc1 is not on $chan."; return 0}
set addhost [getchanhost $misc1 $chan]
if {![set strict-host] && ($strict == 0)} {
# Check for "strict-host / ~" issue in eggdrop 1.4.3+
if {[string index $addhost 0] == "~"} {set addhost "*[string range $addhost 1 end]"}
}
set checkhandle [nick2hand $misc1 $chan]
if {$checkhandle == "" || $checkhandle == "*"} {set checkhandle $misc1}
set checkhandle [string range $checkhandle 0 11]; if {$numversion < 1060900} {set checkhandle [string range $checkhandle 0 8]}
if {$strict == 0} {set addhost [maskhost $addhost]
} else {set addhost "*!$addhost"}
if {[string tolower $misc2] == "chanfriend"} {
if {[matchattr $misc1 |+f $chan]} {notice $nick "$misc1 already has access in $chan, please use the moduser command."; return 0}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002friend\002 for $chan"
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nicknames."
notice $misc1 "Also, type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002friend\002 for $chan"
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
# change to "$checkhandle"
chattr $checkhandle +p|+f $chan
save
notice $nick "Added $misc1 ($addhost) as a \002friend\002 for $chan"
msg $chan "Added $misc1 ($addhost) as an \002friend\002 for $chan. ($nick)"
return 0
}
if {[string tolower $misc2] == "chanvoice"} {
if {[matchattr $misc1 |+f $chan]} {
notice $nick "$misc1 already has access in $chan, please use the moduser command."
return 0
}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002voice\002 for $chan"
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nicknames."
notice $misc1 "Also, type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002voice\002 for $chan"
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
# change to "$checkhandle"
chattr $checkhandle +p|+vf $chan
save
notice $nick "Added $misc1 ($addhost) as a \002voice\002 for $chan"
msg $chan "Added $misc1 ($addhost) as an \002voice\002 for $chan. ($nick)"
return 0
}
if {[string tolower $misc2] == "chanhalfop" || [stl $misc2] == "chanhop"} {
if {![matchattr $handle m|m $chan]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[matchattr $misc1 |+f $chan]} {
notice $nick "$misc1 already has access in $chan, please use the moduser command."
return 0
}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002halfop\002 for $chan."
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nickname."
notice $misc1 "Also, type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002halfop\002 for $chan."
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
chattr $checkhandle +p|+Hlf $chan
save
notice $nick "Added $misc1 ($addhost) as an \002halfop\002 for $chan"
msg $chan "Added $misc1 ($addhost) as an \002halfop\002 for $chan. ($nick)"
return 0
}
if {[string tolower $misc2] == "chanop"} {
if {![matchattr $handle m|m $chan]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[matchattr $misc1 |+f $chan]} {
notice $nick "$misc1 already has access in $chan, please use the moduser command."
return 0
}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002op\002 for $chan."
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nickname."
notice $misc1 "Also, type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002op\002 for $chan."
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
chattr $checkhandle +p|+of $chan
save
notice $nick "Added $misc1 ($addhost) as an \002op\002 for $chan"
msg $chan "Added $misc1 ($addhost) as an \002op\002 for $chan. ($nick)"
return 0
}
if {[string tolower $misc2] == "chanmaster"} {
if {![matchattr $handle m|n $chan]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[matchattr $misc1 |+f $chan]} {
notice $nick "$misc1 already has access in $chan, please use the moduser command."
return 0
}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002master\002 for $chan."
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nickname."
notice $misc1 "Also, type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002master\002 for $chan."
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
chattr $checkhandle +p|+mof $chan
save
notice $nick "Added $misc1 ($addhost) as a \002master\002 for $chan."
msg $chan "Added $misc1 ($addhost) as an \002master\002 for $chan. ($nick)"
return 0
}
if {$misc2 == "chanowner"} {
if {![matchattr $handle m]} {notice $nick "Sorry, not enough access"; return 0}
if {[matchattr $misc1 |+f $chan]} {notice $nick "$misc1 already has access in $chan, please use the moduser command."; return 0}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002owner\002 for $chan."
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nickname."
notice $misc1 "Also, type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002owner\002 for $chan."
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
chattr $checkhandle +p|+nmof $chan
save
notice $nick "Added $misc1 ($addhost) as a \002owner\002 for $chan"
msg $chan "Added $misc1 ($addhost) as an \002owner\002 for $chan. ($nick)"
msg $home "Added $misc1 ($addhost) as an \002owner\002 for $chan. ($nick)"
return 0
}
if {[string tolower $misc2] == "bot"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[matchattr $misc1 +f] || [matchattr $misc1 +b]} {
notice $nick "$misc1 is already added to me."
return 0
}
if {![validuser $checkhandle]} {
if {$misc3 == ""} {
set botaddress ""
addbot $misc1 $botaddress
setuser $misc1 HOSTS $addhost
notice $nick "Added $misc1 ($addhost) as a \002Bot\002 with no bot address."
msg $home "Added $misc1 ($addhost) as a \002Bot\002 with no address. ($nick)"
} else {
set botaddress $misc3
addbot $misc1 $botaddress
setuser $misc1 HOSTS $addhost
notice $nick "Added $misc1 ($addhost) as a \002Bot\002 with the bot address '$botaddress'."
msg $home "Added $misc1 ($addhost) as a \002Bot\002 with the bot address '$botaddress'. ($nick)"
}
}
chattr $checkhandle +fvo
save
return 0
}
if {[string tolower $misc2] == "voice"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[matchattr $misc1 +f]} {
notice $nick "$misc1 already has global access, please use the moduser command."
return 0
}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002Global Voice\002 for $groupname."
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nickname."
notice $misc1 "Also, Type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002Global Voice\002 for $groupname."
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
chattr $checkhandle -qk+pfvV
# Global +d is intentionally left-off this chattr command.
save
notice $nick "Added $misc1 ($addhost) as an \002Global Voice\002 for $groupname."
msg $home "Added $misc1 ($addhost) as an \002Global Voice\002 for $groupname. ($nick)"
return 0
}
if {$misc2 == "halfop"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[matchattr $misc1 +f]} {
notice $nick "$misc1 already has global access, please use the moduser command."
return 0
}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002Global Halfop\002 for $groupname."
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nickname."
notice $misc1 "Also, Type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002Global Halfop\002 for $groupname."
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
chattr $checkhandle -qdkv+fpxhHl
save
notice $nick "Added $misc1 ($addhost) as an \002Global Halfop\002 for $groupname."
msg $home "Added $misc1 ($addhost) as an \002Global Halfop\002 for $groupname. ($nick)"
return 0
}
if {$misc2 == "op"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[matchattr $misc1 +f]} {
notice $nick "$misc1 already has global access, please use the moduser command."
return 0
}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002Global Op\002 for $groupname."
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nickname."
notice $misc1 "Also, Type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002Global Op\002 for $groupname."
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
chattr $checkhandle -qdkv+ofpxhO
save
notice $nick "Added $misc1 ($addhost) as an \002Global Op\002 for $groupname."
msg $home "Added $misc1 ($addhost) as an \002Global Op\002 for $groupname. ($nick)"
return 0
}
if {$misc2 == "tech"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[matchattr $misc1 +f]} {
notice $nick "$misc1 already has global access, please use the moduser command."
return 0
}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002Global OP/Tech\002 for $groupname."
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nickname."
notice $misc1 "Also, Type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002Global Op/Tech\002 for $groupname."
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
chattr $checkhandle -qdkv+ofpxhtT
save
notice $nick "Added $misc1 ($addhost) as an \002Global Op/Tech\002 for $groupname."
msg $home "Added $misc1 ($addhost) as an \002Global Op/Tech\002 for $groupname. ($nick)"
return 0
}
if {$misc2 == "master"} {
if {![matchattr $handle n]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[matchattr $misc1 +f]} {
notice $nick "$misc1 already has global access, please use the moduser command."
return 0
}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002Global Master\002 for $groupname."
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nickname."
notice $misc1 "Also, Type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002Global Master\002 for $groupname."
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
chattr $checkhandle -qdk+mxpotfhM
save
notice $nick "Added $misc1 ($addhost) as an \002Global Master\002 for $groupname."
msg $home "Added $misc1 ($addhost) as an \002Global Master\002 for $groupname. ($nick)"
return 0
}
if {$misc2 == "owner"} {
if {![matchattr $handle n]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[matchattr $misc1 +f]} {
notice $nick "$misc1 already has global access, please use the moduser command."
return 0
}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002Global Owner\002 for $groupname."
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nickname."
notice $misc1 "Also, Type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002Global Owner\002 for $groupname."
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
chattr $checkhandle -qdkv+nmxpofhtN
save
notice $nick "Added $misc1 ($addhost) as an \002Global Owner\002 for $groupname."
msg $home "Added $misc1 ($addhost) as an \002Global Owner\002 for $groupname. ($nick)"
return 0
}
if {$misc2 == "full"} {
if {![matchattr $handle n]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[matchattr $misc1 +f]} {
notice $nick "$misc1 already has global access, please use the moduser command."
return 0
}
if {![validuser $checkhandle]} {
adduser $misc1 $addhost
notice $misc1 "You have been added to my userlist as a \002Full Access User\002 for $groupname."
notice $misc1 "You really need to set a password. To do so, please type '/msg $botnick PASS <your chosen password>'"
notice $misc1 "Also, you need to remember to login using '/msg $botnick login <password>' every time you come on IRC or change nickname."
notice $misc1 "Also, Type '(/msg) $botnick help ($chan)' in the channel for commands available."
} else {
notice $misc1 "You've been added as a \002Full Access User\002 for $groupname."
notice $misc1 "You are already a known user to the bot. If there seem to be a problem with that, please contact $groupname in $home."
}
chattr $checkhandle -qdkv+nmxpoftjhN
save
notice $nick "Added $misc1 ($addhost) as an \002Full Access User\002 for $groupname."
msg $home "Added $misc1 ($addhost) as an \002Full Access User\002 for $groupname. ($nick)"
}
}
utimer 0 sb_check_netbots
proc sb_check_netbots { } {
if {[info args do_login] != "nick host handle arg"} {die "I refuse to run with NETBOTS.TCL! It steals PROCs from me which can reveal user passwords when I try to run!"}
}
### Remuser proc
proc call_remuser {nick handle chan misc1 misc2} {
global botnick home owner bnick mastername ownername groupname
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick remuser (#channel) <nick | handle> (global)"
return 0
}
if {[string tolower $misc1] == "me"} {
notice $nick "I don't think removing you is such a good idea."
return 0
}
if {([string tolower $misc1] == [string tolower $botnick]) || ([string tolower $misc1] == [string tolower $bnick])} {
notice $nick "Are you stupid? Want me to lose all channel-specific data across the board?"
msg $home "$nick tried a \"Remuser $misc1\" in $chan!! Someone kill that dumbass, please?"
return 1
}
if {[onchan $misc1 $chan]} {
set whoisnick $misc1
set remhandle [nick2hand $misc1 $chan]
if {$remhandle == "" || $remhandle == "*"} {
notice $nick "\002$misc1\002 is \002NOT\002 a known user."
return 0
}
} elseif {[validuser $misc1]} {
set whoisnick $misc1
set remhandle $misc1
} else {
notice $nick "\002$misc1\002 is \002NOT\002 a known user."
return 0
}
if {$remhandle == $handle} {
notice $nick "I don't think removing you is such a good idea (get someone with higher access than you to do it)."
return 0
}
if {[handonchan $remhandle $chan]} {set misc1 [hand2nick $remhandle $chan]}
if {[string tolower $misc2] == "global"} {
if {![matchattr $handle m]} {notice $nick "Negative on that, Houston. (Masters Only)"; return 0}
if {[checkaccess $handle $chan $remhandle]} {
deluser $remhandle
notice $nick "Removed $remhandle from the bot's userfile."
msg $home "Removed $remhandle from the bot's userfile. ($nick)"
return 0
} else {notice $nick "Negative on that, Houston. (Don't got enough access)"; return 0}
}
if {![matchattr $handle m]} {
if {[checkbot $remhandle]} {notice $nick "Negative on that, Houston. ($misc1 is a bot - Get a person from $groupname to remove it)"; return 0}
if {![checkchanaccess $handle $chan $remhandle]} {notice $nick "Negative on that, Houston. (Not enough access)"; return 0}
}
if {[string tolower $remhandle] == [string tolower $owner]} {
notice $nick "You can't remove the bot owner you idiot!"
msg $chan "You can't remove the bot owner you idiot!"
msg $home "$nick tried to \037REMUSER\037 $misc1 on $chan! Ha ha!"
return 1
}
if {![delchanrec $remhandle $chan]} {notice $nick "$misc1 doesn't have access in $chan."; return 0}
foreach checkchan [channels] {
if {[matchattr $remhandle |fvHlomn $checkchan]} {
notice $nick "\002Removed $misc1 (Handle: $remhandle) from $chan.\002"
msg $chan "\002Removed $misc1 (Handle: $remhandle) from $chan.\002"
return 0
}
}
if {[matchattr $remhandle fvHotmn]} {
notice $nick "\002Removed $misc1 (Handle: $remhandle) from $chan.\002"
msg $chan "\002Removed $misc1 (Handle: $remhandle) from $chan.\002"
return 0
}
deluser $remhandle
notice $nick "\002Removed $misc1 (Handle: $remhandle) from $chan and from the bot's userfile.\002"
msg $chan "\002Removed $misc1 (Handle: $remhandle) from $chan and from the bot's userfile.\002"
msg $home "\002Removed $misc1 (Handle: $remhandle) from $chan and from the bot's userfile.\002"
}
### moduser proc
proc call_moduser {nick handle chan misc1 misc2 misc3} {
global home groupname botnick
if {![matchattr $handle m|m $chan]} {
notice $nick "Negative on that, Houston. (Masters Only)"
return 0
}
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick adduser (#channel) <nick> <null | voice | bot | op | master | owner | full | chanvoice | chanowner | chanmaster | chanop>"
notice $nick "See also : (/msg) $botnick levels"
return 0
}
if {$misc2 == ""} {
notice $nick "You need to specify a level. Try: (/msg) $botnick levels"
return 0
}
set available [string tolower "chanfriend chanvoice chanop chanmaster chanowner friend voice op tech master owner full"]
if {[lsearch -glob $available [string tolower $misc2]] == -1} {
notice $nick "$misc2 doesn't exist, you idiot!"
return 0
}
if {[onchan $misc1 $chan]} {
set modnick $misc1
set modhandle [nick2hand $misc1 $chan]
if {$modhandle == "" || $modhandle == "*"} {
notice $nick "\002$misc1\002 is \002NOT\002 a known user."
return 0
}
} elseif {[validuser $misc1]} {
set modnick $misc1
set modhandle $misc1
} else {
notice $nick "\002$misc1\002 is \002NOT\002 a known user."
return 0
}
if {[matchattr $modhandle +b]} {
notice $nick "You can't use MODUSER on a bot."
return 0
}
if {[matchattr $modhandle +Z]} {
notice $nick "You can't use MODUSER on a suspended user."
return 0
}
set a $misc1
if {[string tolower $misc2] == "chanfriend"} {
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002friend\002 for $chan by $nick."
}
chattr $modhandle +p|-qdknmoHlv+f $chan
save
notice $nick "Modified $a ($modhandle) to a \002friend\002 for $chan"
msg $chan "Modified $a ($modhandle) to a \002friend\002 for $chan. ($nick)"
return 0
}
if {[string tolower $misc2] == "chanvoice"} {
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002voice\002 for $chan by $nick."
}
chattr $modhandle +p|-qnmHlok+vf $chan
# mode +d is intentionally omitted here.
save
notice $nick "Modified $a ($modhandle) to a \002voice\002 for $chan"
msg $chan "Modified $a ($modhandle) to a \002voice\002 for $chan. ($nick)"
return 0
}
if {[string tolower $misc2] == "chanhop" || [string tolower $misc2] == "chanhalfop"} {
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to an \002halfop\002 for $chan by $nick."
}
chattr $modhandle +p|-nqmdkv+Hlf $chan
save
notice $nick "Modified $a ($modhandle) to an \002halfop\002 for $chan"
msg $chan "Modified $a ($modhandle) to an \002halfop\002 for $chan. ($nick)"
return 0
}
if {[string tolower $misc2] == "chanop"} {
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to an \002op\002 for $chan by $nick."
}
chattr $modhandle +p|-nqmHldkv+of $chan
save
notice $nick "Modified $a ($modhandle) to an \002op\002 for $chan"
msg $chan "Modified $a ($modhandle) to an \002op\002 for $chan. ($nick)"
return 0
}
if {[string tolower $misc2] == "chanmaster"} {
if {![matchattr $handle m|n $chan]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002master\002 for $chan by $nick."
}
chattr $modhandle +p|-qndHlkv+mof $chan
save
notice $nick "Modified $a ($modhandle) to a \002master\002 for $chan"
msg $chan "Modified $a ($modhandle) to a \002master\002 for $chan. ($nick)"
return 0
}
if {$misc2 == "chanowner"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002owner\002 for $chan by $nick."
}
chattr $modhandle +p|-qdkvHl+fmno $chan
save
notice $nick "Modified $a ($modhandle) to an \002owner\002 for $chan"
msg $chan "Modified $a ($modhandle) to an \002owner\002 for $chan. ($nick)"
msg $home "Modified $a ($modhandle) to an \002owner\002 for $chan. ($nick)"
return 0
}
if {[string tolower $misc2] == "bot"} {notice $nick "You can't MODUSER a user to be a bot."}
if {$misc2 == "null"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to \002non-access\002 by $nick."
}
chattr $modhandle -nmtqdkvoHlOMNTC+fp
save
notice $nick "Modified $a ($modhandle) to a \002global op\002"
msg $home "Modified $a ($modhandle) to a \002global op\002 ($nick)"
return 0
}
if {[lsearch -glob "doink protector asshole dumbass shit ass fool clown jester dipshit" [string tolower $misc2]] != -1} {
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002$misc2\002 for $chan by $nick."
}
notice $nick "Modified $a ($modhandle) to a \002$misc2\002 for $chan"
msg $chan "Modified $a ($modhandle) to a \002$misc2\002 for $chan. ($nick)"
return 0
}
if {[string tolower $misc2] == "friend"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002global friend\002 by $nick."
}
chattr $modhandle -nmHlotkqjNMTOVC+fp
# mode +d is intentionally omitted here.
save
notice $nick "Modified $a ($modhandle) to a \002global friend\002"
msg $home "Modified $a ($modhandle) to a \002global friend\002. ($nick)"
return 0
}
if {[string tolower $misc2] == "voice"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002global voice\002 by $nick."
}
chattr $modhandle -nmHlotkjqNMTOC+vpV
# mode +d is intentionally omitted here.
save
notice $nick "Modified $a ($modhandle) to a \002global voice\002"
msg $home "Modified $a ($modhandle) to a \002global voice\002. ($nick)"
return 0
}
if {[stl $misc2] == "halfop" || [stl $misc2] == "hop"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002global halfop\002 by $nick."
}
chattr $modhandle -nmtqdkjvNMVTC+fpHl
save
notice $nick "Modified $a ($modhandle) to a \002global halfop\002"
msg $home "Modified $a ($modhandle) to a \002global halfop\002 ($nick)"
return 0
}
if {$misc2 == "op"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002global op\002 by $nick."
}
chattr $modhandle -nmtqdkjvNMVTC+fopO
save
notice $nick "Modified $a ($modhandle) to a \002global op\002"
msg $home "Modified $a ($modhandle) to a \002global op\002 ($nick)"
return 0
}
if {$misc2 == "tech"} {
if {![matchattr $handle m]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002global op/tech\002 by $nick."
}
chattr $modhandle -nmvqdkNMCVO+foptT
save
notice $nick "Modified $a ($modhandle) to a \002global op/tech\002"
msg $home "Modified $a ($modhandle) to a \002global op/tech\002 ($nick)"
return 0
}
if {$misc2 == "master"} {
if {![matchattr $handle n]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002global master\002 by $nick."
}
chattr $modhandle -ndqkvNCVOC+fmoptM
save
notice $nick "Modified $a ($modhandle) to a \002global master\002"
msg $home "Modified $a ($modhandle) to a \002global master\002 ($nick)"
return 0
}
if {$misc2 == "owner"} {
if {![matchattr $handle n]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002global owner\002 by $nick."
chattr $modhandle -qdkvMOTVC+fnmHloptN
}
save
notice $nick "Modified $a ($modhandle) to a \002global owner\002"
msg $home "Modified $a ($modhandle) to a \002global owner\002 ($nick)"
return 0
}
if {$misc2 == "full"} {
if {![matchattr $handle n]} {
notice $nick "Sorry, not enough access"
return 0
}
if {[handonchan $modhandle $chan]} {
set a [hand2nick $modhandle $chan]
notice $a "You have been modified in my userlist to a \002full access user\002 by $nick."
}
chattr $modhandle -qdkMTOVC+fmontjxpvN
save
notice $nick "Modified $a ($modhandle) to a \002full access user\002"
msg $chan "Modified $a ($modhandle) to a \002full access user\002 ($nick)"
}
}
### cycle proc
proc call_cycle {nick handle chan} {
global home botnick
putquick "PART $chan"
putquick "JOIN $chan"
notice $nick "\002 I have successfully cycled $chan \002"
}
### Invite proc
proc call_invite {nick handle chan misc1} {
global botnick home
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick invite (#channel) <me | nick>"
return 0
}
if {$misc1 == "me"} {
if {[onchan $nick $chan]} {
notice $nick "You are already on $chan."
return 0
}
if {![matchattr $handle n]} {
notice $home "Inviting $nick to $chan"
}
notice $nick "Inviting you to $chan."
putquick "INVITE $nick :$chan"
return 0
}
if {[onchan $misc1 $chan]} {
notice $nick "$misc1 is already on $chan."
return 0
}
if {![matchattr $handle n]} {
notice $home "\002Inviting $misc1 to $chan (requested by $nick)\002"
}
notice $nick "Inviting $misc1 to $chan"
putquick "INVITE $misc1 :$chan"
}
### Chaninfo proc
proc call_chaninfo {nick handle chan} {
set ci [channel info $chan]
global version custom; array set chaninfo ""
set chaninfo(Modes) "chanmode ([l0 $ci])"; set ci [lrange $ci 1 end]
foreach a "idle-kick stopnethack-mode revenge-mode" {
if {[string is integer [l0 $ci]]} {set chaninfo(Modes) [app $chaninfo(Modes) "$a ([l0 $ci])"]; set ci [lrange $ci 1 end]}
}
set need "op invite key unban limit"
foreach a $need {set chaninfo(junk) [l0 $ci]; set ci [lrange $ci 1 end]}
set chaninfo(Flood) ""
set flood "chan ctcp join kick deop"
foreach a $flood { if {[string match "*:*" [l0 $ci]]} {set chaninfo(Flood) [app $chaninfo(Flood) "$a ([l0 $ci])"]; set ci [lrange $ci 1 end]} }
if {[string match "*:*" [l0 $ci]]} {set chaninfo(Flood) [app $chaninfo(Flood) "nick ([l0 $ci])"]; set ci [lrange $ci 1 end]}
if {[string match "*:*" [l0 $ci]] || [string is integer [l0 $ci]]} {set chaninfo(aop-delay) [l0 $ci]; set ci [lrange $ci 1 end]}
set times [stt "ban-time exempt-time invite-time"]; set chaninfo(Times) ""
set chaninfo(Times) ""
foreach a $times {
if [string is integer [l0 $ci]] {set chaninfo(Times) [app $chaninfo(Times) "$a ([l0 $ci])"]; set ci [l1e $ci]}
}
set chaninfo(Flags) $ci; unset ci
foreach a [array names need*] {unset chaninfo($a)}
set replyorder "Mode* Flood* aop* Times"
unset chaninfo(junk)
notice $nick "CHANINFO for $chan:"
foreach a "$replyorder" {
set b [array names chaninfo $a]; # Unset values will be skipped.
foreach c $b {notice $nick "$c: $chaninfo($c)"; unset chaninfo($c)}
}
foreach a [array names chaninfo] { if {![string match "get*" $a]} {notice $nick "$a: $chaninfo($a)"} }
notice $nick " "
notice $nick ">End of CHANINFO data."
return 0
}
### Chanset proc
proc call_chanset {nick handle chan misc1 misc2 misc1end misc2end} {
global botnick version
# Need to remove either THIS [following] STL, or replace-all beyond here.
set misc1 [string tolower $misc1]
if {$misc1 == ""} {notice $nick "Usage: (/msg) $botnick chanset (#channel) <mode> (args | none)"; return 0}
if {[string tolower $misc1] == "chanmode"} {
set m [lrange $misc2end 0 2]; # was: set m [string tolower [lrange $misc2end 0 2]]
set valid 0
if {$m == "none" || $m == "clear"} {
set m "+"; set valid 1
} else {
set main [lindex $m 0]; set mode ""; set extra ""; set onoff "+"
# This will isolate the first packet for processing [the "tnl" of a
# "BOT CHANSET CHANMODE +tnl 30" command]. Parameters for +l and +k
# will be processed for each individual mode.
# EGGDROP does =not= know which modes are [IN]VALID by itself; TCL
# coding needs to check if the bot / server can handle each mode.
# Current testing shows a possible scan routing to handle this.
# More on this in the next release. Until then, modes +ceCILO are
# removed as valid modes. Sorry.
foreach char [split $main ""] {
switch -exact -- $char {
+ {set onoff "+"}
- {set onoff "-"}
s - t - i - n - k - m - p {set valid 1; append mode "$onoff" "$char"}
l {
set valid 1
append mode "$onoff" "l"
set limit [lindex $m 1]
set ok 1
foreach k [split $limit ""] {
if {![string match \[0-9\] $k]} {set ok 0}
}
if {$ok == 0} {notice $nick "$limit is an invalid parameter for mode $onoff$char."; return 0}
lappend extra $limit
set m [lreplace $m 1 1]
}
k {
append mode "$onoff" "k"
set limit [lindex $m 1]
lappend extra $limit
set m [lreplace $m 1 1]
}
default {notice $nick "Erroneous mode value: $char"; return 0}
}
}
set m "$m $extra"
putquick "mode $chan $m"
set valid 1
}
if {$valid == 0} {
notice $nick "Invalid entry: $m"
} else {
channel set $chan chanmode "$m"
notice $nick "Protecting modes: [lrange $misc2end 0 2]"
}
return 1
}
set more ""
if {[l1 $version] >= 1061300} {set more " ban-time exempt-time invite-time"}
# Due to older version of EGGDROP using "STOPNETHACK" I've left both in.
if {[lsearch -glob "idle-kick stopnethack stopnethack-mode revenge-mode$more" [string tolower $misc1]] > -1} {
foreach i [split $misc2 ""] {
if {![string match \[0-9\] $i]} {notice $nick "Usage: (/msg) $botnick chanset (#channel) $misc1 <value>"; return 0}
}
if {$misc2 == 0} {
notice $nick "Turned $misc1 for $chan off."
channel set $chan $misc1 $misc2
return 0
}
channel set $chan $misc1 $misc2
notice $nick "$misc1 for $chan is now $misc2."
return 1
}
if {[string match "flood-*" [stl $misc1]]} {
if ![string match "*:*" $misc2] {notice $nick "Usage: (/msg) $botnick chanset (#channel) $misc1 <number:time>"; return 0}
set type [sl1 [split $misc1 "-"]]
if {[lsearch -glob "chan ctcp delay deop join kick nick" $type] == -1} {notice $nick "$misc1 is not a valid value."; return 0}
set split [split $misc2 :]; set ok 1
foreach a $split { if ![string is integer $a] {set ok 0} }
if {[llength $split] != 2} {set ok 0}
if !($ok) {notice $nick "Usage: (/msg) $botnick chanset (#channel) $misc1 <number:time>"; return 0}
channel set $chan $misc1 $misc2
notice $nick "[l1 [split $misc1 "-"]] flood protection: $misc2"
save; writedata
return 1
}
if {[stl $misc1] == "aop-delay"} {
set split [split $misc2 :]; set ok 1
foreach a $split { if ![string is integer $a] {set ok 0} }
if {[llength $split] > 2} {set ok 0}
if !($ok) {notice $nick "Usage: (/msg) $botnick chanset (#channel) $misc1 <number:time | delay>"; return 0}
channel set $chan $misc1 $misc2
notice $nick "AOP-DELAY setting: $misc2"
save; writedata
return 1
}
set successful ""; set failed ""; set unsupported ""; set modes ""
foreach a [channel info $chan] {
if {[string match "+*" $a] || [string match "-*" $a]} {lappend modes [string range $a 1 end]}
}
foreach a [string tolower $misc1end] {
if {[string match "-*" $a] || [string match "+*" $a]} {
if {[lsearch -glob "[string tolower $modes]" [string tolower [string range $a 1 end]]] > -1} {
channel set $chan $a
if {[lsearch -glob [string tolower [channel info $chan]] "[string tolower $a]"] > -1} {
append successful ", $a"
} else {
append unsupported ", $a"
}
} else {
append failed ", $a"
}
} else {
append failed ", $a"
}
if {$successful != ""} {notice $nick "Successfully set mode [string trim $successful ","] for $chan"}
if {$unsupported != ""} {notice $nick "The following modes are not supported on this EGGDROP version: [string trim $unsupported ","]"}
if {$failed != ""} {
notice $nick "Invalid mode failures for $chan: [string trim $failed ","]"
notice $nick "For the valid modes, type: (/msg) $botnick help (#channel) chaninfo"
}
}
return 1
}
### Ignore proc
proc call_ignore {nick chan handle misc1 misc2end} {
global botnick home
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick ignore <nick | user@host> <reason>"
return 0
}
if {[string tolower $misc1] == "me"} {
notice $nick "I don't think ignoring you is such a good idea."
return 0
}
if {[string tolower $misc1] == [string tolower $botnick]} {
notice $nick "I don't think ignoring myself is such a good idea."
return 0
}
if {![onchan $misc1 $chan]} {
if {$misc2end == ""} {
newignore $misc1 $nick request 1440
notice $nick "Added ignore for $misc1 with default reason: \002request\002"
msg $home "Added ignore for $misc1 with default reason: \002request\002 ($nick)"
return 0
}
newignore $misc1 $nick $misc2end 1440
notice $nick "Added ignore for $misc1 with the reason: \002$misc2end\002"
msg $home "Added ignore for $misc1 with the reason: \002$misc2end\002 ($nick)"
return 0
}
set ignorehandle [nick2hand $misc1 $chan]
if {[checkbot $ignorehandle]} {
notice $nick "Don't ignore $misc1 - it's a bot!"
return 0
}
if {$ignorehandle == $handle} {
notice $nick "I don't think ignoring you is such a good idea."
return 0
}
if {[checkaccess $handle $chan $ignorehandle]} {
set ignore [maskhost *[getchanhost $misc1 $chan]]
if {$misc2end == ""} {
newignore $ignore $nick request 1440
notice $nick "Added ignore for $misc1 ($ignore) with default reason: \002request\002"
msg $home "Added ignore for $misc1 ($ignore) with default reason: \002request\002 ($nick)"
return 0
}
newignore $ignore $nick $misc2end 1440
notice $nick "Added ignore for $misc1 ($ignore) with the reason: \002$misc2end\002"
msg $home "Added ignore for $misc1 ($ignore) with the reason: \002$misc2end\002 ($nick)"
return 0
}
notice $nick "You don't have enough access to ignore $misc1"
}
### Unignore proc
proc call_unignore {nick misc1} {
global botnick
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick unignore <user@host>"
return 0
}
if {[killignore $misc1]} {
notice $nick "$misc1 has successfully been unignored."
return 0
}
notice $nick "$misc1 is not being ignored."
}
### Clear proc
proc call_clear {nick chan} {
if {![botisop $chan]} {
notice $nick "\002 I am not currently opped in $chan «•» \002"
return 0
}
putquick "MODE $chan -ntspimlk *"
set chankey [getchanmode $chan]
set justkey [lindex $chankey 1]
putquick "MODE $chan -k :$justkey"
set justkey [lindex $chankey 2]
putquick "MODE $chan -k :$justkey"
notice $nick "Channel modes in $chan have successfully been cleared."
}
### Opstat proc
proc call_opstat {nick misc1} {
global botnick home cserv exempt
set opstat ""
if {[string tolower $misc1] == "check"} {set misc1 1} else {set misc1 0}
set aa 0
foreach checkchan [channels] {
if {([lsearch -glob [string tolower $exempt] [string tolower $checkchan]] == -1)} {
incr aa
if {[botisop $checkchan]} {
if {$misc1 == 0} {
append opstat " \002@\002$checkchan"
}
} elseif {[isvoice $botnick $checkchan]} {
append opstat " \002+\002\037$checkchan\037"
} elseif {![onchan $botnick $checkchan]} {
append opstat " $checkchan\002\037(banned!)\037\002"
} else {
append opstat " $checkchan \002\037(deoped!)\037\002"
}
if {![onchan $cserv $checkchan] && [onchan $botnick $checkchan] && [onchan $cserv $home] && ($misc1 == 0)} {append opstat "(no $cserv!)"}
}
}
if {$opstat == ""} {
if {$misc1 == 0 || $aa == 0} {
set opstat "No channels are presently supported."
} else {
set opstat "All channels check O.K."
}
}
notice $nick "\002Ops status\002: $opstat"
}
### Log proc
proc call_log {nick misc1end} {
putlog "Manual log entry from $nick: $misc1end"
notice $nick "Entry made in the bot's log file."
return 0
}
### Lock proc
proc call_lock {nick chan} {
global home
if {![botisop $chan]} {
notice $nick "Can't lock $chan because I'm not an op"
return 0
}
msg $home "\002Locking $chan ($nick)\002"
notice $nick "\002Locking $chan\002"
putquick "MODE $chan :+sitnm"
}
### Unlock proc
proc call_unlock {nick chan} {
global home
if {![botisop $chan]} {
notice $nick "Can't unlock $chan because I'm not an op"
return 0
}
msg $home "\002Unlocking $chan ($nick)\002"
notice $nick "\002Unlocking $chan\002"
putquick "MODE $chan :-sim"
}
### Save proc
proc call_save {nick} {
global home
save
savechannels
msg $home "\002Saving database... ($nick)\002"
notice $nick "Saving database... "
}
### act proc
proc call_act {nick chan misc1end} {
global botnick
if {$misc1end == ""} {
notice $nick "Usage: (/msg) $botnick act (#channel) <what to act>"
return 0
}
msg $chan "\001ACTION $misc1end\001"
if {![onchan $nick $chan]} {notice $nick "I did \"$misc1end\" in $chan."}
}
### say proc
proc call_say {nick chan misc1end} {
global botnick; # hold; set hold ""
if {[sl1 $misc1end] == [stl $chan]} {set misc1end [l1e $misc1end]}
if {$misc1end == ""} {notice $nick "Usage: (/msg) $botnick say (#channel) <what to say>"; return 0}
msg $chan "[join $misc1end]"
if {![onchan $nick $chan]} {notice $nick "I said \"[join $misc1end]\" to $chan."}
}
### msg proc
proc call_msg {nick misc1 misc2end} {
global botnick hold
if {$misc1 == "" || $misc2end == ""} {
notice $nick "Usage: (/msg) $botnick msg <nick> <what to msg>"
return 0
}
if {$misc2end == ""} {
notice $nick "Usage: (/msg) $botnick msg (#channel) <what to say>"
return 0
}
msg $misc1 "$misc2end"
notice $nick "I /msg'd $misc1 with \"$misc2end.\""
}
### notice proc
proc call_notice {nick misc1 misc2end} {
global botnick
if {$misc1 == "" || $misc2end == ""} {
notice $nick "Usage: (/msg) $botnick msg <nick> <what to msg>"
return 0
}
notice $misc1 "$misc2end"
notice $nick "I /notice'd $misc1 with \"$misc2end.\""
}
### dccme proc
proc call_dccme {nick uhost handle} {
global botnick mastername ownername groupname
if {![matchattr $handle p]} {notice $nick "Your don't have party-line access. Please talk to a $mastername or $ownername for $groupname."; return 0}
*ctcp:CHAT $nick $uhost $handle $botnick CHAT ""
return 0
}
### channels proc
proc call_channels {nick} {notice $nick "\002 I am currently on: [channels]\002"}
### Global proc
proc call_global {nick handle misc1 misc2 misc3 misc4 misc2end misc3end misc4end} {
global botnick home
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick global <op | deop | kick | ban | unban | userlist | list> "
return 0
}
# Global Op Command
if {[string tolower $misc1] == "op"} {
if {$misc2 == ""} {set misc2 "me"}
set notoppedchans ""
set ochans ""
if {$misc2 == "me"} {
foreach ochan [channels] {
if {[onchan $nick $ochan]} {
if {![botisop $ochan]} {
append notoppedchans " " $ochan
} else {
putquick "MODE $ochan +o $nick"
append ochans " " $ochan
}
}
}
if {!($notoppedchans == "")} {
notice $nick "\002 Status:\002 I can't op you in $notoppedchans."
}
if {$ochans == ""} {
notice $nick "\002 Status:\002 You were not oped in any channels."
} else {
notice $nick "\002 Status:\002 You were oped on $ochans."
}
return 0
}
foreach ochan [channels] {
if {[onchan $misc2 $ochan]} {
if {![botisop $ochan]} {
append notoppedchans " " $ochan
} else {
putquick "MODE $ochan +o $misc2"
append ochans " " $ochan
}
}
}
if {!($notoppedchans == "")} {
notice $nick "\002 Status:\002 I can't op $misc2 in $notoppedchans"
}
if {$ochans == ""} {
notice $nick "\002 Status:\002 $misc2 was not oped in any channels."
} else {
notice $nick "\002 Status:\002 $misc2 was oped on $ochans."
}
return 0
}
# Global Deop Command
if {[string tolower $misc1] == "deop"} {
if {$misc2 == ""} {set misc2 "me"}
if {[string tolower $misc2] == [string tolower $botnick]} {
notice $nick "I don't think deoping myself is such a good idea."
return 0
}
set notoppedchans ""
set dochans ""
set noaccesschans ""
if {[string tolower $misc2] == "me"} {
foreach dochan [channels] {
if {[onchan $nick $dochan]} {
if {![botisop $dochan]} {
append notoppedchans " " $dochan
} else {
putquick "MODE $dochan -o $nick"
append dochans " " $dochan
}
}
}
if {!($notoppedchans == "")} {
notice $nick "\002 Status:\002 I can't deop you in $notoppedchans."
}
if {$dochans == ""} {
notice $nick "\002 Status:\002 You were not deoped in any channels."
} else {
notice $nick "\002 Status:\002 You were deoped on $dochans."
}
return 0
}
foreach dochan [channels] {
if {[onchan $misc2 $dochan]} {
if {![botisop $dochan]} {
append notoppedchans " " $dochan
} else {
set deophandle [nick2hand $misc2 $dochan]
if {[checkbot $deophandle]} {
notice $nick "Don't deop $misc2 - it's a bot!"
return 0
}
if {[checkaccess $handle $dochan $deophandle]} {
putquick "MODE $dochan -o $misc2"
append dochans " " $dochan
} else {
append noaccesschans " " $dochan
}
}
}
}
if {!($notoppedchans == "")} {
notice $nick "\002 Status:\002 I can't deop $misc2 in $notoppedchans"
}
if {!($noaccesschans == "")} {
notice $nick "\002 Status:\002 You don't have access to deop $misc2 in $noaccesschans"
}
if {$dochans == ""} {
notice $nick "\002 Status:\002 $misc2 was not deoped in any channels."
} else {
notice $nick "\002 Status:\002 $misc2 was deoped on $dochans."
}
return 0
}
# Global Kick Command
if {$misc1 == "kick"} {
if {$misc2 == ""} {
notice $nick "Usage: (/msg) $botnick global kick <me | nick> <reason>"
return 0
}
if {$misc2 == $botnick} {
notice $nick "I don't think kicking myself is such a good idea."
return 0
}
set notoppedchans ""
set kchans ""
set noaccesschans ""
if {([string tolower $misc2] == "me") || ([string tolower $misc2] == [string tolower $nick])} {
foreach kchan [channels] {
if {[onchan $nick $kchan]} {
if {![botisop $kchan]} {
append notoppedchans " " $kchan
} else {
if {$misc3end == ""} {
putquick "KICK $kchan $nick :Okay dokay... you're out :P"
append kchans " " $kchan
} else {
putquick "KICK $kchan $nick :$misc3end"
append kchans " " $kchan
}
}
}
}
if {!($notoppedchans == "")} {
notice $nick "\002 Status:\002 I can't kick you in $notoppedchans"
}
if {$kchans == ""} {
notice $nick "\002 Status:\002 You were not kicked in any channels."
} else {
notice $nick "\002 Status:\002 You were kicked from $kchans."
}
return 0
}
foreach kchan [channels] {
if {[onchan $misc2 $kchan]} {
if {![botisop $kchan]} {
append notoppedchans " " $kchan
} else {
set kickhandle [nick2hand $misc2 $kchan]
if {[checkbot $kickhandle]} {
notice $nick "Don't kick $misc2 - it's a bot!"
return 0
}
if {[checkaccess $handle $kchan $kickhandle]} {
if {$misc3end == ""} {
putquick "KICK $kchan $misc1 :Kicked: request"
append kchans " " $kchan
} else {
putquick "KICK $kchan $misc1 :$misc3end"
append kchans " " $kchan
}
} else {
append noaccesschans " " $kchan
}
}
}
}
if {!($notoppedchans == "")} {
notice $nick "\002 Status:\002 I can't kick $misc2 in $notoppedchans"
}
if {!($noaccesschans == "")} {
notice $nick "\002 Status:\002 You don't have access to kick $misc2 in $noaccesschans"
}
if {$kchans == ""} {
notice $nick "\002 Status:\002 $misc2 was not kicked in any channels."
} else {
notice $nick "\002 Status:\002 $misc2 was kicked from $kchans."
}
return 0
}
# Global Ban Command
if {[string tolower $misc1] == "ban"} {
if {$misc2 == ""} {
notice $nick "Usage: (/msg) $botnick global ban <nick | user@host> (B1 .. B9 | perm) <reason>"
notice $nick "See also : (/msg) $botnick bantype"
return 0
}
if {([string tolower $misc2] == "me") || ([string tolower $misc2] == [string tolower $nick])} {
notice $nick "I don't think banning you is such a good idea."
return 0
}
if {$misc2 == $botnick} {
notice $nick "I don't think banning myself is such a good idea."
return 0
}
set bantime 120
set bantimeword "(Default) 2 hours"
set banreason $misc3end
if {[string tolower $misc3] == "perm"} {
set bantime 0
set bantimeword "Perm Ban"
set banreason $misc4end
}
if {[string tolower $misc3] == "b1"} {
set bantime 60
set bantimeword "(B1) 1 hour"
set banreason $misc4end
}
if {[string tolower $misc3] == "b2"} {
set bantime 360
set bantimeword "(B2) 6 hours"
set banreason $misc4end
}
if {[string tolower $misc3] == "b3"} {
set bantime 1440
set bantimeword "(B3) 24 hours"
set banreason $misc4end
}
if {[string tolower $misc3] == "b4"} {
set bantime 4320
set bantimeword "(B4) 3 days"
set banreason $misc4end
}
if {[string tolower $misc3] == "b5"} {
set bantime 10080
set bantimeword "(B5) 7 days"
set banreason $misc4end
}
if {[string tolower $misc3] == "b6"} {
set bantime 43200
set bantimeword "(B6) 30 days"
set banreason $misc4end
}
if {[string tolower $misc3] == "b7"} {
set bantime 129600
set bantimeword "(B7) 3 months"
set banreason $misc4end
}
if {[string tolower $misc3] == "b8"} {
set bantime 259200
set bantimeword "(B8) 6 months"
set banreason $misc4end
}
if {[string tolower $misc3] == "b9"} {
set bantime 525600
set bantimeword "(B9) 1 year"
set banreason $misc4end
}
# Note the variables are diffferent form the regular ban command
if {[string match "*[string range $misc3 0 0]*" "123456789"]} {
if {$misc3 > "9999999"} {set misc3 "9999999"}
set bantime $misc3
set bantimeword "$misc3 minutes"
set banreason $misc4end
}
set ban ""
foreach bchan [channels] {
if {[onchan $misc2 $bchan]} {
set banhandle [nick2hand $misc2 $bchan]
if {$banhandle == $handle} {
notice $nick "I don't think banning you is such a good idea."
return 0
}
if {[checkbot $banhandle]} {
notice $nick "Don't ban $misc2 - it's a bot!"
return 0
}
if {[checkaccess $handle $bchan $banhandle]} {
set banhost [getchanhost $misc2 $bchan]
if {[string match "~*" $banhost]} {
set banhost [string range $banhost 1 end]
}
set ban [maskhost *$banhost]
} else {
notice $nick "You don't have enough access to ban $misc2 in $bchan, so you can't put a global ban."
return 0
}
} else {
set checkhandle [finduser $misc2]
if {[checkbot $checkhandle]} {
notice $nick "Don't ban $misc2 ($checkhandle) - it's a bot!"
return 0
}
if {![checkaccess $handle $bchan $checkhandle]} {
notice $nick "You don't have enough access to ban $misc2 ($checkhandle) in $bchan, so you can't put a global ban."
return 0
}
}
}
if {!($ban == "")} {
if {$banreason == ""} {
set newbanreason "\002Global Ban: ($bantimeword)\002 request"
newban $ban $nick $newbanreason $bantime
notice $nick "Added global ban for $misc2 ($ban) with default reason: \002request\002. Bantype: $bantimeword"
msg $home "Added global ban for $misc2 ($ban) with default reason: \002request\002. Bantype: $bantimeword ($nick)"
return 0
}
set newbanreason "\002Global Ban: ($bantimeword)\002 $banreason"
newban $ban $nick $newbanreason $bantime
notice $nick "Added global ban for $misc2 ($ban) with the reason: \002$banreason\002. Bantype: $bantimeword"
msg $home "Added global ban for $misc2 ($ban) with the reason: \002$banreason\002. Bantype: $bantimeword ($nick)"
return 0
}
if {$banreason == ""} {
set newbanreason "\002Global Ban: ($bantimeword)\002 request"
notice $nick "Added global ban for $misc2 with default reason: \002request\002. Bantype: $bantimeword"
msg $home "Added global ban for $misc2 with default reason: \002request\002 Bantype: $bantimeword ($nick)"
} else {
set newbanreason "\002Global Ban: ($bantimeword)\002 $banreason"
notice $nick "Added global ban for $misc2 with the reason: \002$banreason\002. Bantype: $bantimeword"
msg $home "Added global ban for $misc2 with the reason: \002$banreason\002. Bantype: $bantimeword ($nick)"
}
newban $misc2 $nick $newbanreason $bantime
return 0
}
# Global Unban Command
if {[string tolower $misc1] == "unban"} {
if {$misc2 == ""} {
notice $nick "Usage: (/msg) $botnick global unban <nick!user@host>"
notice $nick "Example: /msg $botnick global unban *!*xone@*.bothouse.org"
return 0
}
if {![string match "*!*@*" $misc2]} {
notice $nick "Usage: (/msg) $botnick global unban <nick!user@host>"
notice $nick "Example: /msg $botnick global unban *!*xone@*.bothouse.org"
return 0
}
set b 0
if {[isban $misc2]} {
killban $misc2
set b 1
}
foreach c [channels] {
if {[isban $misc2 $c]} {
killchanban $c $misc2
set b 1
}
if {[ischanban $misc2 $c]} {
putquick "MODE $c -b $misc2"
set b 1
}
}
if {$b} {
notice $nick "I have successfully unbanned $misc2"
} else {
notice $nick "There was no global ban like $misc2"
}
return 0
}
# Userlist Command
if {$misc1 == "userlist"} {
if {$misc2 == ""} {
msg $nick "\002 Global Userlist \002"
} else {
msg $nick "\002 Global Userlist with the flags: $misc2 \002"
}
if {[userlist $misc2] == ""} {
msg $nick " "
notice $nick "\002 There are no users with the flags $misc2 \002"
return 0
}
foreach user [userlist $misc2] {
set info [getuser $user info]
set hosts [getuser $user hosts]
msg $nick " "
msg $nick "Handle: $user. Global flags: [chattr $user]"
if {!($info == "")} {
msg $nick "Greet: $info"
}
msg $nick "Hosts: $hosts"
}
return 0
}
notice $nick "Usage: (/msg) $botnick global <op | deop | kick | ban | unban | userlist | list> "
return 0
}
### banner proc
proc call_banner {nick misc1end} {
global botnick
if {$misc1end == ""} {
notice $nick "Usage: $botnick banner <message> or $botnick broadcast <message>"
return 0
}
foreach bchan [channels] {
msg $bchan "\002Global Message from \002$nick:\002 $misc1end"
}
return 0
}
### rehash proc
proc call_rehash {nick} {
global home
msg $home "Rehashing ... ($nick)"
notice $nick "Rehashing... "
rehash
}
### restart proc
proc call_restart {nick} {
global home
save
savechannels
msg $home "Restarting... ($nick)"
putquick "QUIT Restarting...($nick)"
restart
}
### join proc
proc call_join {nick misc1} {
global botnick home defchanoptions defchanmodes bnick
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick join <#channel>"
return 0
}
if {[validchan $misc1]} {
notice $nick "I'm already in $misc1"
return 0
}
if {[string match "#*" $misc1]} {
channel add $misc1 $defchanoptions
foreach chanmode $defchanmodes {
channel set $misc1 $chanmode
}
savechannels
notice $nick "Joining $misc1"
msg $home "\002Joining $misc1 ($nick)\002"
return 1
}
notice $nick "$misc1 is not a valid channel name, remember they have to start with a '#'."
return 0
}
### Part proc
proc call_part {nick chan misc1end} {
global botnick home
if {$chan == ""} {notice $nick "Usage: (/msg) $botnick part <#channel>"; return 0}
if {![string match "#*" $chan]} {notice $nick "$chan is not a valid channel name, remember they have to start with a '#'."; return 0}
if {[string tolower $chan] == [string tolower $home]} {
notice $nick "Are you an idiot?!"
msg $home "$nick tried to make me leave here!"
return 0
}
set reason ""
if {$misc1end != ""} {set reason " (reason: $misc1end)"}
notice $nick "Leaving $chan$reason"
msg $chan "\002Leaving $chan ($nick)\002 $reason"
msg $home "\002Leaving $chan ($nick)\002 $reason"
foreach checkuser [userlist] {
set delcheckuser 1
if {[delchanrec $checkuser $chan]} {
if {![matchattr $checkuser fvHo]} {
foreach checkchan [channels] {
if {[matchattr $checkuser |fvHo $checkchan]} {set delcheckuser 0; break}
}
if {$delcheckuser} {deluser $checkuser}
}
}
}
channel remove $chan
savechannels
putlog "Channel $chan REMOVED by $nick$reason"
return 0
}
### suspend proc
proc call_suspend {nick handle chan misc1 misc2end} {
global home botnick
if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick suspend (#channel) <nick | handle | list> \[reason\]"
return 0
}
if {[string tolower $misc1] == "me"} {
notice $nick "I don't think suspending you is such a good idea."
return 0
}
# Have it do the SHOW version first or fall-through to regular routine.
if {[string tolower $misc1] == "list"} {
foreach user [userlist] {
if {[matchattr $user Z]} {
set suspend [getuser $user XTRA "suspend"]
if {$suspend == ""} {
set sinfo "(no suspension data was logged)"
} else {
set stime [ctu [lindex $suspend 0]]
set suser [lindex $suspend 1]
set sreason [lrange $suspend 2 end]
set sinfo "(suspended on $stime by $suser for $sreason)"
}
notice $nick "$user $sinfo"
}
}
return 1
}
if {[onchan $misc1 $chan]} {
set suspendhandle [nick2hand $misc1 $chan]
} else {
set suspendhandle $misc1
}
if {[checkbot $suspendhandle]} {
notice $nick "Don't suspend $misc1 - it's a bot!"
return 0
}
if {$suspendhandle == $handle} {
notice $nick "I don't think suspending you is such a good idea."
return 0
}
if {![validuser $suspendhandle]} {
notice $nick "$misc1 is not a valid user."
return 0
}
if {![checkaccess $handle $chan $suspendhandle]} {
notice $nick "You don't got enough access to suspend $misc1"
return 0
}
foreach checkchan [channels] {
if {[handonchan $suspendhandle $checkchan]} {
set suspendnick [hand2nick $suspendhandle $checkchan]
notice $suspendnick "Your access on me ($botnick) have been suspended by $nick."
notice $nick "$suspendnick ($suspendhandle) is now suspended on $botnick."
setuser $suspendhandle XTRA "suspend" "[clock seconds] $nick $misc2end"
chattr $suspendhandle +Z-Lpx
save
set idx [hand2idx $suspendhandle]
if {$idx != "-1"} {
killdcc $idx
}
return 0
}
}
notice $nick "$suspendhandle is now suspended on $botnick."
setuser $suspendhandle XTRA "suspend" "[clock seconds] $nick $misc2end"
chattr $suspendhandle +Z-Lpx
save
set idx [hand2idx $suspendhandle]
if {$idx != "-1"} {
killdcc $idx
}
return 0
}
### unsuspend proc
proc call_unsuspend {nick handle chan misc1} {
global botnick if {$misc1 == ""} {
notice $nick "Usage: (/msg) $botnick unsuspend (#channel) <nick | handle>"
return 0
}
if {[string tolower $misc1] == "me"} {
notice $nick "You're not suspended."
return 0
}
if {[onchan $misc1 $chan]} {
set unsuspendhandle [nick2hand $misc1 $chan]
} else {
set unsuspendhandle $misc1
}
if {$unsuspendhandle == $handle} {
notice $nick "You're not suspended."
return 0
}
if {![validuser $unsuspendhandle]} {
notice $nick "$misc1 is not a valid user."
return 0
}
foreach checkchan [channels] {
if {[handonchan $unsuspendhandle $checkchan]} {
set unsuspendnick [hand2nick $unsuspendhandle $checkchan]
notice $unsuspendnick "Your access on me ($botnick) have been unsuspended by $nick."
notice $nick "$unsuspendnick (Handle: $unsuspendhandle) is now unsuspended on $botnick."
chattr $unsuspendhandle -Z+px
save
return 0
}
}
notice $nick "$unsuspendhandle is now unsuspended on $botnick."
chattr $unsuspendhandle -Z+px
save
return 0
}
### die proc
proc call_die {nick misc1end} {
global home
msg $home "I know when I'm not wanted (Die Command by $nick)"
if {$misc1end == ""} {
putquick "QUIT :Die by $nick"
} else {
putquick "QUIT :$misc1end (Die by $nick)"
}
putlog "DIE command issued by $nick: $misc1end"
foreach a [userlist] {chattr $a -L}
# Log everyone out before dying
save
die $misc1end
return 0
}
### addmask proc
proc call_addmask {nick hand chan misc1 misc2} {
global numversion
if {$misc2 == ""} {
notice $nick "I need a mask or nick to add to $misc1!"
return 0
}
set strict 0
if {[string index $misc2 0] == "!"} {
set misc2 [string range $misc2 1 end]
set strict 1
}
set nh [nick2hand $misc1 $chan]
set hn [hand2nick $misc1 $chan]
if {![matchattr $hand n] && [matchattr $nh o]} {
notice $nick "You don't have global access\; you can't addmask someone with global access!"
return 0
}
if {![matchattr $hand n] && ![matchattr $nh &f $chan]} {
notice $nick "$misc1 doesn't even have access here!"
return 0
}
if {![checkaccess $hand $chan $nh]} {
notice $nick "You don't have access to do that to $misc1!"
return 0
}
if {([validuser $nh] || $hn != "")} {
notice $nick "$misc1 already has a valid mask as $hn!"
return 0
}
if {![string match "*!*@*" $misc2] && ![onchan $misc2 $chan]} {
notice $nick "Invalid mask. Use format: *!*@*"
return 0
}
if {![string match "*!*@*" $misc2]} {
if {![onchan $misc2 $chan]} {
notice $nick "I can't add $misc2's mask to $misc1 because $misc2 isn't on $chan!"
return 0
}
set addhost [getchanhost $misc2 $chan]
if {$strict == 0} {
set addhost [maskhost "*$addhost"]
} else {
if {[string index $addhost 0] == "~"} {set addhost "*[string range $addhost 1 end]"}
set addhost "*!$addhost"
}
set misc2 $addhost
}
setuser $misc1 HOSTS $misc2
notice $nick "$misc2 added to $misc1."
save
return 1
}
### Remmask proc
proc call_remmask {nick hand chan misc1 misc2} {
if {$misc2 == ""} {
notice $nick "I need a mask to remove from $misc1!"
return 0
}
if {![validuser $misc1]} {
notice $nick "$misc1 isn't a known user."
return 0
}
if {![string match "*!*@*" $misc2]} {
notice $nick "Invalid mask. Use format: *!*@*"
return 0
}
set nh [nick2hand $misc1 $chan]
set hn [hand2nick $misc1 $chan]
if {![matchattr $hand n] && [matchattr $nh o]} {
notice $nick "You don't have global access\; you can't addmask someone with global access!"
return 0
}
if {![matchattr $hand n] && ![matchattr $nh &f $chan]} {
notice $nick "$misc1 doesn't even have access here!"
return 0
}
if {![checkaccess $hand $chan $nh]} {
notice $nick "You don't have access to do that to $misc1!"
return 0
}
if {[delhost $misc1 $misc2]} {
notice $nick "$misc2 was removed from $misc1."
} else {
notice $nick "No such mask on $misc1."
return 0
}
return 1
}
### Send proc
proc call_send {nick uhost handle chan arg} {
global botnick bnick hold
set arg [l1e [join $hold]]
set hold ""
if {[lindex $arg 1] == ""} {
notice $nick "I need to know what to send to whom, you putz!"
return 0
}
set bot [lindex $arg 0]
set bmess [lrange $arg 1 end]
if {([string tolower $bot] == [string tolower $botnick]) || ([string tolower $bot] == [string tolower $bnick])} {
notice $nick "Why can't you just tell me directly?"
return 0
}
if {[lsearch -glob [string tolower [bots]] [string tolower $bot]] == -1} {
notice $nick "I hope $bot isn't a bot that belongs in the botnet, 'cuz $bot ain't there!"
return 0
}
set bmessage "$nick $uhost $handle $chan $bmess"
putlog "Sending message to $bot: $bmess"
putbot $bot "send $bmessage"
notice $nick "Message sent to $bot: $bmess"
return 1
}
### Xsend proc
proc call_xsend {nick uhost handle chan arg} {
set arg [join $arg]
global botnick botnick bnick hold
set hold ""
set arg [join $arg]
if {[lindex $arg 0] == ""} {
notice $nick "I need to know what to send, you putz!"
return 0
}
set bmess $arg
set bmessage "$nick $uhost $handle $chan $bmess"
putlog "Sending message to all bots: $bmess"
putallbots "send $bmessage"
notice $nick "Message sent to all bots: $bmess"
bsend $botnick "send" $bmessage
# This is so the bot itself will also execute the command.
return 1
}
####################
### End of procs ###
####################
foreach i [timers] {
if {[lindex $i 1] == "do_timestat"} {
killtimer [lindex $i 2]
}
}
# Time stats
timer 1 do_timestat
proc do_timestat {} {
foreach i [channels] {
set ulist ""
foreach j [chanlist $i] {
if {[matchattr [nick2hand $j $i] +fvoHmn|+fvoHmn $i] && ![matchattr [nick2hand $j $i] +b]} {
set handle [nick2hand $j $i]
set clone 0
foreach k $ulist {
if {$k == $handle} {
set clone 1
break
}
}
lappend ulist $handle
if {!($clone)} {
if {[getuser $handle XTRA "stat.[string tolower $i]"] == ""} {
setdefaultstats $handle $i
}
set stats [getuser $handle XTRA "stat.[string tolower $i]"]
set time [lindex $stats 0]
set days [lindex $time 1]
set hours [lindex $time 2]
set time [lreplace $time 0 0 [expr 1 + [lindex $time 0]]]
set today [lindex [ctime [clock seconds]] 0]
if {$today == "Mon"} {
set days [lreplace $days 0 0 [expr 1 + [lindex $days 0]]]
} elseif {$today == "Tue"} {
set days [lreplace $days 1 1 [expr 1 + [lindex $days 1]]]
} elseif {$today == "Wed"} {
set days [lreplace $days 2 2 [expr 1 + [lindex $days 2]]]
} elseif {$today == "Thu"} {
set days [lreplace $days 3 3 [expr 1 + [lindex $days 3]]]
} elseif {$today == "Fri"} {
set days [lreplace $days 4 4 [expr 1 + [lindex $days 4]]]
} elseif {$today == "Sat"} {
set days [lreplace $days 5 5 [expr 1 + [lindex $days 5]]]
} else {
set days [lreplace $days 6 6 [expr 1 + [lindex $days 6]]]
}
set time [lreplace $time 1 1 $days]
set h [lindex [split [currtime] :] 0]
if {[string index $h 0] == 0} {
set h [string index $h 1]
}
set hours [lreplace $hours $h $h [expr 1 + [lindex $hours $h]]]
set time [lreplace $time 2 2 $hours]
set stats [lreplace $stats 0 0 $time]
setuser $handle XTRA "stat.[string tolower $i]" $stats
}
}
}
}
timer 1 do_timestat
return 0
}
# Talk stats
bind pubm - * do_talkstat
proc do_talkstat {nick uhost handle channel arg} {
if {[matchattr $handle +fvoHmn|+fvoHmn $channel] && ![matchattr $handle +b]} {
if {[getuser $handle XTRA "stat.[string tolower $channel]"] == ""} {
setdefaultstats $handle $channel
}
set stats [getuser $handle XTRA "stat.[string tolower $channel]"]
set talk [lindex $stats 1]
set days [lindex $talk 1]
set hours [lindex $talk 2]
set talk [lreplace $talk 0 0 [expr [string length $arg] + [lindex $talk 0]]]
set today [lindex [ctime [clock seconds]] 0]
if {$today == "Mon"} {
set days [lreplace $days 0 0 [expr [string length $arg] + [lindex $days 0]]]
} elseif {$today == "Tue"} {
set days [lreplace $days 1 1 [expr [string length $arg] + [lindex $days 1]]]
} elseif {$today == "Wed"} {
set days [lreplace $days 2 2 [expr [string length $arg] + [lindex $days 2]]]
} elseif {$today == "Thu"} {
set days [lreplace $days 3 3 [expr [string length $arg] + [lindex $days 3]]]
} elseif {$today == "Fri"} {
set days [lreplace $days 4 4 [expr [string length $arg] + [lindex $days 4]]]
} elseif {$today == "Sat"} {
set days [lreplace $days 5 5 [expr [string length $arg] + [lindex $days 5]]]
} else {
set days [lreplace $days 6 6 [expr [string length $arg] + [lindex $days 6]]]
}
set talk [lreplace $talk 1 1 $days]
set h [lindex [split [currtime] :] 0]
if {[string index $h 0] == 0} {
set h [string index $h 1]
}
set hours [lreplace $hours $h $h [expr [string length $arg] + [lindex $hours $h]]]
set talk [lreplace $talk 2 2 $hours]
set stats [lreplace $stats 1 1 $talk]
setuser $handle XTRA "stat.[string tolower $channel]" $stats
}
return 0
}
# Join stats
bind join - * do_joinstat
proc do_joinstat {nick uhost handle channel} {
if {[matchattr $handle +fvoHmn|+fvoHmn $channel]} {
if {[getuser $handle XTRA "stat.[string tolower $channel]"] == ""} {
setdefaultstats $handle $channel
}
set stats [getuser $handle XTRA "stat.[string tolower $channel]"]
set stats [lreplace $stats 2 2 [expr 1 + [lindex $stats 2]]]
setuser $handle XTRA "stat.[string tolower $channel]" $stats
}
return 0
}
proc setdefaultstats {handle chan} {
set def [list {0 {0 0 0 0 0 0 0} {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}} {0 {0 0 0 0 0 0 0} {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}} 1]
lappend def [clock seconds]
setuser $handle XTRA "stat.[string tolower $chan]" $def
return 0
}
# Sort procs
proc compare {one two} {
if {[lindex $one 0] > [lindex $two 0]} {
return 1
} elseif {[lindex $one 0] < [lindex $two 0]} {
return -1
} else {
return 0
}
}
proc sort_time {chan} {
set foolist ""
foreach i [userlist +fvoHmn|+fvoHmn $chan] {
set foo "[lindex [lindex [getuser $i XTRA "stat.[string tolower $chan]"] 0] 0] $i"
if {($i != "*ban") && ($foo != " $i") && ![matchattr $i b]} {
lappend foolist $foo
}
}
return [lsort -decreasing -command compare $foolist]
}
proc sort_talk {chan} {
set foolist ""
foreach i [userlist +fvoHmn|+fvoHmn $chan] {
set foo "[lindex [lindex [getuser $i XTRA "stat.[string tolower $chan]"] 1] 0] $i"
if {($i != "*ban") && ($foo != " $i") && ![matchattr $i b]} {
lappend foolist $foo
}
}
return [lsort -decreasing -command compare $foolist]
}
proc sort_join {chan} {
set foolist ""
foreach i [userlist +fvoHmn|+fvoHmn $chan] {
set foo "[lindex [getuser $i XTRA "stat.[string tolower $chan]"] 2] $i"
if {($i != "*ban") && ($foo != " $i") && ![matchattr $i b]} {
lappend foolist $foo
}
}
return [lsort -decreasing -command compare $foolist]
}
# For the call_ping proc
bind ctcr - PING lag_reply
proc lag_reply {nick host handle destination key misc} {
global home
if {$key == "PING"} {
if {!([string match "1*" $misc] || [string match "9*" $misc])} {
# notice $nick "We found that one, dumb fuck!"
# newignore "[maskhost *$host]" "Anti-Hack" "Trying to CTCP hack me!" 43200
# putlog "$nick ($host) (Handle: $handle) just tried a CTCP hack! Auto-ignored for 30 days!"
# msg $home "$nick ($host) (Handle: $handle) just tried a CTCP hack! Auto-ignored for 30 days!"
# return 0
}
set l [string length $misc]
set c 0
set flag ""
while {$c < $l} {
if {![string match "*[string range $misc $c $c]*" "+-0123456789"]} {set flag "*"}
incr c
}
if {$flag == "*"} {
notice $nick "We found that one, dumb fuck!"
newignore "[maskhost *$host]" "Anti-Hack" "Trying to CTCP hack me!" 43200
putlog "$nick ($host) (Handle: $handle) just tried a CTCP hack! Auto-ignored for 30 days!"
msg $home "$nick ($host) (Handle: $handle) just tried a CTCP hack! Auto-ignored for 30 days!"
return 0
}
set endd [clock seconds]
set lagg [expr $endd - $misc]
if {$lagg > "30"} {
notice $nick "Your lagged pretty bad. Switch Servers. Ping Reply: $lagg!"
putlog "$nick is lagged by $lagg secs."
return 1
}
if {$lagg > "15"} {
notice $nick "Your lagged, but not to bad. Ping Reply: $lagg"
putlog "$nick is lagged by $lagg secs."
return 1
}
if {$lagg < "0"} {
notice $nick "Don't send me false PING information you dork!"
putlog "Fake ping sent by $nick."
return 1
}
notice $nick "Your Not that lagged. Ping Reply: $lagg "
putlog "$nick is lagged by $lagg secs."
return 1
}
}
proc check_ctcr_hack {misc} {
set l [string length $misc]
set c 0
set flag 0
while {$c < $l} {
if {![string match "*[string index $misc $c]*" "+-/0123456789.()"]} {set flag 1}
incr c
}
return "$flag"
}
### Check Access ###
proc checkaccess {handle chan chkhandle} {
if {[matchattr $handle n]} {return 1}
if {[matchattr $handle m]} {
if {[matchattr $chkhandle n]} {return 0}
if {[matchattr $chkhandle m]} {return 0}
return 1
}
if {[matchattr $handle o]} {
if {[matchattr $chkhandle n]} {return 0}
if {[matchattr $chkhandle m]} {return 0}
if {[matchattr $chkhandle o]} {return 0}
if {[matchattr $chkhandle |n $chan]} {return 0}
if {[matchattr $chkhandle |m $chan]} {return 0}
return 1
}
if {[matchattr $handle |n $chan]} {
if {[matchattr $chkhandle n]} {return 0}
if {[matchattr $chkhandle m]} {return 0}
if {[matchattr $chkhandle o]} {return 0}
return 1
}
if {[matchattr $handle |m $chan]} {
if {[matchattr $chkhandle n]} {return 0}
if {[matchattr $chkhandle m]} {return 0}
if {[matchattr $chkhandle o]} {return 0}
if {[matchattr $chkhandle |n $chan]} {return 0}
if {[matchattr $chkhandle |m $chan]} {return 0}
return 1
}
if {[matchattr $handle |o $chan]} {
if {[matchattr $chkhandle n]} {return 0}
if {[matchattr $chkhandle m]} {return 0}
if {[matchattr $chkhandle o]} {return 0}
if {[matchattr $chkhandle |n $chan]} {return 0}
if {[matchattr $chkhandle |m $chan]} {return 0}
if {[matchattr $chkhandle |o $chan]} {return 0}
return 1
}
return 0
}
proc checkglobalaccess {handle chkhandle} {
if {[matchattr $handle n]} {return 1}
if {[matchattr $handle m]} {
if {[matchattr $chkhandle n]} {return 0}
if {[matchattr $chkhandle m]} {return 0}
return 1
}
if {[matchattr $handle o]} {
if {[matchattr $chkhandle n]} {return 0}
if {[matchattr $chkhandle m]} {return 0}
if {[matchattr $chkhandle o]} {return 0}
return 1
}
return 0
}
proc checkchanaccess {handle channel chkhandle} {
if {[matchattr $handle |n $channel]} {return 1}
if {[matchattr $handle |m $channel]} {
if {[matchattr $chkhandle |n $channel]} {return 0}
if {[matchattr $chkhandle |m $channel]} {return 0}
return 1
}
if {[matchattr $handle |o $channel]} {
if {[matchattr $chkhandle |n $channel]} {return 0}
if {[matchattr $chkhandle |m $channel]} {return 0}
if {[matchattr $chkhandle |o $channel]} {return 0}
return 1
}
return 0
}
proc checkbot {chkbothandle} {return "[matchattr $chkbothandle b]"}
proc level {wnick handle} {
global home ownername mastername techname opname halfopname voicename homechanopname groupname
if {![matchattr $handle o] && [matchattr $handle |o $home]} {set level $homechanopname}
if {[matchattr $handle v]} {set level $voicename}
if {[matchattr $handle Hl]} {set level $halfopname}
if {[matchattr $handle o]} {
set level $opname
set an "an"
}
if {[matchattr $handle t]} {set level $techname}
if {[matchattr $handle m]} {set level $mastername}
if {[matchattr $handle n]} {
set level $ownername
set an "an"
}
if {[matchattr $handle N]} {
set level $ownername
set an "an"
}
if {[matchattr $handle M]} {set level $mastername}
if {[matchattr $handle T]} {set level $mastername}
if {[matchattr $handle O]} {
set level $opname
set an "an"
}
if {[matchattr $handle H]} {set level $halfopname}
if {[matchattr $handle V]} {set level $voicename}
if {[matchattr $handle C]} {set level $homechanopname}
if {[matchattr $handle b] || [matchattr $wnick b]} {set level "bot"}
return 0
}
proc onjoin_account {chan} {
# To be depricated/removed in SBC1.1
global botnick bnick owner altnick stormver nick
if {![validuser $bnick]} {
set mh "*$nick[maskhost *[getchanhost $botnick $chan]]"
set mha "*$altnick[maskhost *[getchanhost $botnick $chan]]"
set address "Stormbot:99999"
addbot $bnick $address
setuser $bnick HOSTS $mh
setuser $bnick HOSTS $mha
setuser $bnick XTRA "version" "$stormver"
setuser $bnick PASS "[encrypt [rand 999999999] [rand 999999999]]"
chattr $bnick +n
setuser $bnick COMMENT "Do not delete me! I'm a STORMBOT maintenance file!"
putlog "Automatically added \"$bnick\" for STORMBOT maintenance."
save
}
return 1
}
#Enter CT with: [ct TIME-TO-REFORMAT]
proc ct {a {b 0}} {global timezone; set val "[lindex $a 0], [lrange $a 1 2], [lindex $a 4] at [lindex $a 3] [lindex $timezone [expr !($b)]]"; return $val}
#Enter CTC with: ctc OFFSET-TO-CURRENT-TIME
proc ctc {a} { if {[check_ctcr_hack $a]} {return 1} else {return "[ct [ctime [expr [clock seconds] - $a]]]"} }
#Enter CTU with: ctu UNIXTIME (or UNIXTIME w/offset already calculated)
proc ctu {a} {return "[ct [ctime $a]]"}
#Enter CTV with: ctv UNIXTIME OFFSET
proc ctv {a b} { if {[check_ctcr_hack $a]} {return 1} else {return "[ct [ctime [expr $a - $b]]]"} }
#Enter CTP with: [ctp]; this will use the CURRENT UNIXTIME automatically
proc ctp { } {return "[ct [ctime [clock seconds]]]"}
proc currtime { } {return "[clock format [clock seconds] -format "%H:%M"]"}
proc currdate { } {return "[clock format [clock seconds] -format "%d %b %Y"]"}
proc app {var text} {
if {$var != ""} {append var ", "}
append var $text; return "$var"}
proc nopwset {nick hand} {
global botnick home groupname
if {![passwdok $hand ""]} {return 0}
notice $nick "You don't have a password set yet! You won't get very far until you fix this!"
notice $nick "/msg $botnick PASS <password>"
if {[matchattr $hand vo]} {
privmsg "notice $nick "You're being suspended since you're a $groupname representative. See any ADMIN to fix this."
chattr $hand +ZW; return 1
}
set c ""; foreach a [channels] { if {[matchattr $hand &n $a]} {lappend c $a} }
if {$c != ""} {
privmsg "notice $nick "Because you are listed as a channel owner for [join $c ", "]."
privmsg "notice $nick "You will be suspended until you can verify your identity."
privmsg "notice $nick "See any BService ADMIN for assistance with this."
chattr $hand +ZW
}
return 1
}
proc nozero {a} {
while {[string index $a 0] == "0"} {set a [string range $a 1 end]}
if {$a == ""} {set a 0}
return "$a"
}
proc findchan {a} {
global home
foreach chan [channels] {
if {[onchan $a $chan]} {return "$a [nick2hand $a $chan] $chan"}
if {[handonchan $a $chan]} {return "[hand2nick $a $chan] $a $chan"}
}
return ""
}
proc isauthed {nick handle} {
set a 0; if {[matchattr $handle L] && ([getuser $handle XTRA "AUTH"] == $nick)} {set a 1}
return "$a"
}
proc chkaccess {nick handle flag {chan ""}} {
global botnick home mastername ownername groupname
if {![isauthed $nick $handle]} {notice $nick "Who are you? Did you Login? (/msg $botnick LOGIN <password>)"; return 1}
if {[matchattr $handle Z]} {notice $nick "Your access is suspended, please talk to a $mastername or $ownername for $groupname."; return 2}
if {($flag != "") && ($chan == "")} {set chan $home}
if {($flag != "") && ($chan != "")} {
if {[matchattr $handle $flag]} {return 0}; # If global flags match....
set cflag [lindex [split $flag "|"] 1]
if {$chan != "" && [matchattr $handle |$cflag $chan]} {return 0}
}
notice $nick "Negative on that, Houston. For help: (/msg) $botnick help (#channel)"
return 3
}
proc msg {a b} {putquick "privmsg $a :$b"}
proc notice {a b} {putquick "notice $a :$b"}
proc ktm {crap} {
foreach a [timers] { if {[sl1 $a] == [stl $crap] || [string match "*[stl $crap]*" [sl1 $a]]} {killtimer [l2 $a]; putlog "[l2 $a] ([l1 $a]) killed."} }
foreach a [utimers] { if {[sl1 $a] == [stl $crap] || [string match "*[stl $crap]*" [sl1 $a]]} {killutimer [l2 $a]; putlog "u[l2 $a] ([l1 $a]) killed."} }
}
#############################################################################
# Crossover PROCs
proc stl {a} {return "[string tolower $a]"}
proc stu {a} {return "[string toupper $a]"}
proc stt {a} {return "[string totitle $a]"}
proc l0 {a} {return "[lindex $a 0]"}
proc l1 {a} {return "[lindex $a 1]"}
proc l2 {a} {return "[lindex $a 2]"}
proc l3 {a} {return "[lindex $a 3]"}
proc l4 {a} {return "[lindex $a 4]"}
proc l5 {a} {return "[lindex $a 5]"}
proc l1e {a} {return "[lrange $a 1 end]"}
proc l2e {a} {return "[lrange $a 2 end]"}
proc l3e {a} {return "[lrange $a 3 end]"}
proc l4e {a} {return "[lrange $a 4 end]"}
proc l5e {a} {return "[lrange $a 5 end]"}
proc sl0 {a} {return "[stl [l0 $a]]"}
proc sl1 {a} {return "[stl [l1 $a]]"}
proc sl2 {a} {return "[stl [l2 $a]]"}
proc sl3 {a} {return "[stl [l3 $a]]"}
proc sl4 {a} {return "[stl [l4 $a]]"}
proc sl5 {a} {return "[stl [l5 $a]]"}
proc s1e {a} {return "[stl [l1e $a]]"}
proc s2e {a} {return "[stl [l2e $a]]"}
proc s3e {a} {return "[stl [l3e $a]]"}
proc s4e {a} {return "[stl [l4e $a]]"}
proc s5e {a} {return "[stl [l5e $a]]"}
proc bnick {a} {
global bnickdata; set a [stl $a]
if ![info exists bnickdata($a)] {return ""}
return "$bnickdata($a)"
}
proc setbnick {a {b ""}} {
global bnickdata; set a [stl $a]
set bnickdata($a) $b
if {$b == ""} {unset bnickdata($a)}
return "$b"
}
proc writedata { } {
global bnickdata botdatafile
if ![info exists botdatafile] {return "-1"}
if {$botdatafile == ""} {return "-1"}
set r [open $botdatafile w]
foreach a [lsort [array names bnickdata]] {puts $r "[list $a $bnickdata($a)]"}
close $r
}
#############################################################################
# Ignore this ~ this is simply to allow future patch compatability.
if [file exists scripts/sbp-patch.tcl] { if {[source scripts/sbp-patch.tcl] == 5} {putlog "SB $stormver successfully updated!"} }
# The patch will check to fix the proper version of SB only; return "5" if
# okay, or "0" if incorrect version of SB to patch. No error messages will
# be displayed.
#############################################################################
putlog "StormBot ver. $stormver by Xone <xone@bothouse.org> and Domino Rose-Mystagic <domino@bothouse.org> Loaded!"
putlog "A BService Production (#Bothouse @ ChatNet)"
putlog "Bot responding to: '$nick', '$altnick' and '$shortcut.' "
IRC Snippets