本文整理汇总了Python中weboob.capabilities.messages.Thread.flags方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.flags方法的具体用法?Python Thread.flags怎么用?Python Thread.flags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weboob.capabilities.messages.Thread
的用法示例。
在下文中一共展示了Thread.flags方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def iter_threads(self):
for thread in self.browser.get_threads():
t = Thread(thread['id'])
t.flags = Thread.IS_DISCUSSION
t.title = u'Discussion with %s' % thread['name']
t.date = local2utc(datetime.datetime.fromtimestamp(thread['last_message']['utc_timestamp']))
yield t
示例2: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def get_thread(self, _id):
thread = Thread(_id)
thread.title = 'Mail for %s' % _id
thread.flags = thread.IS_DISCUSSION
self._get_messages_thread(_id, thread)
return thread
示例3: iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def iter_threads(self):
for thread in self.browser.get_threads():
if not "person" in thread:
# The account has been removed, probably because it was a
# spammer.
continue
t = Thread(thread["_id"])
t.flags = Thread.IS_DISCUSSION
t.title = u"Discussion with %s" % thread["person"]["name"]
contact = self.storage.get("contacts", t.id, default={"lastmsg": 0})
birthday = parse_date(thread["person"]["birth_date"]).date()
signature = u"Age: %d (%s)" % ((datetime.date.today() - birthday).days / 365.25, birthday)
signature += u"\nLast ping: %s" % parse_date(thread["person"]["ping_time"]).strftime("%Y-%m-%d %H:%M:%S")
signature += u"\nPhotos:\n\t%s" % "\n\t".join([photo["url"] for photo in thread["person"]["photos"]])
signature += u"\n\n%s" % thread["person"]["bio"]
t.root = Message(
thread=t,
id=1,
title=t.title,
sender=unicode(thread["person"]["name"]),
receivers=[self.browser.my_name],
date=parse_date(thread["created_date"]),
content=u"Match!",
children=[],
signature=signature,
flags=Message.IS_UNREAD if int(contact["lastmsg"]) < 1 else 0,
)
parent = t.root
for msg in thread["messages"]:
flags = 0
if int(contact["lastmsg"]) < msg["timestamp"]:
flags = Message.IS_UNREAD
msg = Message(
thread=t,
id=msg["timestamp"],
title=t.title,
sender=unicode(
self.browser.my_name if msg["from"] == self.browser.my_id else thread["person"]["name"]
),
receivers=[
unicode(self.browser.my_name if msg["to"] == self.browser.my_id else thread["person"]["name"])
],
date=parse_date(msg["sent_date"]),
content=unicode(msg["message"]),
children=[],
parent=parent,
signature=signature if msg["to"] == self.browser.my_id else u"",
flags=flags,
)
parent.children.append(msg)
parent = msg
yield t
示例4: iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def iter_threads(self):
threads = self.browser.get_threads_list()
for thread in threads:
t = Thread(thread['userid'])
t.flags = Thread.IS_DISCUSSION
t.title = u'Discussion with %s' % thread['user']['username']
t.date = datetime.fromtimestamp(thread['timestamp'])
yield t
示例5: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def get_thread(self, thread):
if not isinstance(thread, Thread):
thread = Thread(thread)
thread.flags = Thread.IS_DISCUSSION
info = self.browser.get_thread(thread.id)
for user in info['participants']:
if user['user']['fb_id'] is not None:
user['user']['fb'] = self.browser.get_facebook(user['user']['fb_id'])
if user['user']['id'] == self.browser.my_id:
me = HappnContact(user['user'])
else:
other = HappnContact(user['user'])
thread.title = u'Discussion with %s' % other.name
contact = self.storage.get('contacts', thread.id, default={'lastmsg_date': '1970-01-01T01:01:01+00:00'})
child = None
for msg in info['messages']:
flags = 0
if parse_date(contact['lastmsg_date']) < parse_date(msg['creation_date']):
flags = Message.IS_UNREAD
if msg['sender']['id'] == me.id:
sender = me
receiver = other
else:
sender = other
receiver = me
msg = Message(thread=thread,
id=msg['id'],
title=thread.title,
sender=sender.name,
receivers=[receiver.name],
date=parse_date(msg['creation_date']),
content=msg['message'],
children=[],
parent=None,
signature=sender.get_text(),
flags=flags)
if child:
msg.children.append(child)
child.parent = msg
child = msg
thread.root = child
return thread
示例6: _iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def _iter_threads(self, root_link=None):
links = list(self.browser.iter_links(root_link.url if root_link else None))
for link in links:
if link.type == link.FORUM:
link.title = '%s[%s]' % (root_link.title if root_link else '', link.title)
for thread in self._iter_threads(link):
yield thread
if link.type == link.TOPIC:
thread = Thread(url2id(link.url))
thread.title = ('%s ' % root_link.title if root_link else '') + link.title
thread.date = link.date
thread.flags = thread.IS_DISCUSSION
yield thread
示例7: iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def iter_threads(self):
with self.browser:
threads = self.browser.get_threads_list()
for thread in threads:
# Remove messages from user that quit
# if thread['member'].get('isBan', thread['member'].get('dead', False)):
# with self.browser:
# self.browser.delete_thread(thread['member']['id'])
# continue
t = Thread(int(thread["id"]))
t.flags = Thread.IS_DISCUSSION
t.title = u"Discussion with %s" % thread["username"]
yield t
示例8: iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def iter_threads(self):
for thread in self.browser.get_threads():
if 'person' not in thread:
# The account has been removed, probably because it was a
# spammer.
continue
t = Thread(thread['_id'])
t.flags = Thread.IS_DISCUSSION
t.title = u'Discussion with %s' % thread['person']['name']
contact = self.storage.get('contacts', t.id, default={'lastmsg': 0})
birthday = parse_date(thread['person']['birth_date']).date()
signature = u'Age: %d (%s)' % ((datetime.date.today() - birthday).days / 365.25, birthday)
signature += u'\nLast ping: %s' % parse_date(thread['person']['ping_time']).strftime('%Y-%m-%d %H:%M:%S')
signature += u'\nPhotos:\n\t%s' % '\n\t'.join([photo['url'] for photo in thread['person']['photos']])
signature += u'\n\n%s' % thread['person'].get('bio', '')
t.root = Message(thread=t, id=1, title=t.title,
sender=unicode(thread['person']['name']),
receivers=[self.browser.my_name],
date=parse_date(thread['created_date']),
content=u'Match!',
children=[],
signature=signature,
flags=Message.IS_UNREAD if int(contact['lastmsg']) < 1 else 0)
parent = t.root
for msg in thread['messages']:
flags = 0
if int(contact['lastmsg']) < msg['timestamp']:
flags = Message.IS_UNREAD
msg = Message(thread=t,
id=msg['timestamp'],
title=t.title,
sender=unicode(self.browser.my_name if msg['from'] == self.browser.my_id else thread['person']['name']),
receivers=[unicode(self.browser.my_name if msg['to'] == self.browser.my_id else thread['person']['name'])],
date=parse_date(msg['sent_date']),
content=unicode(msg['message']),
children=[],
parent=parent,
signature=signature if msg['to'] == self.browser.my_id else u'',
flags=flags)
parent.children.append(msg)
parent = msg
yield t
示例9: iter_threads_list
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def iter_threads_list(self):
# site is sorted from latest to oldest
for message_a in reversed(self.document.findAll('a', href=re.compile(r'message_read.php\?'))):
ovs_id = re.search(r'Id=(\d+)', message_a["href"]).group(1)
id_ = ovs_id
thread = Thread(id_)
thread.title = ovsparse.all_text_recursive(message_a)
thread.flags = Thread.IS_DISCUSSION
#~ parent_tr = message_a.findParent('tr')
#~ username = all_text_recursive(parent_tr.find('a', href=re.compile(r'profil_read.php\?.*')))
#~ notread_self = (parent_tr.get('class') == 'newmails')
#~ notread_other = (parent_tr.find('span', **{'class': 'new_sortiepartenaire'}) is not None)
yield thread
示例10: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def get_thread(self, _id):
t = Thread(_id)
t.title = 'Mail for %s' % _id
t.flags = t.IS_DISCUSSION
first = True
for d in self.browser.get_mails(_id):
m = self.make_message(d, t)
if not m.content:
m.content = self.browser.get_mail_content(m.id)
if first:
first = False
t.root = m
else:
m.parent = t.root
m.parent.children.append(m)
return t
示例11: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def get_thread(self, _id):
thread = Thread(_id)
thread.title = self.document.find('div', 'PADtitreBlanc_txt').find('center').string
thread.flags = Thread.IS_DISCUSSION
root = True
for message in self._get_messages(thread):
if root:
message.children = []
thread.root = message
thread.date = message.date
message.title = thread.title
root = False
else:
message.title = 'Re: %s' % thread.title
message.children = []
message.parent = thread.root
thread.root.children.append(message)
return thread
示例12: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def get_thread(self, id, contacts=None, get_profiles=False):
"""
Get a thread and its messages.
The 'contacts' parameters is only used for internal calls.
"""
thread = None
if isinstance(id, Thread):
thread = id
id = thread.id
if not thread:
thread = Thread(int(id))
thread.flags = Thread.IS_DISCUSSION
full = False
else:
full = True
with self.browser:
mails = self.browser.get_thread_mails(id, 100)
my_name = self.browser.get_my_name()
child = None
msg = None
slut = self._get_slut(mails["member"]["pseudo"])
if contacts is None:
contacts = {}
if not thread.title:
thread.title = u"Discussion with %s" % mails["member"]["pseudo"]
for mail in mails["messages"]:
flags = Message.IS_HTML
if parse_dt(mail["date"]) > slut["lastmsg"] and mail["id_from"] != self.browser.get_my_name():
flags |= Message.IS_UNREAD
if get_profiles:
if not mail["id_from"] in contacts:
with self.browser:
contacts[mail["id_from"]] = self.get_contact(mail["id_from"])
signature = u""
if mail.get("src", None):
signature += u"Sent from my %s\n\n" % mail["src"]
if mail["id_from"] in contacts:
signature += contacts[mail["id_from"]].get_text()
msg = Message(
thread=thread,
id=int(time.strftime("%Y%m%d%H%M%S", parse_dt(mail["date"]).timetuple())),
title=thread.title,
sender=mail["id_from"],
receivers=[my_name if mail["id_from"] != my_name else mails["member"]["pseudo"]],
date=parse_dt(mail["date"]),
content=unescape(mail["message"]).strip(),
signature=signature,
children=[],
flags=flags,
)
if child:
msg.children.append(child)
child.parent = msg
child = msg
if full and msg:
# If we have get all the messages, replace NotLoaded with None as
# parent.
msg.parent = None
if not full and not msg:
# Perhaps there are hidden messages
msg = NotLoaded
thread.root = msg
return thread
示例13: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import flags [as 别名]
def get_thread(self, id, contacts=None, get_profiles=False):
"""
Get a thread and its messages.
The 'contacts' parameters is only used for internal calls.
"""
thread = None
if isinstance(id, Thread):
thread = id
id = thread.id
if not thread:
thread = Thread(int(id))
thread.flags = Thread.IS_DISCUSSION
full = False
else:
full = True
with self.browser:
mails = self.browser.get_thread_mails(id, 100)
my_name = self.browser.get_my_name()
child = None
msg = None
slut = self._get_slut(id)
if contacts is None:
contacts = {}
if not thread.title:
thread.title = u'Discussion with %s' % mails['who']['pseudo']
self.storage.set('sluts', int(thread.id), 'status', mails['status'])
self.storage.save()
for mail in mails['results']:
flags = 0
if self.antispam and not self.antispam.check_mail(mail):
self.logger.info('Skipped a spam-mail from %s' % mails['who']['pseudo'])
self.report_spam(thread.id)
break
if parse_dt(mail['date']) > slut['lastmsg']:
flags |= Message.IS_UNREAD
if get_profiles:
if not mail['from'] in contacts:
try:
with self.browser:
contacts[mail['from']] = self.get_contact(mail['from'])
except BrowserHTTPNotFound:
pass
if self.antispam and mail['from'] in contacts and not self.antispam.check_contact(contacts[mail['from']]):
self.logger.info('Skipped a spam-mail-profile from %s' % mails['who']['pseudo'])
self.report_spam(thread.id)
break
if int(mail['from']) == self.browser.my_id:
if mails['remote_status'] == 'new' and msg is None:
flags |= Message.IS_NOT_RECEIVED
else:
flags |= Message.IS_RECEIVED
signature = u''
#if mail.get('src', None):
# signature += u'Sent from my %s\n\n' % mail['src']
if mail['from'] in contacts:
signature += contacts[mail['from']].get_text()
msg = Message(thread=thread,
id=int(time.strftime('%Y%m%d%H%M%S', parse_dt(mail['date']).timetuple())),
title=thread.title,
sender=to_unicode(my_name if int(mail['from']) == self.browser.my_id else mails['who']['pseudo']),
receivers=[to_unicode(my_name if int(mail['from']) != self.browser.my_id else mails['who']['pseudo'])],
date=parse_dt(mail['date']),
content=to_unicode(unescape(mail['message'] or '').strip()),
signature=signature,
children=[],
flags=flags)
if child:
msg.children.append(child)
child.parent = msg
child = msg
if full and msg:
# If we have get all the messages, replace NotLoaded with None as
# parent.
msg.parent = None
if not full and not msg:
# Perhaps there are hidden messages
msg = NotLoaded
thread.root = msg
return thread