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.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
import slixfeed.xmpp.utility as utility
|
|
|
|
|
2024-01-24 19:11:39 +01:00
|
|
|
async def remove(self, jid):
|
|
|
|
"""
|
|
|
|
Remove JID to roster.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
jid : str
|
|
|
|
Jabber ID.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
None.
|
|
|
|
"""
|
|
|
|
self.update_roster(
|
|
|
|
jid,
|
|
|
|
subscription="remove"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-01-02 12:42:41 +01:00
|
|
|
async def add(self, jid):
|
|
|
|
"""
|
|
|
|
Add JID to roster.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
jid : str
|
|
|
|
Jabber ID.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
None.
|
|
|
|
"""
|
2024-01-27 18:15:28 +01:00
|
|
|
if await utility.get_chat_type(self, jid) == "groupchat":
|
2024-01-02 12:42:41 +01:00
|
|
|
# Check whether JID is in bookmarks; otherwise, add it.
|
|
|
|
print(jid, "is muc")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
await self.get_roster()
|
|
|
|
# Check whether JID is in roster; otherwise, add it.
|
|
|
|
if jid not in self.client_roster.keys():
|
|
|
|
self.send_presence_subscription(
|
|
|
|
pto=jid,
|
2024-01-24 19:11:39 +01:00
|
|
|
pfrom=self.boundjid.bare,
|
2024-01-02 12:42:41 +01:00
|
|
|
ptype="subscribe",
|
2024-01-24 19:11:39 +01:00
|
|
|
pnick=self.alias
|
2024-01-02 12:42:41 +01:00
|
|
|
)
|
|
|
|
self.update_roster(
|
|
|
|
jid,
|
|
|
|
subscription="both"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def remove_subscription(self):
|
|
|
|
"""
|
|
|
|
Remove subscription from contacts that don't share their presence.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
None.
|
|
|
|
"""
|