diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2016-10-27 19:39:39 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2016-10-27 19:39:39 (GMT) |
commit | ea28451286d3ea4a772fa174483f9a7a66bb1ab3 (patch) | |
tree | 6ee9d8a7848333a7ceeee3b13d492e40225f8b86 /tcllib/examples/irc | |
parent | b5ca09bae0d6a1edce939eea03594dd56383f2c8 (diff) | |
parent | 7c621da28f07e449ad90c387344f07a453927569 (diff) | |
download | blt-ea28451286d3ea4a772fa174483f9a7a66bb1ab3.zip blt-ea28451286d3ea4a772fa174483f9a7a66bb1ab3.tar.gz blt-ea28451286d3ea4a772fa174483f9a7a66bb1ab3.tar.bz2 |
Merge commit '7c621da28f07e449ad90c387344f07a453927569' as 'tcllib'
Diffstat (limited to 'tcllib/examples/irc')
-rw-r--r-- | tcllib/examples/irc/ChangeLog | 29 | ||||
-rwxr-xr-x | tcllib/examples/irc/irc_example.tcl | 30 | ||||
-rw-r--r-- | tcllib/examples/irc/mainloop.tcl | 51 |
3 files changed, 110 insertions, 0 deletions
diff --git a/tcllib/examples/irc/ChangeLog b/tcllib/examples/irc/ChangeLog new file mode 100644 index 0000000..8e7929c --- /dev/null +++ b/tcllib/examples/irc/ChangeLog @@ -0,0 +1,29 @@ +2004-09-23 Andreas Kupries <andreas_kupries@users.sourceforge.net> + + * mainloop.tcl: Fixed expr without braces. + +2003-06-30 David N. Welton <davidw@dedasys.com> + + * irc_example.tcl: Rework this file to reload mainloop.tcl as + needs be. + + * mainloop.tcl: New file: the main code is in here, in order to + facilitate creating a system that is reloadable. + +2003-05-17 David N. Welton <davidw@dedasys.com> + + * irc_example.tcl: Changes from Aaron Faupell - now uses irc 0.4. + Use ircclient namespace instead of previous, overly generic + 'client'. + +2003-05-05 Andreas Kupries <andreas_kupries@users.sourceforge.net> + + * + * Released and tagged Tcllib 1.4 ======================== + * + +2003-01-30 David N. Welton <davidw@dedasys.com> + + * irc_example.tcl (client::connect): Added some more comments, + change the startup features. Create ChangeLog. + diff --git a/tcllib/examples/irc/irc_example.tcl b/tcllib/examples/irc/irc_example.tcl new file mode 100755 index 0000000..a1735ed --- /dev/null +++ b/tcllib/examples/irc/irc_example.tcl @@ -0,0 +1,30 @@ +#!/usr/bin/env tclsh +## -*- tcl -*- + +# irc example script, by David N. Welton <davidw@dedasys.com> +# $Id: irc_example.tcl,v 1.10 2009/01/30 04:18:14 andreas_kupries Exp $ + +set scriptDir [file dirname [info script]] +package require irc 0.4 + +namespace eval ircclient { + variable channel \#tcl + + # Pick up a nick from the command line, or default to TclIrc. + if { [lindex $::argv 0] != "" } { + set nick [lindex $::argv 0] + } else { + set nick TclIrc + } + + set cn [::irc::connection] + # Connect to the server. + $cn connect irc.freenode.net 6667 + $cn user $nick localhost domain "www.tcl.tk" + $cn nick $nick + while { 1 } { + source [file join $::scriptDir mainloop.tcl] + vwait ::ircclient::RELOAD + } +} + diff --git a/tcllib/examples/irc/mainloop.tcl b/tcllib/examples/irc/mainloop.tcl new file mode 100644 index 0000000..70c7215 --- /dev/null +++ b/tcllib/examples/irc/mainloop.tcl @@ -0,0 +1,51 @@ +# Main body of code. + +puts -nonewline "Loading [info script] ..." + +# $cn connect irc.freenode.net 6667 +$cn registerevent 001 "$cn join $channel" + +# Register a default action for commands from the server. +$cn registerevent defaultcmd { + puts "[action] [msg]" +} + +# Register a default action for numeric events from the server. +$cn registerevent defaultnumeric { + puts "[action] XXX [target] XXX [msg]" +} + +# Register a default action for events. +$cn registerevent defaultevent { + puts "[action] XXX [who] XXX [target] XXX [msg]" +} + +# Register a default action for PRIVMSG (either public or to a +# channel). + +$cn registerevent PRIVMSG { + puts "[who] says to [target] [msg]" +} + +# If you uncomment this, you can change this file and reload it +# without shutting down the network connection. + +if {0} { + $cn registerevent PRIVMSG { + puts "[who] says to [target] [msg]" + if { [msg] == "RELOAD" && [target] == $::ircclient::nick } { + if [catch { + ::irc::reload + } err] { + puts "Error: $err" + } + set ::ircclient::RELOAD 1 + } + } +} + +$cn registerevent KICK { + puts "[who] KICKed [target] : [msg]" +} + +puts " done" |