teamwire_api.groups

Group

class Group(object)

A class representing a group of users

Attributes

  • gid: unicode. The ID of the group
  • title: unicode. The title or name of the group
  • members: list of User objects. The members of the group
  • owner: User object (None if not present). The user that created the group
  • is_circle: boolean. Whether the group is a users circle (i.e. created by an admin in the Teamwire Admin Dashboard)
  • is_list: boolean. Whether the group is a user list (i.e. a list of users created by a normal user)
  • is_public: boolean. Whether the group is public (i.e. visible to and useable by users that are not members of the group itself)

Deprecated attributes

is_managed_group: boolean. Deprecated in SDK v1.2: use is_circle instead
is_user_group: boolean.  Deprecated in SDK v1.2: use is_list instead

get_members

 | get_members()

Method to get the list of members of a group

Returns

a list of User objects

add_members

 | async add_members(members=[])

Coroutine to add members to a group

Arguments

  • members: list of User objects to add to the group

Raises

exceptions.TWInvalidMembersError if any of referenced members are invalid exceptions.TWAuthError if the bot is not authorized to add members to the group exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems

remove_members

 | async remove_members(members=[])

Coroutine to remove members from a group

Arguments

  • members: list of User objects to remove from the group

Raises

exceptions.TWInvalidMembersError if any of referenced members are invalid exceptions.TWAuthError if the bot is not authorized to remove members from the group exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems

is_member

 | is_member(user)

Method to check if a user is member of this group

Arguments

  • user: string UID or User object. A user ID or a User object to be checked for membership in this group

Returns

True if the provided user is a member of the group

Groups

class Groups(object)

An accessor to all the groups visible to the bot

get_group

 | async get_group(gid)

coroutine to get a group by its group id

Arguments

  • gid: unicode. The group id of the group to be retrieved

Returns

a Group object

Raises

exceptions.TWNotFoundError if a group with the provided Group ID doesn't exist exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems

get_list

 | async get_list()

Get list of all groups involving the bot

Returns

a list of Group objects

Raises

exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems

create_group

 | async create_group(title, users=[])

coroutine to create a new user group

Arguments

  • title: unicode. The title, or name of the new group
  • users: list of user objects. The members of the group

Returns

a new Group object

Raises

exceptions.TWInvalidMembersError if any of referenced members are invalid exceptions.TWConnectionError in case of network error or timeout exceptions.TWServerError in case of backend-related problems