Re-activated connect-channel again, called from hooks. Fixed some bugs and minor things to give more control over how messages sent to channels are handled.

This commit is contained in:
Griatch 2012-11-13 21:24:05 +01:00
parent d55bee8905
commit 28c625c12c
4 changed files with 46 additions and 20 deletions

View file

@ -15,15 +15,25 @@ That an object is controlled by a player/user is just defined by its
they control by simply linking to a new object's user property.
"""
import datetime
from django.conf import settings
from src.typeclasses.typeclass import TypeClass
from src.commands import cmdset, command
from src.comms.models import Channel
__all__ = ("Object", "Character", "Room", "Exit")
_GA = object.__getattribute__
_SA = object.__setattr__
_DA = object.__delattr__
_CONNECT_CHANNEL = None
try:
_CONNECT_CHANNEL = Channel.objects.filter(db_key=settings.CHANNEL_CONNECTINFO[0])[0]
except Exception, e:
print e
pass
#
# Base class to inherit from.
#
@ -786,6 +796,10 @@ class Character(Object):
self.location.msg_contents("%s has left the game." % self.name, exclude=[self])
self.db.prelogout_location = self.location
self.location = None
if _CONNECT_CHANNEL:
now = datetime.datetime.now()
now = "%02i-%02i-%02i(%02i:%02i)" % (now.year, now.month, now.day, now.hour, now.minute)
_CONNECT_CHANNEL.tempmsg("[%s, %s]: {R%s disconnected{n" % (_CONNECT_CHANNEL.key, now, self.key))
def at_post_login(self):
"""
@ -804,7 +818,11 @@ class Character(Object):
self.location.at_object_receive(self, self.location)
# call look
self.execute_cmd("look")
# send to connect channel, if available
if _CONNECT_CHANNEL:
now = datetime.datetime.now()
now = "%02i-%02i-%02i(%02i:%02i)" % (now.year, now.month, now.day, now.hour, now.minute)
_CONNECT_CHANNEL.tempmsg("[%s, %s]: {G%s connected{n" % (_CONNECT_CHANNEL.key, now, self.key))
#