* Added the 'imclist' command to show other games connected to IMC.

* Added the automatic cleaning/pruning code to weed out entries that are probably disconnected.
* Added 'imcwhois <player>' command. Still needs some sanitizing on the outgoing string.
* Added the beginnings of a -reply packet handler through reply_listener.py.
* Fleshed out a few more packets in packets.py.
Next up: Make the ANSI system a little more modular. Create a class for ANSI tables so developers can pick and choose different tables on their own, but keep the same API. This will be used so we don't have to copy/paste src/ansi.py to src/imc2/ansi.py and duplicate stuff.
This commit is contained in:
Greg Taylor 2009-04-13 06:36:51 +00:00
parent 317a4f1532
commit 31a78f9fb6
7 changed files with 213 additions and 45 deletions

View file

@ -1,7 +1,7 @@
"""
IMC2 user and administrative commands.
"""
import time
from time import time
from django.conf import settings
from src.config.models import ConfigValue
from src.objects.models import Object
@ -11,25 +11,67 @@ from src.util import functions_general
from src.cmdtable import GLOBAL_CMD_TABLE
from src.imc2 import connection as imc2_conn
from src.imc2.packets import *
from src.imc2.trackers import IMC2_MUDLIST
def cmd_imctest(command):
def cmd_imcwhois(command):
"""
Shows a player's inventory.
"""
source_object = command.source_object
source_object.emit_to("Sending")
packet = IMC2PacketWhois(source_object, 'Cratylus')
imc2_conn.IMC2_PROTOCOL_INSTANCE.send_packet(packet)
source_object.emit_to("Sent")
GLOBAL_CMD_TABLE.add_command("imctest", cmd_imctest)
if not command.command_argument:
source_object.emit_to("Get what?")
return
else:
source_object.emit_to("Sending IMC whois request. If you receive no response, no matches were found.")
packet = IMC2PacketWhois(source_object, command.command_argument)
imc2_conn.IMC2_PROTOCOL_INSTANCE.send_packet(packet)
GLOBAL_CMD_TABLE.add_command("imcwhois", cmd_imcwhois)
def cmd_imckeepalive(command):
"""
Shows a player's inventory.
Sends an is-alive packet to the network.
"""
source_object = command.source_object
source_object.emit_to("Sending")
packet = IMC2PacketIsAlive()
imc2_conn.IMC2_PROTOCOL_INSTANCE.send_packet(packet)
source_object.emit_to("Sent")
GLOBAL_CMD_TABLE.add_command("imckeepalive", cmd_imckeepalive)
GLOBAL_CMD_TABLE.add_command("imckeepalive", cmd_imckeepalive)
def cmd_imckeeprequest(command):
"""
Sends a keepalive-request packet to the network.
"""
source_object = command.source_object
source_object.emit_to("Sending")
packet = IMC2PacketKeepAliveRequest()
imc2_conn.IMC2_PROTOCOL_INSTANCE.send_packet(packet)
source_object.emit_to("Sent")
GLOBAL_CMD_TABLE.add_command("imckeeprequest", cmd_imckeeprequest)
def cmd_imclist(command):
"""
Shows the list of cached games from the IMC2 Mud list.
"""
source_object = command.source_object
retval = 'Active MUDs on %s\n\r' % imc2_conn.IMC2_PROTOCOL_INSTANCE.network_name
for name, mudinfo in IMC2_MUDLIST.mud_list.items():
mudline = ' %-20s %s' % (name, mudinfo.versionid)
retval += '%s\n\r' % mudline[:78]
retval += '%s active MUDs found.' % len(IMC2_MUDLIST.mud_list)
source_object.emit_to(retval)
GLOBAL_CMD_TABLE.add_command("imclist", cmd_imclist)
def cmd_imclistupdated(command):
"""
Shows the list of cached games from the IMC2 Mud list.
"""
source_object = command.source_object
retval = 'Active MUDs on %s\n\r' % imc2_conn.IMC2_PROTOCOL_INSTANCE.network_name
for name, mudinfo in IMC2_MUDLIST.mud_list.items():
tdelta = time() - mudinfo.last_updated
retval += ' %-20s %s\n\r' % (name, tdelta)
source_object.emit_to(retval)
GLOBAL_CMD_TABLE.add_command("imclistupdated", cmd_imclistupdated)