stream.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:Qkou_kit 作者: pddg 项目源码 文件源码
def tweetassembler(**args):
    in_reply_to_status = args['in_reply_to_status']
    if in_reply_to_status is not None:
        regex = u'.*??.*'
        if re.match(regex, in_reply_to_status.text, re.U):
            # ??????ID???
            id = in_reply_to_status.in_reply_to_status_id
            # ??????????????
            qkou_status = api.get_status(id)
            entities = qkou_status.entities['hashtags']
            # ????????????????
            if len(entities) > 0:
                hashtag = entities[0]['text']
                # ??????????????
                info_num = re.search("(?<=lec)[0-9]*", hashtag)
                news_num = re.search("(?<=news)[0-9]*", hashtag)
                if info_num is not None:
                    qkou_id = info_num.group()
                    log.debug("[ Stream ] Info??????")
                    dm_text = get_info(qkou_id)
                elif news_num is not None:
                    news_id = news_num.group()
                    log.debug("[ Stream ] News??????")
                    dm_text = get_news(news_id)
                else:
                    pass
                try:
                    api.send_direct_message(
                        user_id=in_reply_to_status.user.id, text=dm_text)
                    log.debug('[ Stream ] DM???')
                except Exception as e:
                    log.exception(e)
            else:
                pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号