-
Notifications
You must be signed in to change notification settings - Fork 2
groups
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.
>>> 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)
>>> print(py_po.groups.info('app_token', 'group_key'))
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'])
>>> 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
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')
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')
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')