mirror of
https://github.com/evennia/evennia.git
synced 2026-03-27 10:16:32 +01:00
115 lines
No EOL
4.1 KiB
Python
115 lines
No EOL
4.1 KiB
Python
"""
|
|
IMC2 user and administrative commands.
|
|
"""
|
|
from time import time
|
|
from django.conf import settings
|
|
from src.config.models import ConfigValue
|
|
from src.objects.models import Object
|
|
from src import defines_global
|
|
from src import ansi
|
|
from src.util import functions_general
|
|
from src.cmdtable import GLOBAL_CMD_TABLE
|
|
from src.ansi import parse_ansi
|
|
from src.imc2.imc_ansi import IMCANSIParser
|
|
from src.imc2 import connection as imc2_conn
|
|
from src.imc2.packets import *
|
|
from src.imc2.trackers import IMC2_MUDLIST, IMC2_CHANLIST
|
|
|
|
def cmd_imcwhois(command):
|
|
"""
|
|
Shows a player's inventory.
|
|
"""
|
|
source_object = command.source_object
|
|
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_imcansi(command):
|
|
"""
|
|
Test IMC ANSI conversion.
|
|
"""
|
|
source_object = command.source_object
|
|
if not command.command_argument:
|
|
source_object.emit_to("You must provide a string to convert.")
|
|
return
|
|
else:
|
|
retval = parse_ansi(command.command_argument, parser=IMCANSIParser())
|
|
source_object.emit_to(retval)
|
|
GLOBAL_CMD_TABLE.add_command("imcansi", cmd_imcansi)
|
|
|
|
def cmd_imcicerefresh(command):
|
|
"""
|
|
Semds an ice-refresh packet.
|
|
"""
|
|
source_object = command.source_object
|
|
packet = IMC2PacketIceRefresh()
|
|
imc2_conn.IMC2_PROTOCOL_INSTANCE.send_packet(packet)
|
|
source_object.emit_to("Sent")
|
|
GLOBAL_CMD_TABLE.add_command("imcicerefresh", cmd_imcicerefresh)
|
|
|
|
def cmd_imcchanlist(command):
|
|
"""
|
|
Shows the list of cached channels from the IMC2 Channel list.
|
|
"""
|
|
source_object = command.source_object
|
|
|
|
retval = 'Channels on %s\n\r' % imc2_conn.IMC2_PROTOCOL_INSTANCE.network_name
|
|
|
|
retval += ' Full Name Name Owner Perm Policy\n\r'
|
|
retval += ' --------- ---- ----- ---- ------\n\r'
|
|
for channel in IMC2_CHANLIST.get_channel_list():
|
|
retval += ' %-18s %-10s %-15s %-7s %s\n\r' % (channel.full_name, channel.name,
|
|
channel.owner, channel.level,
|
|
channel.policy)
|
|
retval += '%s channels found.' % len(IMC2_CHANLIST.chan_list)
|
|
source_object.emit_to(retval)
|
|
GLOBAL_CMD_TABLE.add_command("imcchanlist", cmd_imcchanlist)
|
|
|
|
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 mudinfo in IMC2_MUDLIST.get_mud_list():
|
|
mudline = ' %-20s %s' % (mudinfo.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_imcstatus(command):
|
|
"""
|
|
Shows some status information for your IMC2 connection.
|
|
"""
|
|
source_object = command.source_object
|
|
# This manages our game's plugged in services.
|
|
collection = command.session.server.service_collection
|
|
# Retrieve the IMC2 service.
|
|
service = collection.getServiceNamed('IMC2')
|
|
|
|
if service.running == 1:
|
|
status_string = 'Running'
|
|
else:
|
|
status_string = 'Inactive'
|
|
|
|
# Build the output to emit to the player.
|
|
retval = '-' * 50
|
|
retval += '\n\r'
|
|
retval += 'IMC Status\n\r'
|
|
retval += ' * MUD Name: %s\n\r' % (settings.IMC2_MUDNAME)
|
|
retval += ' * Status: %s\n\r' % (status_string)
|
|
retval += ' * Debugging Mode: %s\n\r' % (settings.IMC2_DEBUG)
|
|
retval += ' * IMC Network Address: %s\n\r' % (settings.IMC2_SERVER_ADDRESS)
|
|
retval += ' * IMC Network Port: %s\n\r' % (settings.IMC2_SERVER_PORT)
|
|
retval += '-' * 50
|
|
|
|
source_object.emit_to(retval)
|
|
GLOBAL_CMD_TABLE.add_command("imcstatus", cmd_imcstatus) |