}
proc loadhelp {} {
- global help_topics
+ global help_topics errorInfo
catch { unset help_topics }
set f [open helpinfos r]
unset topic
unset lines
}
- } elseif {[regexp {^!([-+._0-9a-z]*)$} $l dummy newtopic]} {
+ } elseif {[regexp {^\:\:} $l]} {
+ } elseif {[regexp {^\:([-+._0-9a-z]*)$} $l dummy newtopic]} {
if {[info exists topic]} {
error "help $newtopic while in $topic"
}
set topic $newtopic
set lines {}
- } elseif {[regexp {^[^!#]} $l]} {
+ } elseif {[regexp {^[^:#]} $l]} {
set topic
+ regsub -all {([^\\])\!\$?} _$l {\1} l
+ regsub -all {\\(.)} $l {\1} l
+ regsub {^_} $l {} l
lappend lines [string trimright $l]
} else {
error "eh ? $lno: $l"
}
}
if {[info exists topic]} { error "unfinished topic $topic" }
- } {} {
+ } {
+ set errorInfo "in helpinfos line $lno\n$errorInfo"
+ } {
close $f
}
}
}
set default_settings_nick {timeformat ks}
-set default_settings_chan {autojoin 1 mode *}
+set default_settings_chan {autojoin 1 mode * userinvite pub}
def_somedb_id set {args} {
upvar #0 default_settings_$nickchan def
"I won't join #chan when I'm restarted "}] {}
}
+def_chancmd userinvite {
+ set nv [string tolower [ta_word]]
+ switch -exact $nv {
+ pub { set txt "!invite will work for $chan, but it won't work by /msg" }
+ here { set txt "!invite and /msg invite will work, but only for users who are already on $chan." }
+ all { set txt "Any user will be able to invite themselves or anyone else to $chan." }
+ none { set txt "I will not invite anyone to $chan." }
+ default {
+ error "channel userinvite must be `pub', `here', `all' or `none'
+ }
+ }
+ chandb_set $chan userinvite $nv
+ ucmdr $txt {}
+}
+
def_chancmd mode {
set mode [ta_word]
if {"$mode" != "*" && ![regexp {^(([-+][imnpst]+)+)$} $mode mode]} {
sendout MODE $target +o $n
}
+def_ucmd invite {
+ global chan_nicks
+
+ if {[ischan $dest]} {
+ set target $dest
+ set onchan 1
+ } else {
+ set target [ta_word]
+ set onchan 0
+ }
+ set ltarget [irctolower $target]
+ if {![ischan $target]} { error "$target is not a channel." }
+ if {![info exists chan_nicks($ltarget)]} { error "I am not on $target." }
+ set ui [chandb_get $ltarget userinvite]
+ if {"$ui" == "pub" && !$onchan} {
+ error "Invitations to $target must be made with !invite."
+ }
+ if {"$ui" != "all"} {
+ prefix_nick
+ if {[lsearch -exact $chan_nicks($ltarget) [irctolower $n]] < 0} {
+ error "Invitations to $target may only be made by a user on the channel."
+ }
+ }
+ if {"$ui" == "none"} {
+ error "Sorry, I've not been authorised to invite people to $target."
+ }
+ if {![ta_anymore]} {
+ error "You have to say who to invite."
+ }
+ set invitees {}
+ while {[ta_anymore]} {
+ set invitee [ta_word]
+ check_nick $invitee
+ lappend invitees $invitee
+ }
+ foreach invitee $invitees {
+ sendout INVITE $invitee $ltarget
+ }
+ set who [lindex $invitees 0]
+ switch -exact llength $invitees {
+ 0 { error "zero invitees" }
+ 1 { }
+ 2 { append who " and [lindex $invitees 1]" }
+ * {
+ set who [join [lreplace $invitees end end] ", "]
+ append who " and [lindex $invitees [llength $invitees]]"
+ }
+ }
+ ucmdr {} "invites $who to $target."
+}
+
def_ucmd channel {
if {[ischan $dest]} { set target $dest }
if {![ta_anymore]} {