def summoncharbot():
    print(f'[Starting Character Bot]')
    REGEX = '(?<=^|(?<=[^a-zA-Z0-9-.]))@([A-Za-z]+[A-Za-z0-9]+)'
    username = '******'
    REGCHA = '(?<=^|(?<=[^a-zA-Z0-9-.]))!([A-Za-z]+[A-Za-z0-9]+)'
    newchar = 'generate'

    while True:
        try:
            for post in chain.stream(opNames="comment",
                                     threading=True,
                                     thread_num=5):
                mentions = re.findall(REGEX, post["body"])
                gen_new_char = re.findall(REGCHA, post["body"])
                comment = Comment(post)
                perm = comment.authorperm
                parent = construct_authorperm(
                    Comment(perm).parent_author,
                    Comment(perm).parent_permlink)
                author = post['author']
                if Comment(perm).is_comment():
                    if username in mentions:
                        comment.reply(
                            "Character Generator Bot Summoned! \nUse `!generate` to create a random character.",
                            "", username)
                        commentlink = comment.permlink
                        print("Mention found - Comment made: " + commentlink)
        finally:
            print("Exiting Bot")
Beispiel #2
0
def summon_upvotebot():
    print(f"[Starting up]")
    while True:
        try:
            for post in chain.stream(opNames="comment",
                                     threading=True,
                                     thread_num=5):
                mentions = re.findall(REGEX, post["body"])
                comment = Comment(post)
                perm = comment.authorperm
                parent = construct_authorperm(
                    Comment(perm).parent_author,
                    Comment(perm).parent_permlink)
                author = post["author"]
                if Comment(perm).is_comment and botname in mentions:
                    print(
                        f"[{author} just mentioned {botname} in {perm} in reply to {parent}]"
                    )
                    if author in followees:
                        Comment(parent).upvote(weight=weight, voter=botname)
                        print(
                            f"[{botname} voted {weight}% on {parent} per {author}'s request]"
                        )
                    else:
                        print(
                            f"[{author} tried to summon {botname} but is not in the whitelist]"
                        )
        except Exception as error:
            print(repr(error))
            continue
Beispiel #3
0
 def test_comment(self, node_param):
     if node_param == "non_appbase":
         bts = self.bts
     else:
         bts = self.appbase
     with self.assertRaises(
         exceptions.ContentDoesNotExistsException
     ):
         Comment("@abcdef/abcdef", steem_instance=bts)
     c = Comment(self.authorperm, steem_instance=bts)
     self.assertTrue(isinstance(c.id, int))
     self.assertTrue(c.id > 0)
     self.assertEqual(c.author, self.author)
     self.assertEqual(c.permlink, self.permlink)
     self.assertEqual(c.authorperm, self.authorperm)
     self.assertEqual(c.category, self.category)
     self.assertEqual(c.parent_author, '')
     self.assertEqual(c.parent_permlink, self.category)
     self.assertEqual(c.title, self.title)
     self.assertTrue(len(c.body) > 0)
     for key in ['tags', 'users', 'image', 'links', 'app', 'format']:
         self.assertIn(key, list(c.json_metadata.keys()))
     self.assertTrue(c.is_main_post())
     self.assertFalse(c.is_comment())
     self.assertTrue(isinstance(c.get_reblogged_by(), list))
     self.assertTrue(len(c.get_reblogged_by()) > 0)
     self.assertTrue(isinstance(c.get_votes(), list))
     if node_param == "appbase":
         self.assertTrue(len(c.get_votes()) > 0)
         self.assertTrue(isinstance(c.get_votes()[0], Vote))
Beispiel #4
0
 def test_comment(self, node_param):
     if node_param == "non_appbase":
         bts = self.bts
     else:
         bts = self.appbase
     with self.assertRaises(exceptions.ContentDoesNotExistsException):
         Comment("@abcdef/abcdef", steem_instance=bts)
     c = Comment(self.authorperm, steem_instance=bts)
     self.assertTrue(isinstance(c.id, int))
     self.assertTrue(c.id > 0)
     self.assertEqual(c.author, self.author)
     self.assertEqual(c.permlink, self.permlink)
     self.assertEqual(c.authorperm, self.authorperm)
     self.assertEqual(c.category, self.category)
     self.assertEqual(c.parent_author, '')
     self.assertEqual(c.parent_permlink, self.category)
     self.assertEqual(c.title, self.title)
     self.assertTrue(len(c.body) > 0)
     self.assertTrue(isinstance(c.json_metadata, dict))
     self.assertTrue(c.is_main_post())
     self.assertFalse(c.is_comment())
     if c.is_pending():
         self.assertFalse(
             (c.time_elapsed().total_seconds() / 60 / 60 / 24) > 7.0)
     else:
         self.assertTrue(
             (c.time_elapsed().total_seconds() / 60 / 60 / 24) > 7.0)
     self.assertTrue(isinstance(c.get_reblogged_by(), list))
     self.assertTrue(len(c.get_reblogged_by()) > 0)
     self.assertTrue(isinstance(c.get_votes(), list))
     if node_param == "appbase":
         self.assertTrue(len(c.get_votes()) > 0)
         self.assertTrue(isinstance(c.get_votes()[0], Vote))
def banned_comment(url):
    """
    Comments on the given contribution letting them know that they are banned.
    """
    post = Comment(url)
    comment = constants.COMMENT_BANNED.format(post.author)
    post.reply(comment, author="amosbastian")
 def check_beneficiaries(self, author, permlink):
     if author not in self.accounts:
         return
     if self.accounts[author]["delegated_hp"] == 0:
         return
     if self.accounts[author]["delegation_revoked"]:
         return
     if not self.config["beneficiaryRemoval"]:
         return
     comment = None
     cnt = 0
     while comment is None and cnt < 10:
         cnt += 1
         try:
             comment = Comment(construct_authorperm(author, permlink),
                               blockchain_instance=self.hive)
         except:
             comment = None
             time.sleep(3)
     referrer_ok = False
     for bene in comment["beneficiaries"]:
         if bene["account"] == self.config["referrerAccount"] and bene[
                 "weight"] == self.accounts[author]["weight"]:
             referrer_ok = True
     if not referrer_ok:
         self.remove_delegation(author)
         self.notify_account(author,
                             self.config["delegationBeneficiaryMsg"])
Beispiel #7
0
def contribution(row):
    """Create a dictionary for a contribution post.

    :param row: list of values from worksheet
    :return: dict for contribution
    """
    url_split = row[2].split('/')
    author = url_split[4][1:] if url_split[4][0] == "@" else url_split[3][1:]
    permlink = url_split[5] if url_split[4][0] == "@" else url_split[4]
    review_date = parse_date_to_iso(row[1])
    repo_split = row[3].split('/') if 'github.com' in row[3] else []
    staff_pick = {
        'picked_by': row[8],
        'date': parse_date_to_iso(row[7])
    } if row[6].lower() == 'yes' else None

    repo_full_name = f'{repo_split[3]}/{repo_split[4].split("?")[0]}' \
        if len(repo_split) > 4 else ''
    score = float(row[5]) if row[5] else 0
    category = row[4]

    post = Comment(f'@{author}/{permlink}')
    post_meta = post.json_metadata
    post_json = post.json()
    created = parse_date_to_iso(post_json['created'])

    contrib = {
        'author':
        author,
        'permlink':
        permlink,
        'post_category':
        'utopian-io',
        'moderator': {
            'account': (row[0]),
            'date': review_date
        },
        'repository': {
            'full_name':
            repo_full_name,
            'html_url':
            (f'https://github.com/{repo_full_name}' if repo_full_name else '')
        },
        'score':
        score,
        'status':
        get_status(row),
        'category':
        category or
        (post_meta.get('tags')[1] if len(post_meta.get('tags')) > 1 else ''),
        'tags': (post_meta.get('tags')),
        'created':
        created,
        'body': (post_json.get('body', '')),
        'utopian_vote': (get_utopian_vote(post)),
        'staff_pick':
        staff_pick
    }

    return contrib
Beispiel #8
0
 def test_delete(self):
     bts = self.bts
     c = Comment(self.authorperm, steem_instance=bts)
     tx = c.delete(account="test")
     self.assertEqual((tx["operations"][0][0]), "delete_comment")
     op = tx["operations"][0][1]
     self.assertIn(self.author, op["author"])
def steemstem_vote_finder(user):
    stm = Steem(node=[
        'https://rpc.steemviz.com', 'https://api.steem.house',
        'https://gtg.steem.house:8090', 'wss://gtg.steem.house:8090',
        'https://steemd-appbase.steemit.com', 'wss://steemd.privex.io',
        'https://steemd.privex.io', 'wss://anyx.io', 'https://anyx.io',
        'wss://rpc.curiesteem.com', 'https://rpc.buildteam.io',
        'https://rpc.steemliberator.com', 'https://appbasetest.timcliff.com',
        'wss://rpc.steemviz.com', 'https://steemd.minnowsupportproject.org'
    ])
    set_shared_steem_instance(stm)

    steemstem_user = user
    acc = Account(steemstem_user)
    for post in acc.blog_history():
        if post['parent_author'] == '' and post['author'] == steemstem_user:
            p_link = post['author'] + '/' + post['permlink']
            com_link = Comment(p_link)
            if 'steemstem' in com_link.get_votes():

                html_link = '<a href= \"https://steemit.com/' + '@' + p_link + '\"' + '>' + unidecode(
                    post['title']) + '</a>'
                print(html_link)
                f = open(user + "_" + "steemstem.txt", "a")
                f.write(html_link + '\n')
                f.close()
Beispiel #10
0
 def test_comment(self, node_param):
     if node_param == "instance":
         stm = Steem(node="abc", autoconnect=False, num_retries=1)
         set_shared_steem_instance(self.bts)
         o = Comment("@gtg/witness-gtg-log")
         self.assertIn(o.steem.rpc.url, self.urls)
         with self.assertRaises(NumRetriesReached):
             Comment("@gtg/witness-gtg-log", steem_instance=stm)
     else:
         set_shared_steem_instance(
             Steem(node="abc", autoconnect=False, num_retries=1))
         stm = self.bts
         o = Comment("@gtg/witness-gtg-log", steem_instance=stm)
         self.assertIn(o.steem.rpc.url, self.urls)
         with self.assertRaises(NumRetriesReached):
             Comment("@gtg/witness-gtg-log")
Beispiel #11
0
def staff_pick_section(staff_picks):
    """Creates the staff pick section for the Utopian weekly post."""
    LOGGER.info("Generating staff pick statistics section...")
    section = "## Staff Picks"
    for staff_pick in staff_picks["staff_picks"]:
        url = staff_pick["url"]
        post = Comment(url)
        title = post.json()["title"]

        # If title can't be retrieved set it to the post's URL
        if not title:
            title = url
        author = staff_pick['author']
        category = staff_pick['category']

        # Add staff pick to the string
        section += (
            f"<br><br>### &lt;a href='{url}'&gt;{title}&lt;/a&gt; by @{author} "
            f"[{category}]<br><br>[Image (contributor profile image / image from "
            "the post)]<br><br>[Paragraph: Background info on project etc.]"
            "<br><br>[Paragraph: CM review, including etc.]<br><br>"
            f"Total payout: {staff_pick['total_payout']:.2f} STU<br>"
            f"Number of votes: {staff_pick['total_votes']}")

    return section
Beispiel #12
0
def listen_blockchain_comments():
    """Listens to blockchain for comments by specified accounts at
    Utopian task request posts and put them to a queue.

    """
    for comment_op in listen_blockchain_ops(["comment"]):
        if not comment_op["parent_author"] or comment_op[
                "author"] not in ACCOUNTS:
            continue
        try:
            comment = Comment(
                f'@{comment_op["author"]}/{comment_op["permlink"]}')
        except beem.exceptions.ContentDoesNotExistsException:
            logger.info(
                "Comment does not exist. %s",
                f'@{comment_op["author"]}/{comment_op["permlink"]}',
            )
        except:
            logger.exception("Error while fetching comment")
        else:
            root = comment.get_parent()
            logger.debug("%s, %s", comment["url"], root["url"])
            if is_utopian_task_request(root):
                logger.info("Added to comments queue - %s %s", comment["url"],
                            root["url"])
                QUEUE_COMMENTS.put_nowait((comment, root))
Beispiel #13
0
    def test_comment_dict(self):
        bts = self.bts
        title = ''
        cnt = 0
        while title == '' and cnt < 5:
            c = Comment({
                'author': self.author,
                'permlink': self.permlink
            },
                        steem_instance=bts)
            c.refresh()
            title = c.title
            cnt += 1
            if title == '':
                c.steem.rpc.next()
                c.refresh()
                title = c.title

        self.assertEqual(c.author, self.author)
        self.assertEqual(c.permlink, self.permlink)
        self.assertEqual(c.authorperm, self.authorperm)
        self.assertEqual(c.category, self.category)
        self.assertEqual(c.parent_author, '')
        self.assertEqual(c.parent_permlink, self.category)
        self.assertEqual(c.title, self.title)
Beispiel #14
0
def add_comment(contribution):
    """Adds the authorperm of the moderator's comment to the database."""
    if contribution.moderator == "amosbastian":
        return

    post = Comment(contribution.url)

    inserted = False
    for comment in post.get_replies():
        if comment.author == contribution.moderator:
            age = comment.time_elapsed()
            collection = constants.DB.comments
            collection.insert({
                "url":
                comment.authorperm,
                "upvote_time":
                datetime.now() + timedelta(minutes=10) - age,
                "inserted":
                datetime.now(),
                "upvoted":
                False,
                "category":
                contribution.category
            })
            inserted = True

    if not inserted:
        collection = constants.DB.missed_posts
        collection.insert({
            "url": contribution.url,
            "moderator": contribution.moderator,
            "category": contribution.category
        })
Beispiel #15
0
    def test_export(self):
        bts = self.bts

        if bts.rpc.get_use_appbase():
            content = bts.rpc.get_discussion(
                {
                    'author': self.author,
                    'permlink': self.permlink
                }, api="tags")
        else:
            content = bts.rpc.get_content(self.author, self.permlink)

        c = Comment(self.authorperm, steem_instance=bts)
        keys = list(content.keys())
        json_content = c.json()
        exclude_list = ["json_metadata", "reputation", "active_votes"]
        for k in keys:
            if k not in exclude_list:
                if isinstance(content[k], dict) and isinstance(
                        json_content[k], list):
                    self.assertEqual(list(content[k].values()),
                                     json_content[k])
                elif isinstance(content[k], str) and isinstance(
                        json_content[k], str):
                    self.assertEqual(content[k].encode('utf-8'),
                                     json_content[k].encode('utf-8'))
                else:
                    self.assertEqual(content[k], json_content[k])
Beispiel #16
0
def main():
    result = constants.UNREVIEWED.get_all_values()
    vipo = constants.VIPO
    is_vipo = False

    already_voted_on = [
        contribution["url"] for contribution in
        constants.DB_UTEMPIAN.contributions.find({
            "status": "unreviewed",
            "voted_on": True
        })
    ]

    for row in result[1:]:
        contribution = Contribution(row)
        moderator = contribution.moderator
        score = contribution.score

        if ((moderator != "" and score != "")
                or contribution.url in already_voted_on):
            today = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            contribution.review_date = today

            try:
                post = Comment(contribution.url)
            except ContentDoesNotExistsException:
                constants.UNREVIEWED.delete_row(result.index(row) + 1)
                return

            if contribution.url in already_voted_on:
                contribution.moderator = "IGNORE"
                contribution.score = 0
                contribution.weight = 0
                constants.UNREVIEWED.delete_row(result.index(row) + 1)
                move_to_reviewed(contribution, post)
                continue

            if post.author in vipo:
                is_vipo = True

            category = contribution.category.strip()
            contribution.vote_status, contribution.weight = exponential_vote(
                float(score), category, contribution.url, is_vipo)

            if not moderator.upper() in [
                    "BANNED", "IGNORED", "IGNORE", "IRRELEVANT"
            ]:
                contribution.review_status = "Pending"

            constants.LOGGER.info(
                f"Moving {contribution.url} to reviewed sheet with voting % "
                f"{contribution.weight} and score {score}")

            constants.UNREVIEWED.delete_row(result.index(row) + 1)
            move_to_reviewed(contribution, post)

            if float(score) > constants.MINIMUM_SCORE:
                vote_contribution(contribution)
                add_comment(contribution)
            return
Beispiel #17
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(hive=True), num_retries=10))
        cls.bts = Steem(
            node=nodelist.get_nodes(hive=True),
            nobroadcast=True,
            keys={"active": wif},
            num_retries=10
        )
        # from getpass import getpass
        # self.bts.wallet.unlock(getpass())
        set_shared_steem_instance(cls.bts)
        cls.bts.set_default_account("test")

        acc = Account("fullnodeupdate", steem_instance=cls.bts)
        n_votes = 0
        index = 0
        entries = acc.get_blog_entries(limit=30)[::-1]
        while n_votes == 0:
            comment = Comment(entries[index], steem_instance=cls.bts)
            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)
Beispiel #18
0
def obey(command, blocknum):  # Once Minion receives his orders, he obeys
    print('Obeying my master, his orders are:')
    print(command)
    # Time to slice the memo, first word action npost(new post) rpost(reply to post or comment)
    # For rpost, also extract the author/permanentlink Minion is to reply to
    # the rest of the memo is the body of the post/comment
    memobreak = command
    action = memobreak.split(
        ' ', 1)[0]  # get the first word off the memo, the command

    print('Im performing the action:', action)
    # on this block any command could be coded
    if action == 'npost':
        body = memobreak.split(
            ' ', 1)[1]  # this gets the rest of the memo, it becomes the body
        steem.post("Incubator Post on Block:" + blocknum,
                   body,
                   author=account,
                   tags=["incubator"],
                   self_vote=True)
        print('Post Successfully submitted')
    elif action == 'rpost':
        authorperm = memobreak.split(
            ' ',
            2)[1]  # the link to author/permlink is extracted from the memo
        c = Comment(authorperm)
        body = memobreak.split(' ', 2)[2]  # body of the reply
        c.reply(body, title='', author=account, meta=None)  # execute reply
        print('Reply Successfully submitted')
    else:
        print('no recognizable command found, error')

    account.transfer(operator, '0.001', "STEEM",
                     'Command Executed')  # Respond, Refund
    print('Waiting for new Instructions')
Beispiel #19
0
 def setUpClass(cls):
     cls.bts = Steem(
         node=get_node_list(appbase=False),
         nobroadcast=True,
         keys={"active": wif},
         num_retries=10
     )
     cls.appbase = Steem(
         node=get_node_list(appbase=True),
         nobroadcast=True,
         keys={"active": wif},
         num_retries=10
     )
     cls.authorperm = "@gtg/ffdhu-gtg-witness-log"
     [author, permlink] = resolve_authorperm(cls.authorperm)
     cls.author = author
     cls.permlink = permlink
     cls.category = 'witness-category'
     cls.title = 'gtg witness log'
     # from getpass import getpass
     # self.bts.wallet.unlock(getpass())
     set_shared_steem_instance(cls.bts)
     cls.bts.set_default_account("test")
     cnt = 0
     title = ''
     while cnt < 5 and title == '':
         c = Comment(cls.authorperm, steem_instance=cls.bts)
         title = c["title"]
         cls.bts.rpc.next()
Beispiel #20
0
    def test_vote(self):
        bts = self.bts
        c = Comment(self.authorperm, blockchain_instance=bts)
        bts.txbuffer.clear()
        tx = c.vote(100, account="test")
        self.assertEqual((tx["operations"][0][0]), "vote")
        op = tx["operations"][0][1]
        self.assertIn("test", op["voter"])
        c.blockchain.txbuffer.clear()
        tx = c.upvote(weight=150, voter="test")
        op = tx["operations"][0][1]
        self.assertEqual(op["weight"], 10000)
        c.blockchain.txbuffer.clear()
        tx = c.upvote(weight=99.9, voter="test")
        op = tx["operations"][0][1]
        self.assertEqual(op["weight"], 9990)

        c.blockchain.txbuffer.clear()
        tx = c.downvote(weight=150, voter="test")
        op = tx["operations"][0][1]
        self.assertEqual(op["weight"], -10000)
        c.blockchain.txbuffer.clear()
        tx = c.downvote(weight=99.9, voter="test")
        op = tx["operations"][0][1]
        self.assertEqual(op["weight"], -9990)
Beispiel #21
0
 def test_reply(self):
     bts = self.bts
     c = Comment(self.authorperm, steem_instance=bts)
     tx = c.reply(body="Good post!", author="test")
     self.assertEqual((tx["operations"][0][0]), "comment")
     op = tx["operations"][0][1]
     self.assertIn("test", op["author"])
Beispiel #22
0
 def test_vote(self, node_param):
     if node_param == "non_appbase":
         bts = self.bts
     else:
         bts = self.appbase
     c = Comment(self.authorperm, steem_instance=bts)
     bts.txbuffer.clear()
     tx = c.vote(100, account="test")
     self.assertEqual((tx["operations"][0][0]), "vote")
     op = tx["operations"][0][1]
     self.assertIn("test", op["voter"])
     c.steem.txbuffer.clear()
     tx = c.upvote(weight=150, voter="test")
     op = tx["operations"][0][1]
     self.assertEqual(op["weight"], 10000)
     c.steem.txbuffer.clear()
     tx = c.upvote(weight=99.9, voter="test")
     op = tx["operations"][0][1]
     self.assertEqual(op["weight"], 9990)
     c.steem.txbuffer.clear()
     tx = c.downvote(weight=-150, voter="test")
     op = tx["operations"][0][1]
     self.assertEqual(op["weight"], -10000)
     c.steem.txbuffer.clear()
     tx = c.downvote(weight=-99.9, voter="test")
     op = tx["operations"][0][1]
     self.assertEqual(op["weight"], -9990)
def benchmark_calls(node,
                    authorpermvoter,
                    num_retries=10,
                    num_retries_call=10,
                    timeout=60):
    block_count = 0
    history_count = 0
    access_time = timeout
    follow_time = 0
    sucessfull = False
    error_msg = None
    start_total = timer()
    account_name = "gtg"

    [author, permlink, voter] = resolve_authorpermvoter(authorpermvoter)
    authorperm = construct_authorperm(author, permlink)

    try:
        stm = Steem(node=node,
                    num_retries=num_retries,
                    num_retries_call=num_retries_call,
                    timeout=timeout)

        start = timer()
        Vote(authorpermvoter, steem_instance=stm)
        stop = timer()
        vote_time = stop - start
        start = timer()
        c = Comment(authorperm, steem_instance=stm)
        if c.title == '':
            raise AssertionError("title must not be empty!")
        stop = timer()
        comment_time = stop - start
        start = timer()
        acc = Account(author, steem_instance=stm)
        # if acc.json()["json_metadata"] == '':
        #    raise AssertionError("json_metadata must not be empty!")
        stop = timer()
        account_time = stop - start
        sucessfull = True
        access_time = (vote_time + comment_time + account_time) / 3.0
    except NumRetriesReached:
        error_msg = 'NumRetriesReached'
        sucessfull = False
    except KeyboardInterrupt:
        error_msg = 'KeyboardInterrupt'
        # quit = True
    except Exception as e:
        error_msg = str(e)
        sucessfull = False
    total_duration = float("{0:.2f}".format(timer() - start_total))
    access_time = float("{0:.3f}".format(access_time))
    return {
        'sucessfull': sucessfull,
        'node': node,
        'error': error_msg,
        'total_duration': total_duration,
        'access_time': access_time,
        'count': None
    }
Beispiel #24
0
def vote_update(row, row_index, staff_picked=False):
    """
    Upvotes the highest priority contribution and updates the spreadsheet.
    """
    url = row[2]
    category = row[4]

    account = Account(ACCOUNT)
    # Check if post was staff picked
    if staff_picked:
        vote_pct = MAX_VOTE[category]
    else:
        vote_pct = float(row[-1])

    try:
        post = Comment(url, steem_instance=steem)
        logger.info(f"Voting on {post.authorperm} with {vote_pct}%")
        # If in last twelve hours before payout don't vote
        if valid_age(post):
            post.vote(vote_pct, account=account)
            bot_comment(post, category, account, staff_picked)
            reviewed.update_cell(row_index, 10, "Yes")
        else:
            reviewed.update_cell(row_index, 10, "EXPIRED")
    except Exception as vote_error:
        logger.error(vote_error)
Beispiel #25
0
 def test_delete(self):
     bts = self.bts
     bts.txbuffer.clear()
     c = Comment(self.authorperm, blockchain_instance=bts)
     tx = c.delete(account="test")
     self.assertEqual((tx["operations"][0][0]), "delete_comment")
     op = tx["operations"][0][1]
     self.assertIn(self.author, op["author"])
Beispiel #26
0
 def test_reply(self):
     bts = self.bts
     bts.txbuffer.clear()
     c = Comment(self.authorperm, blockchain_instance=bts)
     tx = c.reply(body="Good post!", author="test")
     self.assertEqual((tx["operations"][0][0]), "comment")
     op = tx["operations"][0][1]
     self.assertIn("test", op["author"])
Beispiel #27
0
 def test_resteem(self):
     bts = self.bts
     c = Comment(self.authorperm, steem_instance=bts)
     tx = c.resteem(account="test")
     self.assertEqual(
         (tx["operations"][0][0]),
         "custom_json"
     )
Beispiel #28
0
def get_payout(s, author, permlink):
    try:
        acc = Comment("@{}/{}".format(author, permlink), steem_instance=s)
        payout = float(str(acc.reward).split()[0])
    except Exception as e:
        print("Error in payout: {}".format(str(e)))
        payout = 0.00

    return payout
Beispiel #29
0
def post_detail(request, author, permlink, **args):
    author_perm = construct_authorperm(author, permlink)
    post = Comment(author_perm, blockchain_instance=hv)
    if post:
        replies = post.get_replies(raw_data=True)
        post = strip(post)
        for reply in replies:
            reply = strip(reply)
    return render(request, 'blog/post_detail.html', {'post': post, 'replies': replies})
Beispiel #30
0
 def test_comment(self, node_param):
     if node_param == "instance":
         set_shared_steem_instance(self.bts)
         o = Comment(self.authorperm)
         self.assertIn(o.steem.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Comment(self.authorperm,
                     steem_instance=Steem(node="https://abc.d",
                                          autoconnect=False,
                                          num_retries=1))
     else:
         set_shared_steem_instance(
             Steem(node="https://abc.d", autoconnect=False, num_retries=1))
         stm = self.bts
         o = Comment(self.authorperm, steem_instance=stm)
         self.assertIn(o.steem.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Comment(self.authorperm)