Clean up send_cmessage() a bit. Changed noheader keyword arg to show_header and defaulted it to True. This should read a little better. Also updated some of the various function calls. More importantly, check to see if the channel argument is a string or unicode object and find the correct channel object as needed, which was the previous behavior. However, if it's not a string or unicode object, assume it's a CommChannel object and avoid querying for it again. This may be a performance win in some cases down the road.

This commit is contained in:
Greg Taylor 2009-04-30 03:13:46 +00:00
parent 70602efaa7
commit 76f14b4779
4 changed files with 42 additions and 34 deletions

View file

@ -24,8 +24,7 @@ def cemit_info(message):
Channel emits info to the appropriate info channel. By default, this
is MUDInfo.
"""
comsys.send_cmessage(settings.COMMCHAN_IMC2_INFO, 'IMC: %s' % message,
noheader=False)
comsys.send_cmessage(settings.COMMCHAN_IMC2_INFO, 'IMC: %s' % message)
class IMC2Protocol(StatefulTelnetProtocol):
"""
@ -118,10 +117,9 @@ class IMC2Protocol(StatefulTelnetProtocol):
mapping = IMC2ChannelMapping.objects.get(imc2_channel_name=chan_name)
ingame_chan_name = mapping.channel.name
# Format the message to cemit to the local channel.
message = '[%s] %s@%s: %s' % (ingame_chan_name,
packet.sender,
packet.origin,
packet.optional_data.get('text'))
message = '%s@%s: %s' % (packet.sender,
packet.origin,
packet.optional_data.get('text'))
# Bombs away.
comsys.send_cmessage(ingame_chan_name, message)
except IMC2ChannelMapping.DoesNotExist: