Skip to content
KronosKoderS edited this page Nov 11, 2015 · 2 revisions

============================================== groups - Group Management for the Pushover API

This module defines functions and classes used for handling groups on the Pushover servers. Users can be added, removed, activated, or deactivated from a group. Information can also be queried about the group.

Group Information and Renaming:

Using the GroupManager class:

>>> import py_pushover as py_po
>>> gm = py_po.groups.GroupManager('app_token', 'group_key')
>>> print(gm.info())

You can also use the group property to query information on the group. This is dynamically updated with every call to the group:

>>> print(gm.group.name)
>>> print(len(gm.group.users))
>>> print(gm.group.users[0].device)

Using the function call

>>> print(py_po.groups.info('app_token', 'group_key'))

Renaming the group

Using the GroupManager class

>>> gm.rename('group name')
>>> print(gm.group.name)

Using the function calls

>>> py_po.groups.rename('app_token', 'group_key', 'group name')
>>> print(py_po.groups.info('app_token', 'group_key')['name'])

User Management for a Group:

Adding a user:

>>> gm.add_user('user_key')
>>> py_po.groups.add_user('app_token', 'group_key', 'user_key')

You can also add specifying information for the user:

>>> gm.add_user('user_key',
...     device='android',
...     memo='Users android device')  # adds only device 'android' for user to group.  Attach a memo to the addition

Removing a user:

Using the Class method:

>>> gm.remove_user('user_key')

You can also use the dynamic group property to select a user

>>> gm.remove_user(gm.group.users[0].user_key)

Using the function call

>>> py_po.groups.remove_user('app_token', 'group_key', 'user_key')

Disable a user

Disabling a user doesn't remove them from the group, but disables any alerts sent to the group to be sent to them

Using the Class method call

>>> gm.disable_user('user_key')

You can also use the dynamic group property >>> gm.disable_user(gm.group.users[0].user_key)

Using the function call

>>> py_po.groups.disable_user('app_token', 'group_key', 'user_key')

Enable a user

Enabling a user does the exact opposite of the disable user. An enabled user will receive messages sent to the group.

Using the Class method:

>>> gm.enable_user('user_key')

You can also use the dynamic group property:

>>> gm.enable_user(gm.group.users[0].user_key)

Using the function call:

>>> py_po.groups.enable_user('app_token', 'group_key', 'user_key')
Clone this wiki locally