Fixed so bots cannot idle timeout.
This commit is contained in:
parent
04eb057419
commit
2aa9ef9997
1 changed files with 13 additions and 3 deletions
|
|
@ -12,7 +12,6 @@ from src.commands.cmdset import CmdSet
|
||||||
from src.utils import search
|
from src.utils import search
|
||||||
|
|
||||||
_IDLE_TIMEOUT = settings.IDLE_TIMEOUT
|
_IDLE_TIMEOUT = settings.IDLE_TIMEOUT
|
||||||
_IDLE_COMMAND = settings.IDLE_COMMAND
|
|
||||||
|
|
||||||
_SESSIONS = None
|
_SESSIONS = None
|
||||||
|
|
||||||
|
|
@ -42,8 +41,18 @@ class BotStarter(Script):
|
||||||
self.db.started = True
|
self.db.started = True
|
||||||
|
|
||||||
def at_repeat(self):
|
def at_repeat(self):
|
||||||
"Called self.interval seconds to keep connection."
|
"""
|
||||||
self.obj.dbobj.execute_cmd(_IDLE_COMMAND)
|
Called self.interval seconds to keep connection. We cannot use
|
||||||
|
the IDLE command from inside the game since the system will
|
||||||
|
not catch it (commands executed from the server side usually
|
||||||
|
has no sessions). So we update the idle counter manually here
|
||||||
|
instead. This keeps the bot getting hit by IDLE_TIMEOUT.
|
||||||
|
"""
|
||||||
|
global _SESSIONS
|
||||||
|
if not _SESSIONS:
|
||||||
|
from src.server.sessionhandler import SESSIONS as _SESSIONS
|
||||||
|
for session in _SESSIONS.sessions_from_player(self.player):
|
||||||
|
session.update_session_counters(idle=True)
|
||||||
|
|
||||||
def at_server_reload(self):
|
def at_server_reload(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -66,6 +75,7 @@ class CmdBotListen(Command):
|
||||||
"""
|
"""
|
||||||
key = "bot_data_in"
|
key = "bot_data_in"
|
||||||
def func(self):
|
def func(self):
|
||||||
|
"Relay to typeclass"
|
||||||
self.obj.typeclass.execute_cmd(self.args.strip(), sessid=self.sessid)
|
self.obj.typeclass.execute_cmd(self.args.strip(), sessid=self.sessid)
|
||||||
|
|
||||||
class BotCmdSet(CmdSet):
|
class BotCmdSet(CmdSet):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue