From a9f92552a4f2e010d699ad76c5d129566a35668f Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Thu, 14 Oct 2010 14:09:48 +0200 Subject: [PATCH] check spam on more objects, and remove threads of spambots --- weboob/backends/aum/backend.py | 19 ++++++++++++++++--- weboob/backends/aum/browser.py | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/weboob/backends/aum/backend.py b/weboob/backends/aum/backend.py index 1445ffe3..3dd07a83 100644 --- a/weboob/backends/aum/backend.py +++ b/weboob/backends/aum/backend.py @@ -88,6 +88,10 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh else: return self.create_browser(self.config['username'], self.config['password']) + def report_spam(self, id): + self.browser.delete_thread(id) + self.browser.report_fake(id) + def get_status(self): with self.browser: try: @@ -108,7 +112,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh continue if self.antispam and not self.antispam.check(contact): debug('Skipped a spam-thread from %s' % contact.get_name()) - self.browser.report_fake(contact.get_id()) + self.report_spam(contact.get_id()) continue thread = Thread(contact.get_id()) thread.title = 'Discussion with %s' % contact.get_name() @@ -142,12 +146,21 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh profiles = {} for mail in mails: flags = 0 + if self.antispam and not self.antispam.check(mail): + debug('Skipped a spam-mail from %s' % mail.sender) + self.report_spam(thread.id) + break + if mail.date > slut['lastmsg']: flags |= Message.IS_UNREAD if not mail.profile_link in profiles: with self.browser: profiles[mail.profile_link] = self.browser.get_profile(mail.profile_link) + if self.antispam and not self.antispam.check(profiles[mail.profile_link]): + debug('Skipped a spam-mail-profile from %s' % mail.sender) + self.report_spam(thread.id) + break mail.signature += u'\n%s' % profiles[mail.profile_link].get_profile_text() if mail.sender == my_name: @@ -197,7 +210,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh continue if self.antispam and not self.antispam.check(contact): debug('Skipped a spam-unread-thread from %s' % contact.get_name()) - self.browser.report_fake(contact.get_id()) + self.report_spam(contact.get_id()) continue slut = self._get_slut(contact.get_id()) if contact.get_lastmsg_date() > slut['lastmsg']: @@ -218,7 +231,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh profile = self.browser.get_profile(ids[new_baskets]) if self.antispam and not self.antispam.check(profile): debug('Skipped a spam-basket from %s' % profile.get_name()) - self.browser.report_fake(profile.get_id()) + self.report_spam(profile.get_id()) continue thread = Thread(profile.get_id()) diff --git a/weboob/backends/aum/browser.py b/weboob/backends/aum/browser.py index 896a0391..d71160b1 100644 --- a/weboob/backends/aum/browser.py +++ b/weboob/backends/aum/browser.py @@ -209,6 +209,23 @@ class AuMBrowser(BaseBrowser): self.page.open_thread_page(id) self.page.post(content) + @pageaccess + def delete_thread(self, id): + """ + mail.php + delete=true&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=6671957&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D= + delete=true&suppr%5B%5D=13121086&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D=&suppr%5B%5D= + """ + data = 'delete=true&suppr%%5B%%5D=%s' % id + for i in xrange(23): + data += '&suppr%5B%5D=' + url = 'http://www.adopteunmec.com/mail.php' + request = self.request_class(url, data, {'Referer': url, 'Content-Type': 'application/x-www-form-urlencoded'}) + # WTF IT DOESN'T WORK I HAVE YOU AUM I WANT TO DEFECATE IN YOUR MOUTH + self.openurl(request).read() + + return True + @pageaccess def send_charm(self, id): result = self.openurl('http://www.adopteunmec.com/fajax_addBasket.php?id=%s' % id).read() @@ -222,11 +239,13 @@ class AuMBrowser(BaseBrowser): # TODO check if it works (but it should) return True + @pageaccess def deblock(self, id): result = self.openurl('http://www.adopteunmec.com/fajax_postMessage.php?action=deblock&to=%s' % id).read() warning('Deblock: %s' % result) return True + @pageaccess def report_fake(self, id): return self.readurl('http://www.adopteunmec.com/fake.php', 'id=%s' % id)