evennia.accounts package¶
This sub-package defines the out-of-character entities known as Accounts. These are equivalent to ‘accounts’ and can puppet one or more Objects depending on settings. An Account has no in-game existence.
Subpackages¶
Submodules¶
evennia.accounts.accounts module¶
Typeclass for Account objects
Note that this object is primarily intended to store OOC information, not game info! This object represents the actual user (not their character) and has NO actual presence in the game world (this is handled by the associated character object, so you should customize that instead for most things).
-
class
evennia.accounts.accounts.DefaultAccount(*args, **kwargs)[source]¶ Bases:
evennia.accounts.models.AccountDBThis is the base Typeclass for all Accounts. Accounts represent the person playing the game and tracks account info, password etc. They are OOC entities without presence in-game. An Account can connect to a Character Object in order to “enter” the game.
Account Typeclass API:
Available properties (only available on initiated typeclass objects)
key (string) - name of account
name (string)- wrapper for user.username
- aliases (list of strings) - aliases to the object. Will be saved to
database as AliasDB entries but returned as strings.
dbref (int, read-only) - unique #id-number. Also “id” can be used.
date_created (string) - time stamp of object creation
permissions (list of strings) - list of permission strings
user (User, read-only) - django User authorization object
- obj (Object) - game object controlled by account. ‘character’ can also
be used.
sessions (list of Sessions) - sessions connected to this account
is_superuser (bool, read-only) - if the connected user is a superuser
Handlers
locks - lock-handler: use locks.add() to add new lock strings
- db - attribute-handler: store/retrieve database attributes on this
self.db.myattr=val, val=self.db.myattr
- ndb - non-persistent attribute handler: same as db but does not
create a database entry when storing data
scripts - script-handler. Add new scripts to object with scripts.add()
cmdset - cmdset-handler. Use cmdset.add() to add new cmdsets to object
nicks - nick-handler. New nicks with nicks.add().
Helper methods
msg(text=None, from_obj=None, session=None, options=None, **kwargs)
execute_cmd(raw_string)
- search(ostring, global_search=False, attribute_name=None,
use_nicks=False, location=None, ignore_errors=False, account=False)
is_typeclass(typeclass, exact=False)
swap_typeclass(new_typeclass, clean_attributes=False, no_default=True)
access(accessing_obj, access_type=’read’, default=False, no_superuser_bypass=False)
check_permstring(permstring)
Hook methods
basetype_setup() at_account_creation()
- > note that the following hooks are also found on Objects and are
usually handled on the character level:
at_init()
at_access()
at_cmdset_get(**kwargs)
at_first_login()
at_post_login(session=None)
at_disconnect()
at_message_receive()
at_message_send()
at_server_reload()
at_server_shutdown()
-
exception
DoesNotExist¶ Bases:
evennia.accounts.models.DoesNotExist
-
exception
MultipleObjectsReturned¶ Bases:
evennia.accounts.models.MultipleObjectsReturned
-
_DefaultAccount__get_single_puppet()¶ This is a legacy convenience link for use with MULTISESSION_MODE.
- Returns
- Users of MULTISESSION_MODE 0 or 1 will
always get the first puppet back. Users of higher `MULTISESSION_MODE`s will get a list of all puppeted objects.
- Return type
puppets (Object or list)
-
_meta= <Options for DefaultAccount>¶
-
_send_to_connect_channel(message)[source]¶ Helper method for loading and sending to the comm channel dedicated to connection messages.
- Parameters
message (str) – A message to send to the connect channel.
-
access(accessing_obj, access_type='read', default=False, no_superuser_bypass=False, **kwargs)[source]¶ Determines if another object has permission to access this object in whatever way.
- Parameters
accessing_obj (Object) – Object trying to access this one.
access_type (str, optional) – Type of access sought.
default (bool, optional) – What to return if no lock of access_type was found
no_superuser_bypass (bool, optional) – Turn off superuser lock bypassing. Be careful with this one.
- Kwargs:
kwargs (any): Passed to the at_access hook along with the result.
- Returns
Result of access check.
- Return type
result (bool)
-
at_access(result, accessing_obj, access_type, **kwargs)[source]¶ - This is triggered after an access-call on this Account has
completed.
- Parameters
result (bool) – The result of the access check.
accessing_obj (any) – The object requesting the access check.
access_type (str) – The type of access checked.
- Kwargs:
- kwargs (any): These are passed on from the access check
and can be used to relay custom instructions from the check mechanism.
Notes
This method cannot affect the result of the lock check and its return value is not used in any way. It can be used e.g. to customize error messages in a central location or create other effects based on the access result.
-
at_account_creation()[source]¶ This is called once, the very first time the account is created (i.e. first time they register with the game). It’s a good place to store attributes all accounts should have, like configuration values etc.
-
at_cmdset_get(**kwargs)[source]¶ Called just before cmdsets on this account are requested by the command handler. The cmdsets are available as self.cmdset. If changes need to be done on the fly to the cmdset before passing them on to the cmdhandler, this is the place to do it. This is called also if the account currently have no cmdsets. kwargs are usually not used unless the cmdset is generated dynamically.
-
at_disconnect(reason=None, **kwargs)[source]¶ Called just before user is disconnected.
- Parameters
reason (str, optional) – The reason given for the disconnect, (echoed to the connection channel by default).
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
-
at_failed_login(session, **kwargs)[source]¶ Called by the login process if a user account is targeted correctly but provided with an invalid password. By default it does nothing, but exists to be overriden.
- Parameters
session (session) – Session logging in.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
-
at_first_login(**kwargs)[source]¶ Called the very first time this account logs into the game. Note that this is called before at_pre_login, so no session is established and usually no character is yet assigned at this point. This hook is intended for account-specific setup like configurations.
- Parameters
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
-
at_first_save()[source]¶ This is a generic hook called by Evennia when this object is saved to the database the very first time. You generally don’t override this method but the hooks called by it.
-
at_init()[source]¶ This is always called whenever this object is initiated – that is, whenever it its typeclass is cached from memory. This happens on-demand first time the object is used or activated in some way after being created but also after each server restart or reload. In the case of account objects, this usually happens the moment the account logs in or reconnects after a reload.
-
at_look(target=None, session=None, **kwargs)[source]¶ Called when this object executes a look. It allows to customize just what this means.
- Parameters
target (Object or list, optional) – An object or a list objects to inspect.
session (Session, optional) – The session doing this look.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
- Returns
- A prepared look string, ready to send
off to any recipient (usually to ourselves)
- Return type
look_string (str)
-
at_msg_receive(text=None, from_obj=None, **kwargs)[source]¶ This hook is called whenever someone sends a message to this object using the msg method.
Note that from_obj may be None if the sender did not include itself as an argument to the obj.msg() call - so you have to check for this. .
Consider this a pre-processing method before msg is passed on to the user session. If this method returns False, the msg will not be passed on.
- Parameters
text (str, optional) – The message received.
from_obj (any, optional) – The object sending the message.
- Kwargs:
This includes any keywords sent to the msg method.
- Returns
If this message should be received.
- Return type
receive (bool)
Notes
If this method returns False, the msg operation will abort without sending the message.
-
at_msg_send(text=None, to_obj=None, **kwargs)[source]¶ This is a hook that is called when this object sends a message to another object with obj.msg(text, to_obj=obj).
- Parameters
text (str, optional) – Text to send.
to_obj (any, optional) – The object to send to.
- Kwargs:
Keywords passed from msg()
Notes
Since this method is executed by from_obj, if no from_obj was passed to DefaultCharacter.msg this hook will never get called.
-
at_password_change(**kwargs)[source]¶ Called after a successful password set/modify.
- Parameters
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
-
at_post_disconnect(**kwargs)[source]¶ This is called after disconnection is complete. No messages can be relayed to the account from here. After this call, the account should not be accessed any more, making this a good spot for deleting it (in the case of a guest account account, for example).
- Parameters
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
-
at_post_login(session=None, **kwargs)[source]¶ Called at the end of the login process, just before letting the account loose.
- Parameters
session (Session, optional) – Session logging in, if any.
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
Notes
This is called before an eventual Character’s at_post_login hook. By default it is used to set up auto-puppeting based on MULTISESSION_MODE.
-
at_pre_login(**kwargs)[source]¶ Called every time the user logs in, just before the actual login-state is set.
- Parameters
**kwargs (dict) – Arbitrary, optional arguments for users overriding the call (unused by default).
-
at_server_reload()[source]¶ This hook is called whenever the server is shutting down for restart/reboot. If you want to, for example, save non-persistent properties across a restart, this is the place to do it.
-
at_server_shutdown()[source]¶ This hook is called whenever the server is shutting down fully (i.e. not for a restart).
-
classmethod
authenticate(username, password, ip='', **kwargs)[source]¶ Checks the given username/password against the database to see if the credentials are valid.
Note that this simply checks credentials and returns a valid reference to the user– it does not log them in!
To finish the job: After calling this from a Command, associate the account with a Session: - session.sessionhandler.login(session, account)
…or after calling this from a View, associate it with an HttpRequest: - django.contrib.auth.login(account, request)
- Parameters
username (str) – Username of account
password (str) – Password of account
ip (str, optional) – IP address of client
- Kwargs:
session (Session, optional): Session requesting authentication
- Returns
- Account whose credentials were
provided if not banned.
errors (list): Error messages of any failures.
- Return type
account (DefaultAccount, None)
-
basetype_setup()[source]¶ This sets up the basic properties for an account. Overload this with at_account_creation rather than changing this method.
-
property
character¶ This is a legacy convenience link for use with MULTISESSION_MODE.
- Returns
- Users of MULTISESSION_MODE 0 or 1 will
always get the first puppet back. Users of higher `MULTISESSION_MODE`s will get a list of all puppeted objects.
- Return type
puppets (Object or list)
-
property
characters¶
-
property
connection_time¶ Returns the maximum connection time of all connected sessions in seconds. Returns nothing if there are no sessions.
-
classmethod
create(*args, **kwargs)[source]¶ Creates an Account (or Account/Character pair for MULTISESSION_MODE<2) with default (or overridden) permissions and having joined them to the appropriate default channels.
- Kwargs:
username (str): Username of Account owner password (str): Password of Account owner email (str, optional): Email address of Account owner ip (str, optional): IP address of requesting connection guest (bool, optional): Whether or not this is to be a Guest account
permissions (str, optional): Default permissions for the Account typeclass (str, optional): Typeclass to use for new Account character_typeclass (str, optional): Typeclass to use for new char
when applicable.
- Returns
Account if successfully created; None if not errors (list): List of error messages in string form
- Return type
account (Account)
-
delete(*args, **kwargs)[source]¶ Deletes the account permanently.
Notes
- *args and **kwargs are passed on to the base delete
mechanism (these are usually not used).
-
disconnect_session_from_account(session, reason=None)[source]¶ Access method for disconnecting a given session from the account (connection happens automatically in the sessionhandler)
- Parameters
session (Session) – Session to disconnect.
reason (str, optional) – Eventual reason for the disconnect.
-
execute_cmd(raw_string, session=None, **kwargs)[source]¶ Do something as this account. This method is never called normally, but only when the account object itself is supposed to execute the command. It takes account nicks into account, but not nicks of eventual puppets.
- Parameters
raw_string (str) – Raw command input coming from the command line.
session (Session, optional) – The session to be responsible for the command-send
- Kwargs:
- kwargs (any): Other keyword arguments will be added to the
found command object instance as variables before it executes. This is unused by default Evennia but may be used to set flags and change operating paramaters for commands at run-time.
-
get_all_puppets()[source]¶ Get all currently puppeted objects.
- Returns
- All puppeted objects currently controlled
by this Account.
- Return type
puppets (list)
-
get_puppet(session)[source]¶ Get an object puppeted by this session through this account. This is the main method for retrieving the puppeted object from the account’s end.
- Parameters
session (Session) – Find puppeted object based on this session
- Returns
The matching puppeted object, if any.
- Return type
puppet (Object)
-
classmethod
get_username_validators(validator_config=[{'NAME': 'django.contrib.auth.validators.ASCIIUsernameValidator'}, {'NAME': 'django.core.validators.MinLengthValidator', 'OPTIONS': {'limit_value': 3}}, {'NAME': 'django.core.validators.MaxLengthValidator', 'OPTIONS': {'limit_value': 30}}, {'NAME': 'evennia.server.validators.EvenniaUsernameAvailabilityValidator'}])[source]¶ Retrieves and instantiates validators for usernames.
- Parameters
validator_config (list) – List of dicts comprising the battery of validators to apply to a username.
- Returns
List of instantiated Validator objects.
- Return type
validators (list)
-
property
idle_time¶ Returns the idle time of the least idle session in seconds. If no sessions are connected it returns nothing.
-
classmethod
is_banned(**kwargs)[source]¶ Checks if a given username or IP is banned.
- Kwargs:
ip (str, optional): IP address. username (str, optional): Username.
- Returns
Whether either is banned or not.
- Return type
is_banned (bool)
-
msg(text=None, from_obj=None, session=None, options=None, **kwargs)[source]¶ Evennia -> User This is the main route for sending data back to the user from the server.
- Parameters
text (str or tuple, optional) – The message to send. This is treated internally like any send-command, so its value can be a tuple if sending multiple arguments to the text oob command.
from_obj (Object or Account or list, optional) – Object sending. If given, its at_msg_send() hook will be called. If iterable, call on all entities.
session (Session or list, optional) – Session object or a list of Sessions to receive this send. If given, overrules the default send behavior for the current MULTISESSION_MODE.
options (list) – Protocol-specific options. Passed on to the protocol.
- Kwargs:
any (dict): All other keywords are passed on to the protocol.
-
classmethod
normalize_username(username)[source]¶ Django: Applies NFKC Unicode normalization to usernames so that visually identical characters with different Unicode code points are considered identical.
(This deals with the Turkish “i” problem and similar annoyances. Only relevant if you go out of your way to allow Unicode usernames though– Evennia accepts ASCII by default.)
In this case we’re simply piggybacking on this feature to apply additional normalization per Evennia’s standards.
-
objects= <evennia.accounts.manager.AccountManager object>¶
-
path= 'evennia.accounts.accounts.DefaultAccount'¶
-
property
puppet¶ This is a legacy convenience link for use with MULTISESSION_MODE.
- Returns
- Users of MULTISESSION_MODE 0 or 1 will
always get the first puppet back. Users of higher `MULTISESSION_MODE`s will get a list of all puppeted objects.
- Return type
puppets (Object or list)
-
puppet_object(session, obj)[source]¶ Use the given session to control (puppet) the given object (usually a Character type).
- Parameters
session (Session) – session to use for puppeting
obj (Object) – the object to start puppeting
- Raises
RuntimeError – If puppeting is not possible, the exception.msg will contain the reason.
-
search(searchdata, return_puppet=False, search_object=False, typeclass=None, nofound_string=None, multimatch_string=None, use_nicks=True, **kwargs)[source]¶ This is similar to DefaultObject.search but defaults to searching for Accounts only.
- Parameters
searchdata (str or int) – Search criterion, the Account’s key or dbref to search for.
return_puppet (bool, optional) – Instructs the method to return matches as the object the Account controls rather than the Account itself (or None) if nothing is puppeted).
search_object (bool, optional) – Search for Objects instead of Accounts. This is used by e.g. the @examine command when wanting to examine Objects while OOC.
typeclass (Account typeclass, optional) – Limit the search only to this particular typeclass. This can be used to limit to specific account typeclasses or to limit the search to a particular Object typeclass if search_object is True.
nofound_string (str, optional) – A one-time error message to echo if searchdata leads to no matches. If not given, will fall back to the default handler.
multimatch_string (str, optional) – A one-time error message to echo if searchdata leads to multiple matches. If not given, will fall back to the default handler.
use_nicks (bool, optional) – Use account-level nick replacement.
- Returns
A single Account or Object match.
- Return type
match (Account, Object or None)
Notes
Extra keywords are ignored, but are allowed in call in order to make API more consistent with objects.objects.DefaultObject.search.
-
set_password(password, **kwargs)[source]¶ Applies the given password to the account. Logs and triggers the at_password_change hook.
- Parameters
password (str) – Password to set.
Notes
This is called by Django also when logging in; it should not be mixed up with validation, since that would mean old passwords in the database (pre validation checks) could get invalidated.
-
typename= 'DefaultAccount'¶
-
unpuppet_object(session)[source]¶ Disengage control over an object.
- Parameters
session (Session or list) – The session or a list of sessions to disengage from their puppets.
- Raises
RuntimeError With message about error. –
-
classmethod
validate_password(password, account=None)[source]¶ Checks the given password against the list of Django validators enabled in the server.conf file.
- Parameters
password (str) – Password to validate
- Kwargs:
- account (DefaultAccount, optional): Account object to validate the
password for. Optional, but Django includes some validators to do things like making sure users aren’t setting passwords to the same value as their username. If left blank, these user-specific checks are skipped.
- Returns
Whether or not the password passed validation error (ValidationError, None): Any validation error(s) raised. Multiple
errors can be nested within a single object.
- Return type
valid (bool)
-
classmethod
validate_username(username)[source]¶ Checks the given username against the username validator associated with Account objects, and also checks the database to make sure it is unique.
- Parameters
username (str) – Username to validate
- Returns
Whether or not the password passed validation errors (list): Error messages of any failures
- Return type
valid (bool)
evennia.accounts.admin module¶
-
class
evennia.accounts.admin.AccountAttributeInline(parent_model, admin_site)[source]¶ Bases:
evennia.typeclasses.admin.AttributeInlineInline Account Attributes.
-
property
media¶
-
model¶ alias of
evennia.accounts.models.AccountDB_db_attributes
-
property
-
class
evennia.accounts.admin.AccountDBAdmin(model, admin_site)[source]¶ Bases:
django.contrib.auth.admin.UserAdminThis is the main creation screen for Users/accounts
-
add_fieldsets= ((None, {'fields': ('username', 'password1', 'password2', 'email'), 'description': '<i>These account details are shared by the admin system and the game.</i>'}),)¶
-
add_form¶ alias of
AccountDBCreationForm
-
fieldsets= ((None, {'fields': ('username', 'password', 'email')}), ('Website profile', {'fields': ('first_name', 'last_name'), 'description': '<i>These are not used in the default system.</i>'}), ('Website dates', {'fields': ('last_login', 'date_joined'), 'description': '<i>Relevant only to the website.</i>'}), ('Website Permissions', {'fields': ('is_active', 'is_staff', 'is_superuser', 'user_permissions', 'groups'), 'description': '<i>These are permissions/permission groups for accessing the admin site. They are unrelated to in-game access rights.</i>'}), ('Game Options', {'fields': ('db_typeclass_path', 'db_cmdset_storage', 'db_lock_storage'), 'description': '<i>These are attributes that are more relevant to gameplay.</i>'}))¶
-
form¶ alias of
AccountDBChangeForm
-
inlines= [<class 'evennia.accounts.admin.AccountTagInline'>, <class 'evennia.accounts.admin.AccountAttributeInline'>]¶
-
list_display= ('username', 'email', 'is_staff', 'is_superuser')¶
-
property
media¶
-
-
class
evennia.accounts.admin.AccountDBChangeForm(*args, **kwargs)[source]¶ Bases:
django.contrib.auth.forms.UserChangeFormModify the accountdb class.
-
class
Meta[source]¶ Bases:
object-
fields= '__all__'¶
-
model¶ alias of
evennia.accounts.models.AccountDB
-
-
_meta= <django.forms.models.ModelFormOptions object>¶
-
base_fields= {'date_joined': <django.forms.fields.DateTimeField object>, 'db_attributes': <django.forms.models.ModelMultipleChoiceField object>, 'db_cmdset_storage': <django.forms.fields.CharField object>, 'db_is_bot': <django.forms.fields.BooleanField object>, 'db_is_connected': <django.forms.fields.BooleanField object>, 'db_key': <django.forms.fields.CharField object>, 'db_lock_storage': <django.forms.fields.CharField object>, 'db_tags': <django.forms.models.ModelMultipleChoiceField object>, 'db_typeclass_path': <django.forms.fields.CharField object>, 'email': <django.forms.fields.EmailField object>, 'first_name': <django.forms.fields.CharField object>, 'groups': <django.forms.models.ModelMultipleChoiceField object>, 'is_active': <django.forms.fields.BooleanField object>, 'is_staff': <django.forms.fields.BooleanField object>, 'is_superuser': <django.forms.fields.BooleanField object>, 'last_login': <django.forms.fields.DateTimeField object>, 'last_name': <django.forms.fields.CharField object>, 'password': <django.contrib.auth.forms.ReadOnlyPasswordHashField object>, 'user_permissions': <django.forms.models.ModelMultipleChoiceField object>, 'username': <django.forms.fields.RegexField object>}¶
-
declared_fields= {'password': <django.contrib.auth.forms.ReadOnlyPasswordHashField object>, 'username': <django.forms.fields.RegexField object>}¶
-
property
media¶
-
class
-
class
evennia.accounts.admin.AccountDBCreationForm(*args, **kwargs)[source]¶ Bases:
django.contrib.auth.forms.UserCreationFormCreate a new AccountDB instance.
-
class
Meta[source]¶ Bases:
object-
fields= '__all__'¶
-
model¶ alias of
evennia.accounts.models.AccountDB
-
-
_meta= <django.forms.models.ModelFormOptions object>¶
-
base_fields= {'date_joined': <django.forms.fields.DateTimeField object>, 'db_attributes': <django.forms.models.ModelMultipleChoiceField object>, 'db_cmdset_storage': <django.forms.fields.CharField object>, 'db_is_bot': <django.forms.fields.BooleanField object>, 'db_is_connected': <django.forms.fields.BooleanField object>, 'db_key': <django.forms.fields.CharField object>, 'db_lock_storage': <django.forms.fields.CharField object>, 'db_tags': <django.forms.models.ModelMultipleChoiceField object>, 'db_typeclass_path': <django.forms.fields.CharField object>, 'email': <django.forms.fields.EmailField object>, 'first_name': <django.forms.fields.CharField object>, 'groups': <django.forms.models.ModelMultipleChoiceField object>, 'is_active': <django.forms.fields.BooleanField object>, 'is_staff': <django.forms.fields.BooleanField object>, 'is_superuser': <django.forms.fields.BooleanField object>, 'last_login': <django.forms.fields.DateTimeField object>, 'last_name': <django.forms.fields.CharField object>, 'password': <django.forms.fields.CharField object>, 'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>, 'user_permissions': <django.forms.models.ModelMultipleChoiceField object>, 'username': <django.forms.fields.RegexField object>}¶
-
declared_fields= {'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>, 'username': <django.forms.fields.RegexField object>}¶
-
property
media¶
-
class
-
class
evennia.accounts.admin.AccountForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]¶ Bases:
django.forms.models.ModelFormDefines how to display Accounts
-
class
Meta[source]¶ Bases:
object-
fields= '__all__'¶
-
model¶ alias of
evennia.accounts.models.AccountDB
-
-
_meta= <django.forms.models.ModelFormOptions object>¶
-
base_fields= {'date_joined': <django.forms.fields.DateTimeField object>, 'db_attributes': <django.forms.models.ModelMultipleChoiceField object>, 'db_cmdset_storage': <django.forms.fields.CharField object>, 'db_is_bot': <django.forms.fields.BooleanField object>, 'db_is_connected': <django.forms.fields.BooleanField object>, 'db_key': <django.forms.fields.RegexField object>, 'db_lock_storage': <django.forms.fields.CharField object>, 'db_permissions': <django.forms.fields.CharField object>, 'db_tags': <django.forms.models.ModelMultipleChoiceField object>, 'db_typeclass_path': <django.forms.fields.CharField object>, 'email': <django.forms.fields.EmailField object>, 'first_name': <django.forms.fields.CharField object>, 'groups': <django.forms.models.ModelMultipleChoiceField object>, 'is_active': <django.forms.fields.BooleanField object>, 'is_staff': <django.forms.fields.BooleanField object>, 'is_superuser': <django.forms.fields.BooleanField object>, 'last_login': <django.forms.fields.DateTimeField object>, 'last_name': <django.forms.fields.CharField object>, 'password': <django.forms.fields.CharField object>, 'user_permissions': <django.forms.models.ModelMultipleChoiceField object>, 'username': <django.forms.fields.CharField object>}¶
-
declared_fields= {'db_cmdset_storage': <django.forms.fields.CharField object>, 'db_key': <django.forms.fields.RegexField object>, 'db_lock_storage': <django.forms.fields.CharField object>, 'db_permissions': <django.forms.fields.CharField object>, 'db_typeclass_path': <django.forms.fields.CharField object>}¶
-
property
media¶
-
class
-
class
evennia.accounts.admin.AccountInline(parent_model, admin_site)[source]¶ Bases:
django.contrib.admin.options.StackedInlineInline creation of Account
-
extra= 1¶
-
fieldsets= (('In-game Permissions and Locks', {'fields': ('db_lock_storage',), 'description': '<i>These are permissions/locks for in-game use. They are unrelated to website access rights.</i>'}), ('In-game Account data', {'fields': ('db_typeclass_path', 'db_cmdset_storage'), 'description': '<i>These fields define in-game-specific properties for the Account object in-game.</i>'}))¶
-
form¶ alias of
AccountForm
-
max_num= 1¶
-
property
media¶
-
model¶ alias of
evennia.accounts.models.AccountDB
-
template= 'admin/accounts/stacked.html'¶
-
-
class
evennia.accounts.admin.AccountTagInline(parent_model, admin_site)[source]¶ Bases:
evennia.typeclasses.admin.TagInlineInline Account Tags.
-
property
media¶
-
model¶ alias of
evennia.accounts.models.AccountDB_db_tags
-
property
evennia.accounts.bots module¶
Bots are a special child typeclasses of Account that are controlled by the server.
-
class
evennia.accounts.bots.Bot(*args, **kwargs)[source]¶ Bases:
evennia.accounts.accounts.DefaultAccountA 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)
-
exception
DoesNotExist¶ Bases:
evennia.accounts.accounts.DoesNotExist
-
exception
MultipleObjectsReturned¶ Bases:
evennia.accounts.accounts.MultipleObjectsReturned
-
_meta= <Options for Bot>¶
-
at_server_shutdown()[source]¶ We need to handle this case manually since the shutdown may be a reset.
-
msg(text=None, from_obj=None, session=None, options=None, **kwargs)[source]¶ Evennia -> outgoing protocol
-
path= 'evennia.accounts.bots.Bot'¶
-
typename= 'Bot'¶
-
exception
-
class
evennia.accounts.bots.BotStarter(*args, **kwargs)[source]¶ Bases:
evennia.scripts.scripts.DefaultScriptThis non-repeating script has the sole purpose of kicking its bot into gear when it is initialized.
-
exception
DoesNotExist¶ Bases:
evennia.scripts.scripts.DoesNotExist
-
exception
MultipleObjectsReturned¶ Bases:
evennia.scripts.scripts.MultipleObjectsReturned
-
_meta= <Options for BotStarter>¶
-
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.
-
path= 'evennia.accounts.bots.BotStarter'¶
-
typename= 'BotStarter'¶
-
exception
-
class
evennia.accounts.bots.GrapevineBot(*args, **kwargs)[source]¶ Bases:
evennia.accounts.bots.Botg Grapevine (https://grapevine.haus) relayer. The channel to connect to is the first name in the settings.GRAPEVINE_CHANNELS list.
-
exception
DoesNotExist¶ Bases:
evennia.accounts.bots.DoesNotExist
-
exception
MultipleObjectsReturned¶ Bases:
evennia.accounts.bots.MultipleObjectsReturned
-
_meta= <Options for GrapevineBot>¶
-
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.
-
factory_path= 'evennia.server.portal.grapevine.RestartingWebsocketServerFactory'¶
-
msg(text=None, **kwargs)[source]¶ Takes text from connected channel (only).
- Parameters
text (str, optional) – Incoming text from channel.
- Kwargs:
- 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.
-
path= 'evennia.accounts.bots.GrapevineBot'¶
-
start(ev_channel=None, grapevine_channel=None)[source]¶ Start by telling the portal to connect to the grapevine network.
-
typename= 'GrapevineBot'¶
-
exception
-
class
evennia.accounts.bots.IRCBot(*args, **kwargs)[source]¶ Bases:
evennia.accounts.bots.BotBot for handling IRC connections.
-
exception
DoesNotExist¶ Bases:
evennia.accounts.bots.DoesNotExist
-
exception
MultipleObjectsReturned¶ Bases:
evennia.accounts.bots.MultipleObjectsReturned
-
_meta= <Options for IRCBot>¶
-
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.
- Kwargs:
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.
-
factory_path= 'evennia.server.portal.irc.IRCBotFactory'¶
-
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).
-
msg(text=None, **kwargs)[source]¶ Takes text from connected channel (only).
- Parameters
text (str, optional) – Incoming text from channel.
- Kwargs:
- 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.
-
path= 'evennia.accounts.bots.IRCBot'¶
-
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”.
-
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.
-
typename= 'IRCBot'¶
-
exception
-
class
evennia.accounts.bots.RSSBot(*args, **kwargs)[source]¶ Bases:
evennia.accounts.bots.BotAn RSS relayer. The RSS protocol itself runs a ticker to update its feed at regular intervals.
-
exception
DoesNotExist¶ Bases:
evennia.accounts.bots.DoesNotExist
-
exception
MultipleObjectsReturned¶ Bases:
evennia.accounts.bots.MultipleObjectsReturned
-
_meta= <Options for RSSBot>¶
-
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.
-
path= 'evennia.accounts.bots.RSSBot'¶
-
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.
-
typename= 'RSSBot'¶
-
exception
evennia.accounts.manager module¶
The managers for the custom Account object and permissions.
evennia.accounts.models module¶
Account
The account class is an extension of the default Django user class, and is customized for the needs of Evennia.
We use the Account to store a more mud-friendly style of permission system as well as to allow the admin more flexibility by storing attributes on the Account. Within the game we should normally use the Account manager’s methods to create users so that permissions are set correctly.
To make the Account model more flexible for your own game, it can also persistently store attributes of its own. This is ideal for extra account info and OOC account configuration variables etc.
-
class
evennia.accounts.models.AccountDB(*args, **kwargs)[source]¶ Bases:
evennia.typeclasses.models.TypedObject,django.contrib.auth.models.AbstractUserThis is a special model using Django’s ‘profile’ functionality and extends the default Django User model. It is defined as such by use of the variable AUTH_PROFILE_MODULE in the settings. One accesses the fields/methods. We try use this model as much as possible rather than User, since we can customize this to our liking.
The TypedObject supplies the following (inherited) properties:
key - main name
typeclass_path - the path to the decorating typeclass
typeclass - auto-linked typeclass
date_created - time stamp of object creation
permissions - perm strings
dbref - #id of object
db - persistent attribute storage
ndb - non-persistent attribute storage
The AccountDB adds the following properties:
is_connected - If any Session is currently connected to this Account
name - alias for user.username
sessions - sessions connected to this account
is_superuser - bool if this account is a superuser
is_bot - bool if this account is a bot and not a real account
-
exception
DoesNotExist¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
_AccountDB__cmdset_storage_del()¶ Deleter. Allows for del self.name
-
_AccountDB__cmdset_storage_get()¶ Getter. Allows for value = self.name. Returns a list of cmdset_storage.
-
_AccountDB__cmdset_storage_set(value)¶ Setter. Allows for self.name = value. Stores as a comma-separated string.
-
_AccountDB__uid_del()¶
-
_AccountDB__uid_get()¶ Getter. Retrieves the user id
-
_AccountDB__uid_set(value)¶
-
_AccountDB__username_del()¶
-
_AccountDB__username_get()¶
-
_AccountDB__username_set(value)¶
-
_is_deleted= False¶
-
_meta= <Options for AccountDB>¶
-
account_subscription_set¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
property
cmdset_storage¶ Getter. Allows for value = self.name. Returns a list of cmdset_storage.
-
db_attributes¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
db_cmdset_storage¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
db_is_bot¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
db_is_connected¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)¶
-
get_next_by_db_date_created(*, field=<django.db.models.fields.DateTimeField: db_date_created>, is_next=True, **kwargs)¶
-
get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)¶
-
get_previous_by_db_date_created(*, field=<django.db.models.fields.DateTimeField: db_date_created>, is_next=False, **kwargs)¶
-
groups¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
hide_from_accounts_set¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
id¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
property
is_bot¶ A wrapper for getting database field db_is_bot.
-
property
is_connected¶ A wrapper for getting database field db_is_connected.
-
property
key¶
-
logentry_set¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
property
name¶
-
objectdb_set¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
objects= <evennia.accounts.manager.AccountDBManager object>¶
-
path= 'evennia.accounts.models.AccountDB'¶
-
receiver_account_set¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
scriptdb_set¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
sender_account_set¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
typename= 'SharedMemoryModelBase'¶
-
property
uid¶ Getter. Retrieves the user id
-
user_permissions¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
evennia.accounts.tests module¶
-
class
evennia.accounts.tests.TestAccountSessionHandler(methodName='runTest')[source]¶ Bases:
unittest.case.TestCaseCheck AccountSessionHandler class
-
class
evennia.accounts.tests.TestDefaultAccount(methodName='runTest')[source]¶ Bases:
unittest.case.TestCaseCheck DefaultAccount class
-
test_puppet_object_already_puppeting()[source]¶ Check puppet_object method called, already puppeting this
-
-
class
evennia.accounts.tests.TestDefaultAccountAuth(methodName='runTest')[source]¶
-
class
evennia.accounts.tests.TestDefaultAccountEv(methodName='runTest')[source]¶ Bases:
evennia.utils.test_resources.EvenniaTestTesting using the EvenniaTest parent
-
class
evennia.accounts.tests.TestDefaultGuest(methodName='runTest')[source]¶ Bases:
evennia.utils.test_resources.EvenniaTestCheck DefaultGuest class
-
_overridden_settings= {'GUEST_ENABLED': True, 'GUEST_LIST': ['bruce_wayne']}¶
-
ip= '212.216.134.22'¶
-