2024-01-02 12:42:41 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
|
|
|
1) remove_subscription (clean_roster)
|
|
|
|
Remove presence from contacts that don't share presence.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2024-02-07 01:26:42 +01:00
|
|
|
class XmppRoster:
|
2024-01-02 12:42:41 +01:00
|
|
|
|
2024-02-07 01:26:42 +01:00
|
|
|
async def remove(self, jid):
|
|
|
|
"""
|
|
|
|
Remove JID to roster.
|
2024-01-24 19:11:39 +01:00
|
|
|
|
2024-02-07 01:26:42 +01:00
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
jid : str
|
|
|
|
Jabber ID.
|
2024-01-24 19:11:39 +01:00
|
|
|
|
2024-02-07 01:26:42 +01:00
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
None.
|
|
|
|
"""
|
|
|
|
self.update_roster(jid, subscription="remove")
|
2024-01-24 19:11:39 +01:00
|
|
|
|
|
|
|
|
2024-02-07 01:26:42 +01:00
|
|
|
async def add(self, jid):
|
|
|
|
"""
|
|
|
|
Add JID to roster.
|
2024-01-02 12:42:41 +01:00
|
|
|
|
2024-02-07 01:26:42 +01:00
|
|
|
Add JID to roster if it is not already in roster.
|
2024-01-02 12:42:41 +01:00
|
|
|
|
2024-02-07 01:26:42 +01:00
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
jid : str
|
|
|
|
Jabber ID.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
None.
|
|
|
|
"""
|
2024-01-02 12:42:41 +01:00
|
|
|
await self.get_roster()
|
|
|
|
if jid not in self.client_roster.keys():
|
2024-02-07 01:26:42 +01:00
|
|
|
self.update_roster(jid, subscription="both")
|
2024-01-02 12:42:41 +01:00
|
|
|
|