old_contents: #  Copyright (c) 2012 Stuart Walsh
  #
  #  Permission is hereby granted, free of charge, to any person
  #  obtaining a copy of this software and associated documentation
  #  files (the "Software"), to deal in the Software without
  #  restriction, including without limitation the rights to use,
  #  copy, modify, merge, publish, distribute, sublicense, and/or sell
  #  copies of the Software, and to permit persons to whom the
  #  Software is furnished to do so, subject to the following
  #  conditions:
  #
  #  The above copyright notice and this permission notice shall be
  #  included in all copies or substantial portions of the Software.
  #
  #  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  #  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  #  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  #  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  #  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  #  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  #  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  #  OTHER DEALINGS IN THE SOFTWARE.
  
  from ircd import register
  from pythonwrap import Client
  
  @register("NICK", min_args=1, max_args=2, access=0)
  def handle_nick(client, nick):
    client.Name = nick
    check_and_register(client)
  
  @register("USER", min_args=4, max_args=4, access=0)
  def handle_user(client, username, unused, unused2, realname):
    if client.is_registered():
      client.numeric(462)
      return 
    client.Username = username
    client.Realname = realname
    check_and_register(client)
  
  @register("PING", min_args=1, max_args=1, access=1)
  def handle_ping(client, arg):
    client.send(":{source} PONG {source} :{reply}", source=Client.Me.Name, reply=arg)
  
  def check_and_register(client):
    if client.is_registered():
      return
  
    if client.Name and client.Username:
      client.add()
  
new_contents: #  Copyright (c) 2012 Stuart Walsh
  #
  #  Permission is hereby granted, free of charge, to any person
  #  obtaining a copy of this software and associated documentation
  #  files (the "Software"), to deal in the Software without
  #  restriction, including without limitation the rights to use,
  #  copy, modify, merge, publish, distribute, sublicense, and/or sell
  #  copies of the Software, and to permit persons to whom the
  #  Software is furnished to do so, subject to the following
  #  conditions:
  #
  #  The above copyright notice and this permission notice shall be
  #  included in all copies or substantial portions of the Software.
  #
  #  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  #  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  #  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  #  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  #  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  #  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  #  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  #  OTHER DEALINGS IN THE SOFTWARE.
  
  from ircd import register, event
  from pythonwrap import Client
  
  @register("NICK", min_args=1, max_args=2, access=0)
  def handle_nick(client, nick):
    client.Name = nick
    check_and_register(client)
  
  @register("USER", min_args=4, max_args=4, access=0)
  def handle_user(client, username, unused, unused2, realname):
    if client.is_registered():
      client.numeric(462)
      return 
    client.Username = username
    client.Realname = realname
    check_and_register(client)
  
  @register("PING", min_args=1, max_args=1, access=1)
  def handle_ping(client, arg):
    client.send(":{source} PONG {source} :{reply}", source=Client.Me.Name, reply=arg)
  
  def check_and_register(client):
    if client.is_registered():
      return
  
    if client.Name and client.Username:
      client.add()
  
  @event(Client.connected)
  def client_connected(client):
    print "CLIENT CONNECTED YAY"
  
subject: add a test for @event