Group Chats
The following functions and classes are defined in the phone.group_chat namespace.
The GroupChat class
class GroupChat(object)The core of the discussion part of this framework.
def __init__(self, name, icon, key, transient=False)
name: a string, the name of the character.icon: a displayable.key: any hashable object that is notNone. this must be a unique object proper to thisphone.group_chat.GroupChatobject.transient: a boolean. If true, the group chat is cleared once the discussion is over.
Once created, the following fields can be read and safely modified:
nameicon
while following fields should be read only:
unreaddatetransient
def add_character(self, char)Adds the
*character*charto this group chat, saves the group chat in the*character*’s list of known group chats, and returns the group chat.def remove_character(self, char)Removes the
*character*charfrom this group chat, and removes the group chat from the*character*’s known group chats.def number_of_messages_sent(self, char)Returns the number of messages sent by the
*character*char. IfNoneis passed, returns the total number of messages sent.def clear(self)Clears the group chat’s history.
These objects are hashable (their key will be hashed).
Functions
def group_chat(x)If
xis aphone.group_chat.GroupChatobject, will return that object, otherwise, the group chat with the same key will be returned, or raise aKeyErrorif it wasn’t found.def has_group_chat(key)Returns if a group chat with the key
keyexists.def get_all()Returns a list of every group chats defined.
Example
# default /!\
default eileen_gc = phone.group_chat.GroupChat("Eileen", phone.asset("default_icon.png"), "eileen_gc").add_character("eileen")
or use the define clause of the init phone register statement.
init phone register:
define "Hello":
icon "icon.png" add "eileen" key "hello"