Continued work on the bots.
This commit is contained in:
parent
54586d0261
commit
2ae5d56928
3 changed files with 15 additions and 12 deletions
|
|
@ -112,7 +112,7 @@ class IRCBot(Bot):
|
||||||
# instruct the server and portal to create a new session
|
# instruct the server and portal to create a new session
|
||||||
_SESSIONS.start_bot_session("src.server.portal.irc.IRCClient", self.id)
|
_SESSIONS.start_bot_session("src.server.portal.irc.IRCClient", self.id)
|
||||||
|
|
||||||
def connect_to_channel(self, channelname):
|
def connect_to_channel(self, botkey, channelname):
|
||||||
"""
|
"""
|
||||||
Connect the bot to an Evennia channel
|
Connect the bot to an Evennia channel
|
||||||
"""
|
"""
|
||||||
|
|
@ -130,4 +130,5 @@ class IRCBot(Bot):
|
||||||
self.dbobj.msg(text=text)
|
self.dbobj.msg(text=text)
|
||||||
|
|
||||||
|
|
||||||
def execute_cmd(
|
def execute_cmd(self):
|
||||||
|
pass
|
||||||
|
|
|
||||||
|
|
@ -69,28 +69,29 @@ class PortalSessionHandler(SessionHandler):
|
||||||
operation=PDISCONN)
|
operation=PDISCONN)
|
||||||
|
|
||||||
|
|
||||||
def server_connect(self, protocol_path="", uid=None):
|
def server_connect(self, protocol_path="", uid=None, config=dict()):
|
||||||
"""
|
"""
|
||||||
Called by server to force the initialization of a new
|
Called by server to force the initialization of a new
|
||||||
protocol instance. Server wants this instance to get
|
protocol instance. Server wants this instance to get
|
||||||
a unique sessid and to be connected back as normal. This
|
a unique sessid and to be connected back as normal. This
|
||||||
is used to initiate irc/imc2/rss etc connections.
|
is used to initiate irc/imc2/rss etc connections.
|
||||||
|
|
||||||
protocol_class_path - full python path to the class factory
|
protocol_path - full python path to the class factory
|
||||||
for the protocol used, eg
|
for the protocol used, eg
|
||||||
'src.server.portal.irc.IRCClient'
|
'src.server.portal.irc.IRCClient'
|
||||||
The given class will be instantiated with this handler
|
uid - database uid to the connected player-bot
|
||||||
in a property sessionhandler. It must have a
|
config - dictionary of configuration options, fed as **kwarg
|
||||||
connectionMade() method, responsible for configuring
|
to protocol class' __init__ method.
|
||||||
itself and then calling self.sessionhandler.connect(self)
|
|
||||||
like any other newly connected protocol.
|
The called protocol class must have a method ConnectionMade
|
||||||
|
that calls the portalsession.connect() as a normal protocol.
|
||||||
"""
|
"""
|
||||||
global _MOD_IMPORT
|
global _MOD_IMPORT
|
||||||
if not _MOD_IMPORT:
|
if not _MOD_IMPORT:
|
||||||
from src.utils.utils import variable_from_module as _MOD_IMPORT
|
from src.utils.utils import variable_from_module as _MOD_IMPORT
|
||||||
path, clsname = protocol_path.rsplit(".", 1)
|
path, clsname = protocol_path.rsplit(".", 1)
|
||||||
cls = _MOD_IMPORT(path, clsname)
|
cls = _MOD_IMPORT(path, clsname)
|
||||||
protocol = cls()
|
protocol = cls(**config)
|
||||||
protocol.sessionhandler = self
|
protocol.sessionhandler = self
|
||||||
protocol.connectionMade()
|
protocol.connectionMade()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ class ServerSessionHandler(SessionHandler):
|
||||||
|
|
||||||
# server-side access methods
|
# server-side access methods
|
||||||
|
|
||||||
def start_bot_session(self, protocol_path, uid):
|
def start_bot_session(self, protocol_path, uid, configdict):
|
||||||
"""
|
"""
|
||||||
This method allows the server-side to force the Portal to create
|
This method allows the server-side to force the Portal to create
|
||||||
a new bot session using the protocol specified by protocol_path,
|
a new bot session using the protocol specified by protocol_path,
|
||||||
|
|
@ -271,7 +271,8 @@ class ServerSessionHandler(SessionHandler):
|
||||||
Server.
|
Server.
|
||||||
"""
|
"""
|
||||||
data = {"protocol_path":protocol_path,
|
data = {"protocol_path":protocol_path,
|
||||||
"uid":uid}
|
"uid":uid,
|
||||||
|
"config":configdict}
|
||||||
self.server.amp_protocol.call_remote_PortalAdmin(0,
|
self.server.amp_protocol.call_remote_PortalAdmin(0,
|
||||||
operation=SCONN,
|
operation=SCONN,
|
||||||
data=data)
|
data=data)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue