AuM implements ICapContact
This commit is contained in:
parent
1ed2be8ea9
commit
a672c146c9
2 changed files with 15 additions and 11 deletions
|
|
@ -25,6 +25,7 @@ from weboob.backend import BaseBackend
|
||||||
from weboob.capabilities.chat import ICapChat
|
from weboob.capabilities.chat import ICapChat
|
||||||
from weboob.capabilities.messages import ICapMessages, ICapMessagesReply, Message
|
from weboob.capabilities.messages import ICapMessages, ICapMessagesReply, Message
|
||||||
from weboob.capabilities.dating import ICapDating
|
from weboob.capabilities.dating import ICapDating
|
||||||
|
from weboob.capabilities.contact import ICapContact, Contact
|
||||||
from weboob.tools.browser import BrowserUnavailable
|
from weboob.tools.browser import BrowserUnavailable
|
||||||
|
|
||||||
from .browser import AdopteUnMec
|
from .browser import AdopteUnMec
|
||||||
|
|
@ -36,7 +37,7 @@ from .optim.visibility import Visibility
|
||||||
__all__ = ['AuMBackend']
|
__all__ = ['AuMBackend']
|
||||||
|
|
||||||
|
|
||||||
class AuMBackend(BaseBackend, ICapMessages, ICapMessagesReply, ICapDating, ICapChat):
|
class AuMBackend(BaseBackend, ICapMessages, ICapMessagesReply, ICapDating, ICapChat, ICapContact):
|
||||||
NAME = 'aum'
|
NAME = 'aum'
|
||||||
MAINTAINER = 'Romain Bignon'
|
MAINTAINER = 'Romain Bignon'
|
||||||
EMAIL = 'romain@peerfuse.org'
|
EMAIL = 'romain@peerfuse.org'
|
||||||
|
|
@ -70,7 +71,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesReply, ICapDating, ICapC
|
||||||
try:
|
try:
|
||||||
profiles = {}
|
profiles = {}
|
||||||
|
|
||||||
contacts = self.browser.get_contact_list()
|
contacts = self.browser.get_threads_list()
|
||||||
for contact in contacts:
|
for contact in contacts:
|
||||||
if not contact.get_id() in self.storage.get('sluts'):
|
if not contact.get_id() in self.storage.get('sluts'):
|
||||||
slut = {'lastmsg': datetime(1970,1,1),
|
slut = {'lastmsg': datetime(1970,1,1),
|
||||||
|
|
@ -144,8 +145,8 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesReply, ICapDating, ICapC
|
||||||
self.OPTIM_PROFILE_WALKER = ProfilesWalker(self.weboob.scheduler, self.storage, self.browser)
|
self.OPTIM_PROFILE_WALKER = ProfilesWalker(self.weboob.scheduler, self.storage, self.browser)
|
||||||
self.OPTIM_VISIBILITY = Visibility(self.weboob.scheduler, self.browser)
|
self.OPTIM_VISIBILITY = Visibility(self.weboob.scheduler, self.browser)
|
||||||
|
|
||||||
def iter_chat_contacts(self, online=True, offline=True):
|
def iter_contacts(self, status=Contact.STATUS_ALL):
|
||||||
return self.browser.iter_chat_contacts(online=online, offline=offline)
|
return self.browser.iter_contacts(status)
|
||||||
|
|
||||||
def iter_chat_messages(self, _id=None):
|
def iter_chat_messages(self, _id=None):
|
||||||
return self.browser.iter_chat_messages(_id)
|
return self.browser.iter_chat_messages(_id)
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,8 @@ from weboob.backends.aum.pages.login import LoginPage, RedirectPage, BanPage, Er
|
||||||
from weboob.backends.aum.pages.edit import EditPhotoPage, EditPhotoCbPage, EditAnnouncePage, EditDescriptionPage, EditSexPage, EditPersonalityPage
|
from weboob.backends.aum.pages.edit import EditPhotoPage, EditPhotoCbPage, EditAnnouncePage, EditDescriptionPage, EditSexPage, EditPersonalityPage
|
||||||
from weboob.backends.aum.pages.wait import WaitPage
|
from weboob.backends.aum.pages.wait import WaitPage
|
||||||
|
|
||||||
from weboob.capabilities.chat import ChatContact, ChatException, ChatMessage
|
from weboob.capabilities.chat import ChatException, ChatMessage
|
||||||
|
from weboob.capabilities.contact import Contact
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['AdopteUnMec']
|
__all__ = ['AdopteUnMec']
|
||||||
|
|
@ -194,7 +195,7 @@ class AdopteUnMec(BaseBrowser):
|
||||||
self.openurl('/mails.php?type=3')
|
self.openurl('/mails.php?type=3')
|
||||||
|
|
||||||
@pageaccess
|
@pageaccess
|
||||||
def get_contact_list(self):
|
def get_threads_list(self):
|
||||||
if not self.is_on_page(ContactListPage):
|
if not self.is_on_page(ContactListPage):
|
||||||
self.location('/mails.php')
|
self.location('/mails.php')
|
||||||
|
|
||||||
|
|
@ -284,7 +285,7 @@ class AdopteUnMec(BaseBrowser):
|
||||||
raise ChatException(u'Error while getting chat infos. json:\n%s' % json)
|
raise ChatException(u'Error while getting chat infos. json:\n%s' % json)
|
||||||
return json
|
return json
|
||||||
|
|
||||||
def iter_chat_contacts(self, online=True, offline=True):
|
def iter_contacts(self, status=Contact.STATUS_ALL):
|
||||||
def iter_dedupe(contacts):
|
def iter_dedupe(contacts):
|
||||||
yielded_ids = set()
|
yielded_ids = set()
|
||||||
for contact in contacts:
|
for contact in contacts:
|
||||||
|
|
@ -294,14 +295,16 @@ class AdopteUnMec(BaseBrowser):
|
||||||
|
|
||||||
json = self._get_chat_infos()
|
json = self._get_chat_infos()
|
||||||
for contact in iter_dedupe(json['contacts']):
|
for contact in iter_dedupe(json['contacts']):
|
||||||
if online and contact['cat'] == 1 or offline and contact['cat'] == 3:
|
if status & Contact.STATUS_ONLINE and contact['cat'] == 1 or \
|
||||||
|
status & Contact.STATUS_OFFLINE and contact['cat'] == 3:
|
||||||
if contact['cat'] == 1:
|
if contact['cat'] == 1:
|
||||||
online = True
|
s = Contact.STATUS_ONLINE
|
||||||
elif contact['cat'] == 3:
|
elif contact['cat'] == 3:
|
||||||
online = False
|
s = Contact.STATUS_OFFLINE
|
||||||
else:
|
else:
|
||||||
raise ChatException(u'Unknown online status: contact=%s' % contact)
|
raise ChatException(u'Unknown online status: contact=%s' % contact)
|
||||||
yield ChatContact(_id=contact['id'], pseudo=contact['pseudo'], online=online, avatar_url=contact['cover'], age=contact['birthday'])
|
# TODO age in contact['birthday']
|
||||||
|
yield Contact(id=contact['id'], name=contact['pseudo'], status=s, thumbnail_url=contact['cover'])
|
||||||
|
|
||||||
def iter_chat_messages(self, _id=None):
|
def iter_chat_messages(self, _id=None):
|
||||||
json = self._get_chat_infos()
|
json = self._get_chat_infos()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue