How to use the beem.utils.construct_authorperm function in beem

To help you get started, we’ve selected a few beem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holgern / beem / tests / beem / test_vote.py View on Github external
n_votes = 0
        index = 0
        while n_votes == 0:
            comment = acc.get_feed(limit=30)[::-1][index]
            votes = comment.get_votes()
            n_votes = len(votes)
            index += 1

        last_vote = votes[0]

        cls.authorpermvoter = construct_authorpermvoter(last_vote['author'], last_vote['permlink'], last_vote["voter"])
        [author, permlink, voter] = resolve_authorpermvoter(cls.authorpermvoter)
        cls.author = author
        cls.permlink = permlink
        cls.voter = voter
        cls.authorperm = construct_authorperm(author, permlink)
github holgern / beem / tests / beem / test_utils.py View on Github external
def test_constructAuthorperm(self):
        self.assertEqual(construct_authorperm("A", "B"), "@A/B")
        self.assertEqual(construct_authorperm({'author': "A", 'permlink': "B"}), "@A/B")
github travelfeed-io / travelfeed-curator / tfbot.py View on Github external
def curation_action(action, author, permlink, curator):
    try:
        authorperm = construct_authorperm(author, permlink)
        post = Comment(authorperm)
        app = post.json_metadata.get('app', None).split('/')[0]
        isTfio = app == "travelfeed"
        if post["author"] in blacklist:
            return
        elif action == "curate":
            try:
                if(isTfio):
                    post.upvote(weight=100, voter=curationaccount)
                else:
                    post.upvote(weight=90, voter=curationaccount)
            except Exception as error:
                logger.critical("Could not upvote post "+repr(error))
            try:
                write_comment(post, resteemtext.format(
                    curator), isTfio)
github tiotdev / steem-curationbot / curationbot.py View on Github external
async def tf50(ctx, link):
    curator = re.sub(r'\d{4}|\W|(TravelFeed)','',str(ctx.message.author),re.IGNORECASE|re.DOTALL)
    if not ctx.message.channel.id == commandchannel:
        await send_discord("Bot commands are only allowed in #bot-commands", ctx.message.channel.id)
        return
    if not ctx.message.author.id in discordcuratorlist:
        await send_discord("Curator unauthorised: "+curator, logchannel)
        return
    await bot.add_reaction(ctx.message, "⏳")
    author, permlink = resolve_authorperm(link)
    post = Comment(construct_authorperm(author, permlink))
    actionqueue.put(Post_Action(post, "tf50", curator, ctx.message))
github holgern / beem / beem / comment.py View on Github external
def vote(self, weight, account=None, identifier=None, **kwargs):
        """ Vote for a post

            :param float weight: Voting weight. Range: -100.0 - +100.0.
            :param str account: (optional) Account to use for voting. If
                ``account`` is not defined, the ``default_account`` will be used
                or a ValueError will be raised
            :param str identifier: Identifier for the post to vote. Takes the
                form ``@author/permlink``.

        """
        if not identifier:
            identifier = construct_authorperm(self["author"], self["permlink"])

        return self.steem.vote(weight, identifier, account=account)
github holgern / beem / beem / comment.py View on Github external
if self.use_tags_api:
                    content = self.steem.rpc.get_discussion({'author': author, 'permlink': permlink}, api="tags")
                else:
                    content =self.steem.rpc.list_comments({"start": [author, permlink], "limit": 1, "order": "by_permlink"}, api="database")
                if content is not None and "comments" in content:
                    content =content["comments"]
                if isinstance(content, list) and len(content) >0:
                    content =content[0]
            except:
                content = self.steem.rpc.get_content(author, permlink)
        else:
            content = self.steem.rpc.get_content(author, permlink)
        if not content or not content['author'] or not content['permlink']:
            raise ContentDoesNotExistsException(self.identifier)
        content = self._parse_json_data(content)
        content["authorperm"] = construct_authorperm(content['author'], content['permlink'])
        super(Comment, self).__init__(content, id_item="authorperm", lazy=self.lazy, full=self.full, steem_instance=self.steem)
github tiotdev / steem-curationbot / curationbot.py View on Github external
while True:
        """Continuously stream comment objects from Blockchain, react to relevant one"""
        try:
            stream = map(Comment, blockchain.stream(opNames=["comment"]))
            logger.info("Stream from blockchain started")
        except Exception as error:
            logger.warning("Could not start blockchain stream "+repr(error))
            steem.rpc.next()
            stream_comments(sync_q)
        for post in stream:
            try:
                post.refresh()
                tags = post["tags"]
                author = post["author"]
                body = post["body"]
                authorperm = construct_authorperm(author, post['permlink'])
                if post.is_comment():
                    if author in curatorlist:
                        """Initiates an action if a curator uses the invocation command in a comment"""
                        parent = post.get_parent()
                        if "!tf50" in body:
                            logger.info("Found !tf50 in curator comment")
                            sync_q.put(Post_Action(parent, "tf50", author, None))
                        elif "!tf100" in body:
                            logger.info("Found !tf100 in curator comment")
                            sync_q.put(Post_Action(parent, "tf100", author, None))
                        elif "!coop100" in body:
                            sync_q.put(Post_Action(parent, "coop100", None, None))
                        elif "!ad10" in body:
                            sync_q.put(Post_Action(parent, "ad10", author, None)) 
                    elif "!tfreview" in body:
                        """Users targeted by bot comments can have their posts manually reviewed"""
github tiotdev / steem-curationbot / curationbot.py View on Github external
async def lang0(ctx, link):
    curator = re.sub(r'\d{4}|\W|(TravelFeed)','',str(ctx.message.author),re.IGNORECASE|re.DOTALL)
    if not ctx.message.channel.id == commandchannel:
        await send_discord("Bot commands are only allowed in #bot-commands", ctx.message.channel.id)
        return
    if not ctx.message.author.id in discordcuratorlist:
        await send_discord("Curator unauthorised: "+curator, logchannel)
        return
    await bot.add_reaction(ctx.message, "⏳")
    author, permlink = resolve_authorperm(link)
    authorperm = construct_authorperm(author, permlink)
    post = Comment(authorperm)
    actionqueue.put(Post_Action(post, "lang0", None, ctx.message))
github holgern / beem / examples / watching_the_watchers.py View on Github external
if a["proxy"] != "":
                        related.append(a["proxy"])
                    self.wtw.set_account_info(account, fish, related)
                    accl2 = list()
                    if racc is not None and racc not in self.looked_up:
                        accl2.append(racc)
                    if proxy is not None and proxy not in self.looked_up:
                        accl2.append(proxy)
                    if len(accl2) > 0:
                        lookup_accounts(accl2)
            accounts = []
            for a in acclist:
                accounts.append(Account(a))
            user_info(accounts)
        if vote_event["weight"] < 0:
            authorperm = construct_authorperm(vote_event["author"], vote_event["permlink"])
            # print(authorperm)
            try:
                process_vote_content(Comment(authorperm))
            except exceptions.ContentDoesNotExistsException:
                print("Could not find Comment: %s" % (authorperm))
            al = list()
            if not vote_event["voter"] in self.looked_up:
                al.append(vote_event["voter"])
                self.looked_up.add(vote_event["voter"])
            if not vote_event["author"] in self.looked_up:
                al.append(vote_event["author"])
                self.looked_up.add(vote_event["author"])
            if len(al) > 0:
                lookup_accounts(al)