implement get_status() to get my nickname, my score and the number of available charms
This commit is contained in:
parent
1f09368a99
commit
b73c0559c6
3 changed files with 19 additions and 7 deletions
|
|
@ -24,7 +24,7 @@ from time import sleep
|
|||
from weboob.backend import BaseBackend
|
||||
from weboob.capabilities.chat import ICapChat
|
||||
from weboob.capabilities.messages import ICapMessages, ICapMessagesReply, Message
|
||||
from weboob.capabilities.dating import ICapDating
|
||||
from weboob.capabilities.dating import ICapDating, StatusField
|
||||
from weboob.capabilities.contact import ICapContact, Contact
|
||||
from weboob.tools.browser import BrowserUnavailable
|
||||
|
||||
|
|
@ -58,6 +58,14 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesReply, ICapDating, ICapC
|
|||
# Private
|
||||
_profiles_walker = None
|
||||
|
||||
def get_status(self):
|
||||
with self.browser:
|
||||
return (
|
||||
StatusField('myname', 'My name', self.browser.get_my_name()),
|
||||
StatusField('score', 'Score', self.browser.score()),
|
||||
StatusField('avcharms', 'Available charms', self.browser.nb_available_charms()),
|
||||
)
|
||||
|
||||
def iter_messages(self, thread=None):
|
||||
for message in self._iter_messages(thread, False):
|
||||
yield message
|
||||
|
|
@ -146,13 +154,16 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesReply, ICapDating, ICapC
|
|||
self.OPTIM_VISIBILITY = Visibility(self.weboob.scheduler, self.browser)
|
||||
|
||||
def iter_contacts(self, status=Contact.STATUS_ALL):
|
||||
return self.browser.iter_contacts(status)
|
||||
with self.browser:
|
||||
return self.browser.iter_contacts(status)
|
||||
|
||||
def iter_chat_messages(self, _id=None):
|
||||
return self.browser.iter_chat_messages(_id)
|
||||
with self.browser:
|
||||
return self.browser.iter_chat_messages(_id)
|
||||
|
||||
def send_chat_message(self, _id, message):
|
||||
return self.browser.send_chat_message(_id, message)
|
||||
with self.browser:
|
||||
return self.browser.send_chat_message(_id, message)
|
||||
|
||||
#def start_chat_polling(self):
|
||||
#self._profile_walker = ProfilesWalker(self.weboob.scheduler, self.storage, self.browser)
|
||||
|
|
|
|||
|
|
@ -180,8 +180,9 @@ class AdopteUnMec(BaseBrowser):
|
|||
return self.page.nb_new_visites()
|
||||
|
||||
@pageaccess
|
||||
def nb_available_charms(self):
|
||||
self.home()
|
||||
def nb_available_charms(self, reload=False):
|
||||
if reload or not self.is_on_page(HomePage):
|
||||
self.home()
|
||||
return self.page.nb_available_charms()
|
||||
|
||||
@pageaccess
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class PageBase(BasePage):
|
|||
if tag.getAttribute('width') == '220':
|
||||
# <table><tbody(implicit)><td>
|
||||
child = tag.childNodes[1].childNodes[0].childNodes[3]
|
||||
return child.childNodes[0].childNodes[0].data
|
||||
return int(child.childNodes[0].childNodes[0].data.replace(' ', ''))
|
||||
|
||||
error("Error: I can't find the score :(")
|
||||
return '0'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue