mirror of
https://github.com/evennia/evennia.git
synced 2026-04-04 06:57:16 +02:00
Added a keepalive for the bot to survive IDLE_TIMEOUTs.
This commit is contained in:
parent
f126d30b36
commit
fc89923fa8
1 changed files with 13 additions and 2 deletions
|
|
@ -4,13 +4,16 @@ Player that are controlled by the server.
|
|||
|
||||
"""
|
||||
|
||||
from django.conf import settings
|
||||
from src.players.player import Player
|
||||
from src.scripts.scripts import Script
|
||||
from src.commands.command import Command
|
||||
from src.commands.cmdset import CmdSet
|
||||
from src.commands.cmdhandler import CMD_NOMATCH, CMD_LOGINSTART
|
||||
from src.utils import search
|
||||
|
||||
_IDLE_TIMEOUT = settings.IDLE_TIMEOUT
|
||||
_IDLE_COMMAND = settings.IDLE_COMMAND
|
||||
|
||||
_SESSIONS = None
|
||||
_CHANNELDB = None
|
||||
|
||||
|
|
@ -25,9 +28,13 @@ class BotStarter(Script):
|
|||
"""
|
||||
def at_script_creation(self):
|
||||
self.key = "botstarter"
|
||||
self.desc = "kickstarts bot"
|
||||
self.desc = "bot start/keepalive"
|
||||
self.persistent = True
|
||||
self.db.started = False
|
||||
if _IDLE_TIMEOUT > 0:
|
||||
# call before idle_timeout triggers
|
||||
self.interval = int(max(60, _IDLE_TIMEOUT * 0.99))
|
||||
self.start_delay = True
|
||||
|
||||
def at_start(self):
|
||||
"Kick bot into gear"
|
||||
|
|
@ -35,6 +42,10 @@ class BotStarter(Script):
|
|||
self.player.start()
|
||||
self.db.started = True
|
||||
|
||||
def at_repeat(self):
|
||||
"Called self.interval seconds to keep connection."
|
||||
self.dbobj.execute_cmd(_IDLE_COMMAND)
|
||||
|
||||
def at_server_reload(self):
|
||||
"""
|
||||
If server reloads we don't need to reconnect the protocol
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue