Further development of the reworking of systems using Sessions rather than session id.

This commit is contained in:
Griatch 2015-11-14 20:32:58 +01:00
parent 709f5ff5b3
commit d496606a3c
19 changed files with 166 additions and 209 deletions

View file

@ -90,7 +90,7 @@ class CmdBotListen(Command):
key = "bot_data_in"
def func(self):
"Relay to typeclass"
self.obj.execute_cmd(self.args.strip(), sessid=self.sessid)
self.obj.execute_cmd(self.args.strip(), session=self.session)
class BotCmdSet(CmdSet):
"""
@ -135,19 +135,19 @@ class Bot(DefaultPlayer):
"""
pass
def msg(self, text=None, from_obj=None, sessid=None, **kwargs):
def msg(self, text=None, from_obj=None, session=None, **kwargs):
"""
Evennia -> outgoing protocol
"""
super(Bot, self).msg(text=text, from_obj=from_obj, sessid=sessid, **kwargs)
super(Bot, self).msg(text=text, from_obj=from_obj, session=session, **kwargs)
def execute_cmd(self, raw_string, sessid=None):
def execute_cmd(self, raw_string, session=None):
"""
Incoming protocol -> Evennia
"""
super(Bot, self).msg(raw_string, sessid=sessid)
super(Bot, self).msg(raw_string, session=session)
def at_server_shutdown(self):
"""
@ -236,14 +236,14 @@ class IRCBot(Bot):
text = "bot_data_out %s" % text
super(IRCBot, self).msg(text=text)
def execute_cmd(self, text=None, sessid=None):
def execute_cmd(self, text=None, session=None):
"""
Take incoming data and send it to connected channel. This is
triggered by the CmdListen command in the BotCmdSet.
Args:
text (str, optional): Command string.
sessid (int, optional): Session id responsible for this
session (Session, optional): Session responsible for this
command.
"""
@ -296,7 +296,7 @@ class RSSBot(Bot):
"rate": self.db.rss_rate}
_SESSIONS.start_bot_session("evennia.server.portal.rss.RSSBotFactory", configdict)
def execute_cmd(self, text=None, sessid=None):
def execute_cmd(self, text=None, session=None):
"""
Echo RSS input to connected channel
@ -386,13 +386,13 @@ class IMC2Bot(Bot):
text = "bot_data_out %s" % text
self.msg(text=text)
def execute_cmd(self, text=None, sessid=None):
def execute_cmd(self, text=None, session=None):
"""
Relay incoming data to connected channel.
Args:
text (str, optional): Command string.
sessid (int, optional): Session id responsible for this
session (Session, optional): Session responsible for this
command.
"""

View file

@ -430,8 +430,9 @@ class DefaultPlayer(with_metaclass(TypeclassBase, PlayerDB)):
raw_string = self.nicks.nickreplace(raw_string,
categories=("inputline", "channel"), include_player=False)
if not session and _MULTISESSION_MODE in (0, 1):
# for these modes we use the
session
# for these modes we use the first/only session
sessions = self.sessions.get()
session = sessions[0] if sessions else None
return cmdhandler.cmdhandler(self, raw_string,
callertype="player", session=session, **kwargs)
@ -679,7 +680,7 @@ class DefaultPlayer(with_metaclass(TypeclassBase, PlayerDB)):
the player loose.
Args:
sessid (int, optional): Session logging in, if any.
session (Session, optional): Session logging in, if any.
Notes:
This is called *before* an eventual Character's
@ -786,7 +787,7 @@ class DefaultPlayer(with_metaclass(TypeclassBase, PlayerDB)):
# list of targets - make list
characters = target
sessions = self.get_all_sessions()
sessions = self.sessions.all()
is_su = self.is_superuser
# text shown when looking in the ooc area
@ -845,7 +846,7 @@ class DefaultGuest(DefaultPlayer):
MULTISESSION_MODE we're in. They don't get a choice.
Args:
sessid (int, optional): Id of Session connecting.
session (Session, optional): Session connecting.
"""
self._send_to_connect_channel("{G%s connected{n" % self.key)