chiark / gitweb /
New help scheme.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 5 Sep 2000 22:26:57 +0000 (22:26 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 5 Sep 2000 22:26:57 +0000 (22:26 +0000)
bot.tcl
helpinfos [new file with mode: 0644]

diff --git a/bot.tcl b/bot.tcl
index f17134479b3ef3a4cf04c0c150e8c1292ccb4845..f3db5c192e4d72643133fa4add1e3ae2f85bff52 100755 (executable)
--- a/bot.tcl
+++ b/bot.tcl
@@ -486,21 +486,45 @@ proc ucmdr {priv pub args} {
     return -code return [concat [list $priv $pub] $args]
 }
 
-proc ucmd_sendhelp {} {
-    ucmdr \
-{Commands currently understood:
- help              get this list of commands
- seen <nick>       ask after someone (I'll tell them you asked)
- summon <username> invite a logged-on user onto IRC
-Send commands to me by /msg, or say them in channel with ! in front.} {}
-#
-# register          register your nick (you must auth[*] first)
-#[*]auth: /blight in ircII, or /msg blight authuser <username> <pass>
+proc loadhelp {} {
+    global help_topics
+
+    catch { unset help_topics }
+    set f [open helpinfos r]
+    set lno 0
+    while {[gets $f l] >= 0} {
+       incr lno
+       if {[regexp {^#.*} $l]} {
+       } elseif {[regexp {^ *$} $l]} {
+           if {[info exists topic]} {
+               set help_topics($topic) [join $lines "\n"]
+               unset topic
+               unset lines
+           }
+       } 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]} {
+           set topic
+           lappend lines [string trimright $l]
+       } else {
+           error "eh ? $lno: $l"
+       }
+    }
+    if {[info exists topic]} { error "unfinished topic $topic" }
 }
 
-def_ucmd help { ta_nomore; ucmd_sendhelp }
+def_ucmd help {
+    upvar #0 help_topics([irctolower [string trim $text]]) info
+    if {![info exists info]} { error "no help on $text, sorry." {} }
+    ucmdr $info {}
+}
 
-def_ucmd ? { ta_nomore; ucmd_sendhelp }
+def_ucmd ? {
+    global help_topics
+    ucmdr $help_topics() {}
+}
 
 proc manyset {list args} {
     foreach val $list var $args {
@@ -597,6 +621,8 @@ if {![info exists sock]} {
     fileevent $sock readable onread
 }
 
+loadhelp
+
 #if {![regexp {tclsh} $argv0]} {
 #    vwait terminate
 #}
diff --git a/helpinfos b/helpinfos
new file mode 100644 (file)
index 0000000..09587fa
--- /dev/null
+++ b/helpinfos
@@ -0,0 +1,87 @@
+!
+General commands:           Registration and user settings:
+ help [<cmd>|<opt>|<topic>]  register [insecure|delete]
+ seen <nick>                 set [<opt> [<value>]]
+ summon <username>           (See `help identify'.)
+ convert <number> <unit>    Channel settings:
+ ops                         oplist [<chan>] [+|-|= [?]<nick> ...]
+Options:                    Additional help topics:
+ timeformat ks|hms           identify identpass invite
+Send commands to me by /msg, or say them in channel with ! in front.
+
+!help
+help             gives an overview and lists the topics &c
+help <command>   gives help on a command
+help <opt>       gives help on an option
+help <topic>     gives help on an additional topic
+
+!seen
+seen <nick>
+ Tells you or the channel when I last saw that nick in
+ use.  When the nick is next used, I'll tell them you asked.
+
+!summon
+summon <username>
+ Invites a logged-on user onto IRC.  If the user is not logged on
+ you'll be told.  Target users can change this (eg, to disable it)
+ by reconfiguring the userv service `irc-summon'.  See ~ian/.userv.
+
+!convert
+convert <number> <unit>
+ Converts the specified quantity into SI units.  Units that are
+ understood are any understood by units(1) and also
+   kelvin celsius fahrenheit    (convert to celsius or kelvin)
+
+!ops
+ops             on channel
+ops <channel>   (privately)
+ Asks me to give you channel operator privilege.  You must have
+ identified yourself (see `help identification').
+
+!oplist
+oplist [<chan>]                      show chop list
+oplist [<chan>] + <nick> <nick> ...  add nicks to chop list
+oplist [<chan>] - <nick> <nick> ...  remove nicks from chop list
+oplist [<chan>] = <nick> <nick> ...  set chop list
+ Configures the list of who may use the `ops' command.  You must be
+ on the oplist yourself to do this.  If you op me on a channel I'll
+ automatically add you to the oplist if you have identified yourself.
+
+!identify
+You must identify yourself to change your settings and to use channel
+management commands.  In ircII on chiark, just say `/blight-id'.  For
+other clients, see `help identpass'.  Once you are identified you can
+then register new nicks, change settings, etc. - so long as you
+remain on a channel that I'm on too.  (See also `help invite'.)
+
+!identpass
+identpass <username> <password>
+ Identification, for example with /blight-id, is actually done with
+ `identpass', which passes the md5sum of the password to `userv
+ <username> irc-identpass <nick>'.  That must exit 0 if all is well.
+
+!invite
+If you invite me to a channel I'll join it.
+
+!register
+register            register your nick (or make it secure)
+register delete     delete your nick registration
+register insecure   register your nick insecurely
+ I only store settings for registered nicks.  For `insecure' nicks
+ anyone who currently holds that nick can change its settings,
+ including securing it to their username.  `secure' nicks can only
+ have their settings changed by the user to which they are
+ registered, after identifying themselves (see `help identify').
+
+!set
+set                  show your current settings
+set <option>         show the current setting of <option>
+set <option> <value> set <option> to <value>
+ See also `help register' and `help ident'.  See just `help' for the
+ list of options, and `help <option>' for info about that option.
+
+!timeformat
+set timeformat ks   show times in seconds, kiloseconds, etc.
+set timeformat hms  use days, hours, minutes, seconds
+
+#