当前位置: 首页>>代码示例>>Python>>正文


Python Comment.flattenMentions方法代码示例

本文整理汇总了Python中model.Comment.flattenMentions方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.flattenMentions方法的具体用法?Python Comment.flattenMentions怎么用?Python Comment.flattenMentions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.Comment的用法示例。


在下文中一共展示了Comment.flattenMentions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: email_outbox

# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import flattenMentions [as 别名]
def email_outbox(user_id):
  from model import User
  from model import Comment
  
  user_obj = memcache.get(user_id) or {}
  outbox = user_obj.get('outbox', [])
  if len(outbox):
    user = User.get_by_key_name(user_id)
    from_users = {}
    while len(outbox):
      msg = outbox.pop(0)
      if msg['type'] == 'new_message' and user.email_message != False \
          and from_users.get(msg['message']['from_user']['id']) != True:
        split = msg['message']['from_user']['name'].split(' ')
        first_name = split[0] if len(split) else msg['message']['from_user']['name']
        if msg['message']['media']:
          message_email = emailer.Email(emailer.Message.VIDEO(first_name),
                                        {'first_name' : first_name,
                                         'name': msg['message']['from_user']['name'],
                                         'text': msg['message']['text'],
                                         'image': 'http://i.ytimg.com/vi/%s/0.jpg' % msg['message']['media']['host_id'],
                                         'title': msg['message']['media']['name'],
                                         'link': 'http://' + msg['message']['media']['link']
                                        })
        else:
          message_email = emailer.Email(emailer.Message.MESSAGE(first_name),
                                        {'first_name' : first_name,
                                         'name': msg['message']['from_user']['name'],
                                         'text': msg['message']['text'],
                                         'image': 'https://graph.facebook.com/%s/picture' % msg['message']['from_user']['id'],
                                         'link': 'http://www.xylocast.com'
                                        })
        message_email.send(user)
        from_users[msg['message']['from_user']['id']] = True

      if msg['type'] == 'new_comment' and user.email_reply != False:
        split = msg['comment']['user']['name'].split(' ')
        first_name = split[0] if len(split) else msg['comment']['user']['name']
        comment_email = emailer.Email(emailer.Message.COMMENT(first_name),
                                  {'first_name' : first_name,
                                   'name': msg['comment']['user']['name'],
                                   'link': 'http://' + msg['comment']['media']['link'],
                                   'text': Comment.flattenMentions(msg['comment']['text']),
                                   'title': msg['comment']['media']['name'],
                                   'image': 'http://i.ytimg.com/vi/%s/0.jpg' % msg['comment']['media']['host_id']
                                  })
        comment_email.send(user)
      if msg['type'] == 'notification' and user.email_mention != False:
        if msg['notification']['type'] == 'mention':
          split = msg['notification']['comment']['user']['name'].split(' ')
          first_name = split[0] if len(split) else msg['notification']['comment']['user']['name']
          mention_email = emailer.Email(emailer.Message.MENTION(first_name),
                                    {'first_name' : first_name,
                                     'name': msg['notification']['comment']['user']['name'],
                                     'link': 'http://' + msg['notification']['comment']['media']['link'],
                                     'text': Comment.flattenMentions(msg['notification']['comment']['text']),
                                     'title': msg['notification']['comment']['media']['name'],
                                     'image': 'http://i.ytimg.com/vi/%s/0.jpg' % msg['notification']['comment']['media']['host_id']
                                    })
          mention_email.send(user)
    del user_obj['outbox']
    memcache.set(user_id, user_obj)
开发者ID:ebby,项目名称:brokentv,代码行数:64,代码来源:broadcast.py


注:本文中的model.Comment.flattenMentions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。