mirror of
https://github.com/evennia/evennia.git
synced 2026-04-02 22:17:17 +02:00
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
|
||||
_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
|
||||
"""
|
||||
|
|
@ -130,4 +130,5 @@ class IRCBot(Bot):
|
|||
self.dbobj.msg(text=text)
|
||||
|
||||
|
||||
def execute_cmd(
|
||||
def execute_cmd(self):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -69,28 +69,29 @@ class PortalSessionHandler(SessionHandler):
|
|||
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
|
||||
protocol instance. Server wants this instance to get
|
||||
a unique sessid and to be connected back as normal. This
|
||||
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
|
||||
'src.server.portal.irc.IRCClient'
|
||||
The given class will be instantiated with this handler
|
||||
in a property sessionhandler. It must have a
|
||||
connectionMade() method, responsible for configuring
|
||||
itself and then calling self.sessionhandler.connect(self)
|
||||
like any other newly connected protocol.
|
||||
uid - database uid to the connected player-bot
|
||||
config - dictionary of configuration options, fed as **kwarg
|
||||
to protocol class' __init__ method.
|
||||
|
||||
The called protocol class must have a method ConnectionMade
|
||||
that calls the portalsession.connect() as a normal protocol.
|
||||
"""
|
||||
global _MOD_IMPORT
|
||||
if not _MOD_IMPORT:
|
||||
from src.utils.utils import variable_from_module as _MOD_IMPORT
|
||||
path, clsname = protocol_path.rsplit(".", 1)
|
||||
cls = _MOD_IMPORT(path, clsname)
|
||||
protocol = cls()
|
||||
protocol = cls(**config)
|
||||
protocol.sessionhandler = self
|
||||
protocol.connectionMade()
|
||||
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ class ServerSessionHandler(SessionHandler):
|
|||
|
||||
# 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
|
||||
a new bot session using the protocol specified by protocol_path,
|
||||
|
|
@ -271,7 +271,8 @@ class ServerSessionHandler(SessionHandler):
|
|||
Server.
|
||||
"""
|
||||
data = {"protocol_path":protocol_path,
|
||||
"uid":uid}
|
||||
"uid":uid,
|
||||
"config":configdict}
|
||||
self.server.amp_protocol.call_remote_PortalAdmin(0,
|
||||
operation=SCONN,
|
||||
data=data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue