cmdline.py 文件源码

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

项目:TwiBot 作者: ShruthiChari 项目源码 文件源码
def __call__(self, twitter, options):
        statusTxt = (" ".join(options['extra_args'])
                     if options['extra_args']
                     else str(input("message: ")))
        replies = []
        ptr = re.compile("@[\w_]+")
        while statusTxt:
            s = ptr.match(statusTxt)
            if s and s.start() == 0:
                replies.append(statusTxt[s.start():s.end()])
                statusTxt = statusTxt[s.end() + 1:]
            else:
                break
        replies = " ".join(replies)
        if len(replies) >= 140:
            # just go back
            statusTxt = replies
            replies = ""

        splitted = []
        while statusTxt:
            limit = 140 - len(replies)
            if len(statusTxt) > limit:
                end = string.rfind(statusTxt, ' ', 0, limit)
            else:
                end = limit
            splitted.append(" ".join((replies, statusTxt[:end])))
            statusTxt = statusTxt[end:]

        if options['invert_split']:
            splitted.reverse()
        for status in splitted:
            twitter.statuses.update(status=status)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号