evennia.accounts.bots¶
Bots are a special child typeclasses of Account that are controlled by the server.
-
class
evennia.accounts.bots.
BotStarter
(*args, **kwargs)[source]¶ Bases:
evennia.scripts.scripts.DefaultScript
This non-repeating script has the sole purpose of kicking its bot into gear when it is initialized.
-
at_repeat
()[source]¶ 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.
-
at_server_reload
()[source]¶ If server reloads we don’t need to reconnect the protocol again, this is handled by the portal reconnect mechanism.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶ Bases:
evennia.scripts.scripts.DefaultScript.MultipleObjectsReturned
-
path
= 'evennia.accounts.bots.BotStarter'¶
-
typename
= 'BotStarter'¶
-
-
class
evennia.accounts.bots.
Bot
(*args, **kwargs)[source]¶ Bases:
evennia.accounts.accounts.DefaultAccount
A Bot will start itself when the server starts (it will generally not do so on a reload - that will be handled by the normal Portal session resync)
-
msg
(text=None, from_obj=None, session=None, options=None, **kwargs)[source]¶ Evennia -> outgoing protocol
-
at_server_shutdown
()[source]¶ We need to handle this case manually since the shutdown may be a reset.
-
exception
DoesNotExist
¶ Bases:
evennia.accounts.accounts.DefaultAccount.DoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
evennia.accounts.accounts.DefaultAccount.MultipleObjectsReturned
-
path
= 'evennia.accounts.bots.Bot'¶
-
typename
= 'Bot'¶
-
-
class
evennia.accounts.bots.
IRCBot
(*args, **kwargs)[source]¶ Bases:
evennia.accounts.bots.Bot
Bot for handling IRC connections.
-
factory_path
= 'evennia.server.portal.irc.IRCBotFactory'¶
-
start
(ev_channel=None, irc_botname=None, irc_channel=None, irc_network=None, irc_port=None, irc_ssl=None)[source]¶ Start by telling the portal to start a new session.
- Parameters
ev_channel (str) – Key of the Evennia channel to connect to.
irc_botname (str) – Name of bot to connect to irc channel. If not set, use self.key.
irc_channel (str) – Name of channel on the form #channelname.
irc_network (str) – URL of the IRC network, like irc.freenode.net.
irc_port (str) – Port number of the irc network, like 6667.
irc_ssl (bool) – Indicates whether to use SSL connection.
-
get_nicklist
(caller)[source]¶ Retrive the nick list from the connected channel.
- Parameters
caller (Object or Account) – The requester of the list. This will be stored and echoed to when the irc network replies with the requested info.
- Notes: Since the return is asynchronous, the caller is stored internally
in a list; all callers in this list will get the nick info once it returns (it is a custom OOB inputfunc option). The callback will not survive a reload (which should be fine, it’s very quick).
-
ping
(caller)[source]¶ Fire a ping to the IRC server.
- Parameters
caller (Object or Account) – The requester of the ping.
-
reconnect
()[source]¶ Force a protocol-side reconnect of the client without having to destroy/recreate the bot “account”.
-
msg
(text=None, **kwargs)[source]¶ Takes text from connected channel (only).
- Parameters
text (str, optional) – Incoming text from channel.
- Keyword Arguments
options (dict) – Options dict with the following allowed keys: - from_channel (str): dbid of a channel this text originated from. - from_obj (list): list of objects sending this text.
-
execute_cmd
(session=None, txt=None, **kwargs)[source]¶ Take incoming data and send it to connected channel. This is triggered by the bot_data_in Inputfunc.
- Parameters
session (Session, optional) – Session responsible for this command. Note that this is the bot.
txt (str, optional) – Command string.
- Keyword Arguments
user (str) – The name of the user who sent the message.
channel (str) – The name of channel the message was sent to.
type (str) – Nature of message. Either ‘msg’, ‘action’, ‘nicklist’ or ‘ping’.
nicklist (list, optional) – Set if type=’nicklist’. This is a list of nicks returned by calling the self.get_nicklist. It must look for a list self._nicklist_callers which will contain all callers waiting for the nicklist.
timings (float, optional) – Set if type=’ping’. This is the return (in seconds) of a ping request triggered with self.ping. The return must look for a list self._ping_callers which will contain all callers waiting for the ping return.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
path
= 'evennia.accounts.bots.IRCBot'¶
-
typename
= 'IRCBot'¶
-
-
class
evennia.accounts.bots.
RSSBot
(*args, **kwargs)[source]¶ Bases:
evennia.accounts.bots.Bot
An RSS relayer. The RSS protocol itself runs a ticker to update its feed at regular intervals.
-
start
(ev_channel=None, rss_url=None, rss_rate=None)[source]¶ Start by telling the portal to start a new RSS session
- Parameters
ev_channel (str) – Key of the Evennia channel to connect to.
rss_url (str) – Full URL to the RSS feed to subscribe to.
rss_rate (int) – How often for the feedreader to update.
- Raises
RuntimeError – If ev_channel does not exist.
-
execute_cmd
(txt=None, session=None, **kwargs)[source]¶ Take incoming data and send it to connected channel. This is triggered by the bot_data_in Inputfunc.
- Parameters
session (Session, optional) – Session responsible for this command.
txt (str, optional) – Command string.
kwargs (dict, optional) – Additional Information passed from bot. Not used by the RSSbot by default.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
path
= 'evennia.accounts.bots.RSSBot'¶
-
typename
= 'RSSBot'¶
-
-
class
evennia.accounts.bots.
GrapevineBot
(*args, **kwargs)[source]¶ Bases:
evennia.accounts.bots.Bot
g Grapevine (https://grapevine.haus) relayer. The channel to connect to is the first name in the settings.GRAPEVINE_CHANNELS list.
-
factory_path
= 'evennia.server.portal.grapevine.RestartingWebsocketServerFactory'¶
-
start
(ev_channel=None, grapevine_channel=None)[source]¶ Start by telling the portal to connect to the grapevine network.
-
msg
(text=None, **kwargs)[source]¶ Takes text from connected channel (only).
- Parameters
text (str, optional) – Incoming text from channel.
- Keyword Arguments
options (dict) – Options dict with the following allowed keys: - from_channel (str): dbid of a channel this text originated from. - from_obj (list): list of objects sending this text.
-
execute_cmd
(txt=None, session=None, event=None, grapevine_channel=None, sender=None, game=None, **kwargs)[source]¶ Take incoming data from protocol and send it to connected channel. This is triggered by the bot_data_in Inputfunc.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
path
= 'evennia.accounts.bots.GrapevineBot'¶
-
typename
= 'GrapevineBot'¶
-