IRC

From Gwen Morse's Wiki
Jump to: navigation, search
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 
;;; TF-IRC
;;; 
;;; A bunch of TinyFugue scripts to let you IRC using the TinyFugue MUD
;;; client.
;;; 
;;; 
;;; INSTALLING
;;; ==========
;;;    
;;;    1.  Create a directory named .tf in your home directory.
;;; 
;;;    2.  Copy 'irc', 'irc.watch' and 'irc.dcc' to that directory.
;;; 
;;;    3.  Add a line like this to your .tfrc to load them into TF:
;;;          /load -q ~/.tf/irc
;;; 
;;;    4.  Define your IRC worlds like this in your .tfrc:
;;;          /addworld -T"irc" efnet         efnet.telstra.net.au 6667
;;;          /addworld -T"irc" oznet         aussie.oz.org        6667
;;;          /addworld -T"irc" undernet      us.undernet.org      6667
;;;        You can define as many IRC worlds as you like, as long as you
;;;        set them all to type "irc".
;;; 
;;;    5.  At the top of the file 'irc' there are a bunch of variables
;;;        you can define, like your IRC nickname, realname, etc.
;;; 
;;; 
;;; BUGS
;;; ====
;;; I don't think dcc works at the moment.  The watch stuff definately
;;; doesn't work.  I'm getting there!  This is just a minor project.
;;; 
;;; 
;;; OTHER STUFF
;;; ===========
;;; 
;;; I can be contact at <gossamer at tertius dot net dot au>.
;;; 
;;; Much of my code is available on the web, look for the latest
;;; release of things at:
;;;    http://www.tertius.net.au/~gossamer/code/
;;; 
;;; 
;;; LEGAL STUFF
;;; ===========
;;; 
;;; Copyright (c) 1998 Bek Oberin. All rights reserved. 
;;; 
;;; This package is free software; you can redistribute it and/or modify
;;; it under the same terms as Perl itself.


;;;;;; IRC "Worlds"

/addworld -T"irc.irc" efnet         efnet.telstra.net.au            6667
/addworld -T"irc.irc" oznet         aussie.oz.org                   6667
/addworld -T"irc.irc" undernet      us.undernet.org                 6667
/addworld -T"irc.irc" teambg        irc.teambg.net                  6667
/addworld -T"irc.irc" fwp           irc.gamesnet.net                6667
/addworld -T"irc.irc" fedora        tolkien.freenode.net            6667
/addworld -T"irc.irc" nitdroid      chat.freenode.net               6667
/addworld -T"irc.irc" meego-arm     irc.freenode.net                6667
/addworld -T"irc.irc" blinkenshell  irc.blinkenshell.org            6697

;; /SERVER ADD -ssl -auto -network BlinkenIRC irc.blinkenshell.org 6697
;; /CHANNEL ADD -auto #blinkenshell BlinkenIRC


;;; Small syntax fixes by Gwen Morse

; TF-IRC
; IRC handler for TinyFugue.
;
; Last updated by gossamer on Thu Sep 17 18:53:15 EST 1998
; Last updated by Josh Howard on Mon Apr 21 18:21:19 2003


;
; Requires tf 4.0a1 or above
;

;
; User Config
;

; Nickname
/set irc_nick samplenic

; Username (bit before the @ in the domain)
/set irc_user FirstLastName

; Realname
/set irc_name MyRealName

; Signoff comment
/set irc_signoff I'm outta here.

; What's returned when somebody asks for your version/finger/userinfo
; via CTCP
/set finger_msg This space for hire.
/set userinfo_msg http://mywebsite.com

; Don't change these ones
/set version_msg TF-IRC:v0.02:IRC via TinyFugue/Win32 or Tinyfugue/Linux
/set clientinfo_msg CTCP commands supported - ACTION CLIENTINFO FINGER PING USERINFO VERSION - Client is still under development

; mud or irc
/set irc_display_mode mud

; use colours?
/set irc_colours on

;
; END User Config
; Anything you change below here is YOUR problem
;
/require lisp.tf
/require pcmd.tf

/set away_set 0

/if (irc_display_mode =~ "mud") \
   /set irc_server_prefix [Server] %;\
   /set irc_whois_prefix [Whois] %;\
   /set irc_error_prefix Error: %;\
/else \
   /set irc_server_prefix *** %;\
   /set irc_whois_prefix *** %;\
   /set irc_error_prefix *** %;\
/endif


; Debug trendy thing - comment out if you aren't debugging, it shows
;                      all the server messages before processing ...
;                      It's AWFULLY spammy though
;/def -T"irc.irc" -p999 -F -mregexp -t"^(.*)$" debug_echo = /echo -w [DEBUG] %P1


;
; Colours
;

/if (irc_colours =~ "on") \
   /if (irc_display_mode =~ "mud") \
      /def -p100 -T"irc.irc" -F -aCgreen -mregexp -t'^[^ ]* (pages):' IRCmsg%;\
      /def -p100 -T"irc.irc" -F -PCgreen -mregexp -t'^From [^,]*,' IRCotherchan %;\
      /def -p100 -T"irc.irc" -F -PCblue -mregexp -t'^\\[[^ ]+\\]' IRCbox %;\
      /def -p100 -T"irc.irc" -F -PBCred -mregexp -t'^Error: .*$' IRCerror %;\
      /def -p100 -T"irc.irc" -F -PCcyan -mregexp -t'has left.*$' IRCleft %;\
      /def -p100 -T"irc.irc" -F -PCcyan -mregexp -t'has disconnected.*$' IRCdisconn %;\
      /def -p100 -T"irc.irc" -F -PCcyan -mregexp -t'has joined.*$' IRCjoin %;\
      /def -p100 -T"irc.irc" -F -PCcyan -mregexp -t'Users [^:]*:' IRCcontents %;\
   /else \
      /def -p100 -T"irc.irc" -F -PCgreen -mregexp -t'>' IRCoutmsg %;\
      /def -p100 -T"irc.irc" -F -PCgreen -mregexp -t'<' IRCinmsg %;\
      /def -p100 -T"irc.irc" -F -PCblue -mregexp -t'^\\*\\*\\*' IRCbox %;\
   /endif %;\
/endif

;
; User-entered commands
;

; /join
/def -T"irc.irc" join = \
   /if ({*} !~ "") \
      /send -w JOIN :%*%; \
      /eval /set channel_${world_name} %%*%; \
      /eval /set irc_channel %%{channel_${world_name}} %;\
   /else \
      /echo -w -p %%{irc_error_prefix} No channel specified to join!%; \
   /endif

; /part or /hop
/def -T"irc.irc" hop = \
   /part

/def -T"irc.irc" part = \
   /if ({*} !~ "") \
      /send -w PART :%*%; \
   /else \
      /eval /send -w PART :%%{channel_${world_name}}%; \
      /eval /set channel_${world_name}=%;\
      /eval /set irc_channel %%{channel_${world_name}} %;\
   /endif

; /kick
/def -T"irc.irc" kick = \
   /eval /send -w KICK %%{channel_${world_name}} %%1 :%%-1

; /op
/def -T"irc.irc" op = \
   /eval /send -w MODE %%{channel_${world_name}} +o %%*

; /who
/def -T"irc.irc" who = \
   /eval /send -w WHO %%{channel_${world_name}}

; /whois
/def -T"irc.irc" whois = \
   /send -w WHOIS %1 %1

; /list
/def -T"irc.irc" irclist = \
   /send -w LIST %1 %1

; /away
/def -T"irc.irc" away = \
   /if ({*} !~ "") \
      /set away_msg=%* \[$[ftime(abeTZY,time())]\]%; \
      /send -w AWAY :%{away_msg}%; \
      /set away_set 1%; \
      /set away_at $[time()]%; \
   /else \
      /send -w AWAY%; \
      /set away_set 0%; \
      /unset away_msg%; \
      /unset away_at%; \
   /endif

; /ctcp commands
/def -T"irc.irc" ctcp = \
   /send -w PRIVMSG %{1} :�%{-1}�

/def -T"irc.irc" ctcpr = \
   /send -w NOTICE %{1} :�%{-1}�

; /msg and /amsg (action msg)
/def -T"irc.irc" msg = \
   /send -w PRIVMSG %{1} :%{-1}%;\
   /if (irc_display_mode =~ "mud") \
      /echo -w -p @{Cgreen}You page@{n} %{1} with "%{-1}"%;\
   /else \
      /echo -w -p @{Cgreen}>>%{1}>>@{n} %{-1}%;\
   /endif

; pageish version of msg
/def -p1  -T"irc.irc" -h'SEND ^\+who$' alias_who2= \
   /eval /send -w NAMES %%{channel_${world_name}}

/def -p1  -T"irc.irc" -h'SEND ^WHO$' alias_who= \
   /eval /send -w WHO %%{channel_${world_name}}

/def -p1  -T"irc.irc" -h'SEND ^\+finger (.*)$' alias_finger= \
   /eval /send -w WHOIS %P1 %P1

/def -p1  -T"irc.irc" -h'SEND ^p(age)? ([^=]*)=([^:].*)$' alias_msg= \
   /msg %P2 %P3

/def -T"irc.irc" amsg = \
   /ctcp %{1} ACTION %{-1}%;\
   /if (irc_display_mode =~ "mud") \
      /echo -w -p @{Cgreen}Long distance to@{n} %{1}: @{BCyellow}%{irc_nick}@{n} %{-1}%;\
   /else \
      /echo -w -p @{Cgreen}*>>%{1}>>@{n} %{irc_nick} %{-1}%;\
   /endif

; pageish version of amsg
/def -p1  -T"irc.irc" -h'SEND ^p(age)? ([^=]*)=:(.*)$' alias_amsg= \
   /amsg %P2 %P3

; /ping
/def -T"irc.irc" ping = \
   /ctcp %{1} PING $[time()]

; /nick
/def -T"irc.irc" nick = \
   /send -w NICK :%*%;\
   /set irc_nick %*

; /topic
/def -T"irc.irc" topic = \
   /if ({*} !~ "") \
      /eval /send -w TOPIC %%{channel_${world_name}} :%%*%; \
   /else \
      /eval /send -w TOPIC %%{channel_${world_name}}%; \
   /endif

; /q
/def  -T"irc.irc" q = \
   /send -w QUIT :%{irc_signoff}

; /ver
/def -T"irc.irc" ver = \
   /ctcp %* VERSION

; /finger
/def -T"irc.irc" finger = \
   /ctcp %* FINGER


;
; Server messages - things we ignore
;
/def -q -ag -p999  -T"irc.irc" -F -mregexp -t'^:.+ (315|318|321|323|329|366|369|376|403)' ~ignores

; ctcp sounds
/def -q -ag -p520  -T"irc.irc" -F -mregexp -t'^.+ PRIVMSG .+:�SOUND .+�'


;
; Server messages - things we just display
;
/def -q -p599  -T"irc.irc" -F -mregexp -t'^:.+ (001|002|003|004|250|251|255|265|266|305|306|368|372|375|377|378|472|257) .+ : ?-? ?(.*)$' ~numbers = \
   /substitute %{irc_server_prefix} %P2

/def -q -p599  -T"irc.irc" -F -mregexp -t'^:.+ (401|402) [^ ]+ ([^ ]+) :?(.+)$' ~numbers3 = \
   /substitute %{irc_server_prefix} %P2: %P3

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ (252|253|254)+ [^ ]+ ([^ ]+) :(.+)$' ~head1= \
   /substitute %{irc_server_prefix} %P2 %P3

/def -q -p518  -T"irc.irc" -F -mregexp -t'^NOTICE [^ ]+ :(.*)$' ~notice= \
   /substitute %{irc_server_prefix} %P1

/def -q -p518  -T"irc.irc" -F -mregexp -t'^NOTICE [^ ]+ :(.*)$' ~notice= \
   /substitute %{irc_server_prefix} %P1

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:([^!]+)![^ ]+ NOTICE [^ ]+ :VERSION (.*)' ~version_reply= \
   /substitute %{irc_server_prefix} Version from %P1: %P2

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 322 [^ ]+ (#[^ ]+) ([^ ]+) :(.*)$' ~list= \
   /substitute %{irc_server_prefix} %P2 %P1 (%P3)

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 301 [^ ]+ ([^ ]+) :(.*)$' ~away = \
   /substitute %{irc_server_prefix} Away message from %P1: %P2

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 433 \* ([^ ]+) :Nickname is already in use.' ~badnick =\
   /substitute %{irc_error_prefix} Nickname %P1 already in use!

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 367 .+ .+ (.*) (.*) (.*)$' ~bans = \
   /substitute %{irc_server_prefix} Ban: %P1 by %P2 at $[ftime(%c,{P3})]

; somebody joins channel
/def -q -p518  -T"irc.irc" \
   -F -mregexp -t'^:([^!]*)!([^ ]*) JOIN [^:]*:(([^.]|[.])*)$' ~join = \
   /substitute  %P1 (%P2) has joined %P3.%; \
   /if ({P1} =~ {irc_nick}) \
      /eval /set channel_${world_name} %P3%; \
      /eval /set irc_channel %P3 %;\
   /endif

; channel names list
/def -q -p599 -F  -T"irc.irc" \
   -F -mregexp -t'^:[^ ]+[ ]+353(([ ]|[^ ])+)[ ]+([^ ]+)[ ]+[^:]*:(([ ]|[^ ])*)' ~names = \
   /if (irc_display_mode =~ "mud") \
      /substitute Users on %P3: %P4 %;\
   /else \
      /substitute %{irc_server_prefix} Users on %P3: %P4 %;\
   /endif

/def -q -p518  -T"irc.irc" \
   -F -mregexp -t'^:([^!]*)!([^ ]*) QUIT [^:]*:(([^.]|[.])*)$' ~quit = \
   /substitute %P1 has disconnected: %P3

; somebody leaves channel
/def -q -p518  -T"irc.irc" \
   -F -mregexp -t'^:([^!]*)!([^ ]*) PART (([^.]|[.])*)$' ~part = \
   /substitute %P1 has left %P3.%;\
   /if ({P1} =~ {irc_nick}) \
      /eval /set channel_${world_name}%; \
      /eval /set irc_channel %%{channel_${world_name}}%;\
   /endif

/def -q -p518  -T"irc.irc" \
   -F -mregexp -t'^:([^!]+)![^ ]+ KICK (#[^ ]+) ([^ :]+) :(.*)$' ~kicked = \
   /substitute %{irc_server_prefix} %P3 kicked from %P2 by %P1: %P4%;\
   /if ({P3} =~ {irc_nick}) \
      /eval /set channel_${world_name}%; \
      /eval /set irc_channel %%{channel_${world_name}}%;\
   /endif

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 352 [^ ]+ (#[^ ]+) ([^ ]+) ([^ ]+) [^ ]+ ([^ ]+) ([^ ]+) :[^ ]+ (.*)$' ~ircwho = \
   /substitute %P1 $[pad({P4}, -9)] $[pad({P5}, -4)] %P2@%P3 (%P6)

/def -q -p518  -T"irc.irc" \
   -F -mregexp -t'^:.+ 311 [^ ]+ ([^ ]+) ([^ ]+) ([^ ]+) .+ :(.+)$' ~iwhois = \
   /substitute %{irc_whois_prefix} %P1 is %P2@%P3 (%P4)

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 319 [^ ]+ [^ ]+ :(.*)$' ~iwhois2 = \
   /substitute %{irc_whois_prefix} on channels: %P1

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 312 [^ ]+ [^ ]+ ([^ ]+) :(.+)$' ~iwhois3 = \
   /substitute %{irc_whois_prefix} on irc via server %P1 (%P2)

/def -q -p518  -T"irc.irc" \
   -F -mregexp -t'^:.+ 317 [^ ]+ [^ ]+ ([^ ]+) :seconds idle$' ~iwhois4 = \
   /substitute %{irc_whois_prefix} $[{P1} / 60] mins, $[mod({P1},60)] secs idle.

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 313 [^ ]+ [^ ]+ :(.*)$' ~iwhois5 = \
   /substitute %{irc_whois_prefix} IRC Operator.

/def -q -p518  -T"irc.irc" \
   -F -mregexp -t'^:.+ 421 [^ ]+ ([^ ]+) :Unknown command$' ~badcommand = \
   /substitute %{irc_error_prefix} Unknown command '%P1'.

/def -q -p518  -T"irc.irc" \
   -F -mregexp -t'^:.+ 441 [^ ]+ ([^ ]+) ([^ ]+) :isn\'t on that channel$' ~nothere = \
   /substitute %{irc_error_prefix} %P1 isn't on channel %P2.

/def -q -p518  -T"irc.irc" \
   -F -mregexp -t'^:.+ 401 [^ ]+ ([^ ]+) :is not on IRC' ~noton = \
   /substitute %{irc_error_prefix} %P1 isn't on IRC.

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 317 [^ ]+ [^ ]+ ([^ ]+) ([^ ]+) :seconds idle, signon time' ~iwhois6 = \
   /substitute %{irc_whois_prefix} $[{P1} / 60] mins, $[mod({P1},60)] secs idle. Signon at: $[ftime({c},{P2})]

; Speech to channel
/def -q -p518  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* PRIVMSG (#[^ ]+) :(([^.]|[.])*)$' ~message = \
   /if /test tolower({P2}) =~ {channel_${world_name}} %; /then \
      /if (irc_display_mode =~ "mud") \
         /substitute %P1 says, "%P3"%; \
      /else \
         /substitute \<%P1\> %P3%; \
      /endif %;\
   /else \
      /if (irc_display_mode =~ "mud") \
         /substitute From %P2, %P1 says, "%P3"%; \
      /else \
         /substitute \<%P1:%P2\> %P3%; \
      /endif %;\
   /endif

; /me to channel
/def -q -p519  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* PRIVMSG (#[^ ]+) :ACTION (([^.]|[.])*)$' ~caction = \
   /if /test tolower({P2}) =~ {channel_${world_name}} %; /then \
      /if (irc_display_mode =~ "mud") \
         /substitute %P1 %P3%; \
      /else \
         /substitute * %P1 %P3%; \
      /endif %;\
   /else \
      /if (irc_display_mode =~ "mud") \
         /substitute From %P2, %P1 %P3%; \
      /else \
         /substitute * %P1:%P2 %P3%; \
      /endif %;\
   /endif

; self mode change
/def -q -p100  -T"irc.irc" -F -mregexp -t'^:([^ ]+) MODE ([^ ]+) :(.+)$' ~selfmode = \
   /substitute %{irc_server_prefix} Mode change \"%P3\" by %P1

; channel mode change
/def -q -p100  -T"irc.irc" \
   -F -mregexp -t'^:([^!]+)(![^ ]+)? MODE (#[^ ]+) (.*)$' ~chmode = \
   /substitute %{irc_server_prefix} Mode change \"%P4\" on channel %P3 by %P1

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 324 [^ ]+ (#[^ ]+) (.+)$' ~modes = \
   /substitute %{irc_server_prefix} Modes on %P1: %P2

/def -q -p517  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* NOTICE [^:]*:(([^.]|[.])*)$' ~pnotice = \
   /substitute \-%P1\- %P2

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* NOTICE (#[^:]*):(([^.]|[.])*)$' ~cnotice = \
   /substitute \-%P1:%P2\- %P3

/def -q -p519  -T"irc.irc" -F -mregexp -t'^:([^!]+)![^ ]+ NOTICE [^:]*:�([^ ]+) (([^.]|[.])+)�$' ~creply = \
   /substitute %{irc_server_prefix} CTCP %P2 reply from %P1: %P3

; ping reply
/def -q -p520  -T"irc.irc" -F -mregexp -t'^:([^!]+)![^ ]+ NOTICE [^:]* :PING (([^.]|[.])+)$' ~preply = \
   /substitute %{irc_server_prefix} Ping reply from %P1: $[(time() - %P2) / 60] mins, $[mod(time() - %P2,60)] secs

/def -q -p100  -T"irc.irc" -F -mregexp -t'^:([^!]+)![^ ]+ NICK [^:]*:(([^.]|[.])+)$' ~nickchng = \
   /substitute %{irc_server_prefix} %P1 is now known as %P2

/def -q -p520  -T"irc.irc" -F -mregexp -t'^:([^!]+)![^ ]+ TOPIC ([^ ]+) :(([^.]|[.])+)$' ~topic3 = \
   /substitute %{irc_server_prefix} %P1 set the topic on %P2 to: %P3

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 332 .+ (#[^ :]+) :(([^.]|[.])+)$' ~topic = \
   /substitute %{irc_server_prefix} Topic for %P1: %P2

/def -q -p518  -T"irc.irc" -F -mregexp -t'^:.+ 333 .+ #[^ ]+ ([^ ]+) (.+)$' ~topic2 = \
   /substitute %{irc_server_prefix} Last set by %P1 at: $[ftime({c},{P2})]


;
; Server things we reply to
;

 
; server pings
;;/def -q -ag -p518  -T"irc.irc" -F -F -mregexp -t'^PING :(([ ]|[^ ])+)$' ~ping = \
;;   /send -w PONG %P1
/def -T"irc.irc" -p999 -F -mregexp -t'^PING (.*)'=/send PONG %{P1} 

/def -q -ag -p518  -T"irc.irc" -F -F -mregexp -t'^PING :(([ ]|[^ ])+)$' ~ping = \
   /send -w PONG %P1
 
; ctcp request
 /def -q -p519  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* PRIVMSG [^:]*:VERSION$' ~cversion = \

/def -q -p519  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* PRIVMSG [^:]*:TIME$' ~ctime = \
   /substitute [TFIRC] %P1 has requested your TIME.%;\
   /ctcpr %P1 TIME $[ftime(%c,time())]

/def -q -p519  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* PRIVMSG [^:]*:FINGER$' ~cfinger = \
   /substitute [TFIRC] %P1 has requested your FINGER.%;\
   /ctcpr %P1 FINGER %{finger_msg}

/def -q -p519  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* PRIVMSG [^:]*:USERINFO$' ~cuserinfo = \
   /substitute [TFIRC] %P1 has requested your USERINFO.%;\
   /ctcpr %P1 USERINFO %{version_msg}

/def -q -p519  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* PRIVMSG [^:]*:CLIENTINFO' ~cclientinto = \
   /substitute [TFIRC] %P1 has requested your CLENTINFO.%;\
   /ctcpr %P1 CLIENTINFO %{version_msg}

;/def -q -p519  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* PRIVMSG [^:]*:(VERSION|FINGER|USERINFO|CLIENTINFO)' ~cversion = \
;   /substitute [TFIRC] %P1 has requested your %P2.%;\
;   /ctcpr %P1 %P2 %{version_msg}

; /msg to us
/def -q -p517  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* PRIVMSG [^:]*:(([^.]|[.])*)$' ~pmessage = \
   /if (irc_display_mode =~ "mud") \
      /substitute %P1 pages: %P2%;\
   /else \
      /substitute <<%P1<< %P2 %; \
   /endif%;\
   /if ({away_set}) \
      /~away_idle%; \
      /send -w NOTICE %P1 :Away: %{away_msg} \[%{away_from}\]%; \
      /substitute $[ftime("[%H:%M:%S]",time())] Away message sent to %P1.%; \
   /endif

; /amsg to us
/def -q -p518  -T"irc.irc" -F -mregexp -t'^:([^!]*)[^ ]* PRIVMSG [^:]*:ACTION (([^.]|[.])*)$' ~paction = \
   /if (irc_display_mode =~ "mud") \
      /substitute From afar, %P1 %P2%;\
   /else \
      /substitute *<<%P1 %P2 %; \
   /endif
;   /if (%{away_set}) \
;      /~away_idle%; \
;      /send -w NOTICE %P1 :Away: %{away_msg} \[%{away_from}\]%; \
;      /substitute $[ftime("[%H:%M:%S]",time())] Away message sent to %P1.%; \
;   /endif

; update /away info
/def ~away_idle = \
   /if ((time() - %{away_at}) > 3600)%; \
      /set away_from=$[(time() - %{away_at}) / 3600]h$[mod((time() - %{away_at}),3600) / 60]m%; \
   /else \
      /set away_from=$[(time() - %{away_at}) / 60]m%; \
   /endif

; pings from ordinary mortals
/def -q -p520  -T"irc.irc" -F -mregexp -t'^:([^!]+)![^ ]+ PRIVMSG [^:]* :PING (.+)$' ~cping = \
   /send -w NOTICE %P1 :�PING %P2� %;\
   /substitute %{irc_server_prefix} %P1 pinged you.


;
; Hooks
;

; /say and ""
/def -T"irc.irc" say = \
   /if /test {channel_${world_name}} !~ ""%;  /then \
      /eval /send -w PRIVMSG %%{channel_${world_name}} :%%*%; \
      /if (irc_display_mode =~ "mud") \
         /echo -w -p @{BCyellow}You@{n} say, "%*"%; \
      /else \
         /echo -w -p @{BCyellow}<%{irc_nick}>@{n} %*%; \
      /endif %;\
   /else \
      /echo -w -p %{irc_error_prefix} You're not on a channel!%; \
   /endif

; " version of say
/def -p1  -T"irc.irc" -h'SEND ^\"(.*)' alias_say= \
   /say %P1

; /me and :
/def -T"irc.irc" me = \
   /if /test {channel_${world_name}} !~ ""%;  /then \
      /eval /ctcp %%{channel_${world_name}} ACTION %*%;\
      /if (irc_display_mode =~ "mud") \
         /echo -w -p @{BCyellow}%{irc_nick}@{n} %*%; \
      /else \
         /echo -w -p @{Cgreen}* @{BCyellow}%{irc_nick}@{n} %*%; \
      /endif %;\
   /else \
      /echo -w -p  %{irc_error_prefix} You're not on a channel!%; \
   /endif

; : version of /me
/def -p1 -T"irc.irc" -h'SEND ^\:([^ ].*)' alias_action= \
   /me %P1

/def -T"irc.irc" -F -hWORLD -p999 IRCworld_hook = \
   /set lp=0

; Send connect stuff when we connect
/def -T"irc.irc" -hCONNECT -p999 ~irc_login_hook = \
   /send -w PASS foobar%; \
   /send -w NICK %{irc_nick}%; \
   /send -w USER %{irc_user} foo foo :%{irc_name}%; \
   /send -w MODE %{irc_nick} +i%; \
   /if (away_set) \
      /send -w AWAY :%{away_msg}%; \
   /endif%;\
   /world %1

; Unset channel when we disconnect
/def -T"irc.irc" -hDISCONNECT -p999 ~irc_logout_hook = \
   /unwatch -a%;\
   /kill %{watch_pid}%;\
   /eval /set channel_${world_name}=

;;; This is the end of the stuff that might be working

Here is some extra stuff that definitely doesn't work.

;
; DCC Chat Stuff
;
/def chat = \
   /addworld -T"irc.dcc" dcc_%1 %2 %3 %;\
   /world dcc_%1

/def -q -p1 -mglob -T"irc.dcc" -t'*' ~dcc_filter =\
   /substitute $[substr(${world_name}, 4)] says, "%*"

/def -q -p2 -ag -mregexp -T"irc.dcc" -t'�ACTION (.*)�' ~dcc_filter2 =\
   /echo -w $[substr(${world_name}, 4)] %-1

/def ~reset_chat_alias =\
   /send -w %* %;\
   /def -p1 -F -1 -T"irc.dcc" -h'SEND ^\"(.*)' alias_dcc_say= \
      /echo -w -p @{BCyellow}You@{n} say "%%P1"%%; \
      /~reset_chat_alias %%P1

/def -p1 -F -1 -T"irc.dcc" -h'SEND ^\"(.*)' alias_dcc_say= \
   /echo -w -p @{BCyellow}You@{n} say "%P1"%; \
   /~reset_chat_alias %P1

/def -p1 -F -1 -T"irc.dcc" -h'SEND ^\:(.*)' alias_dcc_act= \
   /echo -w -p @{BCyellow}%{irc_nick}@{n} %P1%; \
   /send -w �ACTION %P1�

;
; Watch stuff
;

; Usage:
; /watch <player>        Tells you when <player> logs on to the mud.
; /watch                Tells you who you are still watching for.
; /unwatch <player>        Stops looking for <player>.
; /unwatch -a                Stops looking for everyone.

/def watch = \
    /let watch_list=/eval %{watch_list_${world_name}}%;\
    /let watch_glob=/eval %{watch_glob_${world_name}}%;\
    /let watch_pid=/eval %{watch_pid_${world_name}}%;\
    /let who=$[tolower(%1)]%;\
    /if (who =~ "") \
        /echo \% You are watching for: %{watch_list}%;\
        /break%;\
    /endif%;\
    /if (who =/ watch_glob) \
        /echo \% You are already watching for that person!%;\
        /break%;\
    /endif%;\
    /if (watch_pid =~ "") \
        /repeat -60 1 /_watch%;\
        /set watch_pid=%?%;\
    /endif%;\
    /set watch_list=%{who} %{watch_list}%;\
    /set watch_glob={%{watch_list}}%;\
    /eval /let %{watch_list_${world_name}} = %{watch_list}%;\
    /eval /let %{watch_glob_${world_name}} = %{watch_glob}%;\
    /eval /let %{watch_pid_${world_name}} = %{watch_pid}

/def unwatch =\
    /let who=$[tolower({1})]%;\
    /let watch_list=/eval %{watch_list_${world_name}}%;\
    /let watch_glob=/eval %{watch_glob_${world_name}}%;\
    /let watch_pid=/eval %{watch_pid_${world_name}}%;\
    /if (who =~ "") \
        /echo \% Use /unwatch <name> or /unwatch -a for all.%;\
        /break%;\
    /endif%;\
    /if ((who !~ "-a") & (who !/ watch_glob)) \
        /echo \% You already weren't watching for that person!%;\
        /break%;\
    /endif%;\
    /if (who =~ "-a") \
        /set watch_list=%;\
    /else \
        /set watch_list=$(/remove %{who} %{watch_list})%;\
    /endif%;\
    /set watch_glob={%{watch_list}}%;\
    /if ((watch_list =~ "") & (watch_pid !~ "")) \
        /kill %{watch_pid}%;\
        /unset watch_pid%;\
    /endif%;\
    /eval /let %{watch_list_${world_name}} = %{watch_list}%;\
    /eval /let %{watch_glob_${world_name}} = %{watch_glob}%;\
    /eval /let %{watch_pid_${world_name}} = %{watch_pid}

/def _watch_check =\
    /let watch_list=/eval %{watch_list_${world_name}}%;\
    /let watch_glob=/eval %{watch_glob_${world_name}}%;\
    /let watch_pid=/eval %{watch_pid_${world_name}}%;\
  /if (strstr(%{watch_ison_new}, %{*}) != -1) \
      /if (strstr(%{watch_ison}, %{*}) != -1)%;\
      /else \
          /substitute [Watch] %{1} has connected to IRC.%;\
      /endif%;\
  /else \
      /if (strstr(%{watch_ison}, %{*}) != -1) \
          /substitute [Watch] %{1} has disconnected from IRC.%;\
      /endif%;\
  /endif%;\
    /eval /let %{watch_list_${world_name}} = %{watch_list}%;\
    /eval /let %{watch_glob_${world_name}} = %{watch_glob}%;\
    /eval /let %{watch_pid_${world_name}} = %{watch_pid}

/def -q -p100 -ag -mregexp -T'irc' -t'^:.+ 303 [^ ]+ :(.*)$' _do_watch =\
    /let watch_list=/eval %{watch_list_${world_name}}%;\
    /let watch_glob=/eval %{watch_glob_${world_name}}%;\
    /let watch_pid=/eval %{watch_pid_${world_name}}%;\
  /set watch_ison_new=$[tolower(%{P1})]%;\
  /mapcar /_watch_check %{watch_list}%;\
  /set watch_ison=%{watch_ison_new}%;\
    /eval /let %{watch_list_${world_name}} = %{watch_list}%;\
    /eval /let %{watch_glob_${world_name}} = %{watch_glob}%;\
    /eval /let %{watch_pid_${world_name}} = %{watch_pid}

/def _watch =\
    /let watch_list=/eval %{watch_list_${world_name}}%;\
    /let watch_glob=/eval %{watch_glob_${world_name}}%;\
    /let watch_pid=/eval %{watch_pid_${world_name}}%;\
    /unset watch_pid%;\
        /if (watch_list !~ "") \
            /repeat -60 1 /_watch%;\
            /set watch_pid=%?%;\
        /endif%;\
    /send -T"irc.irc" -w${world_name} ison :%{watch_list}%;\
    /eval /let %{watch_list_${world_name}} = %{watch_list}%;\
    /eval /let %{watch_glob_${world_name}} = %{watch_glob}%;\
    /eval /let %{watch_pid_${world_name}} = %{watch_pid}