コード例 #1
0
ファイル: test_comment.py プロジェクト: E-D-A/beem
 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))
コード例 #2
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))
コード例 #3
0
ファイル: app.py プロジェクト: TheCrazyGM/voteleader
def monitor():
    table = db.load_table("leaderboard")
    vote_table = db["vote_history"]
    print("[Monitor Starting up...]")
    # Read the live stream and filter out only transfers
    for post in stream:
        try:
            q = table.find_one(user=post["author"])
            if q is not None and post["author"] == q["user"]:
                perm = construct_authorperm(post["author"], post["permlink"])
                c = Comment(perm, blockchain_instance=hive)
                if c.is_main_post():
                    today = datetime.now(timezone.utc)
                    week_tally = tally(post["author"])
                    print(f"[Post Found! By: {q['user']} Rank: {q['rank']}]")
                    vote_weight = math.ceil(
                        ((160 - q["rank"]) * 2.5) / (week_tally))
                    vote_weight = 100 if vote_weight >= 100 else vote_weight
                    vote_weight = 1 if vote_weight <= 1 else vote_weight
                    print(
                        f"[{week_tally} post(s) a week. - {perm} should be voted with a {vote_weight}% upvote.]"
                    )
                    # Trying to catch about the 4 minute mark for curation.
                    time.sleep(240)
                    tx = c.upvote(weight=vote_weight, voter=voter)
                    reply_body = f"Your current Rank ({q['rank']}) in the battle Arena of Holybread has granted you an Upvote of {vote_weight}%"
                    # print(tx)
                    reply_tx = c.reply(reply_body,
                                       title="Leaderboard Vote",
                                       author=voter)
                    # print(reply_tx)
                    vote_table.insert(
                        dict(
                            user=q["user"],
                            rank=q["rank"],
                            post=perm,
                            vote_weight=vote_weight,
                            vote_time=today,
                        ))
        except Exception as e:
            print(f"[Error: {e}]")
コード例 #4
0
 def test_comment(self):
     bts = self.bts
     with self.assertRaises(exceptions.ContentDoesNotExistsException):
         Comment("@abcdef/abcdef", steem_instance=bts)
     title = ''
     cnt = 0
     while title == '' and cnt < 5:
         c = Comment(self.authorperm, steem_instance=bts)
         title = c.title
         cnt += 1
         if title == '':
             c.blockchain.rpc.next()
             c.refresh()
             title = c.title
     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)
     votes = c.get_votes()
     self.assertTrue(isinstance(votes, list))
     self.assertTrue(len(votes) > 0)
     self.assertTrue(isinstance(votes[0], Vote))
コード例 #5
0
        elif member["blacklisted"] is None and (member["steemcleaners"]
                                                or member["buildawhale"]):
            continue

        rshares = member["balance_rshares"] / comment_vote_divider
        if post_list[authorperm][
                "main_post"] == 1 and rshares < minimum_vote_threshold:
            continue
        elif post_list[authorperm][
                "main_post"] == 0 and rshares < minimum_vote_threshold * 2:
            continue
        try:
            c = Comment(authorperm, steem_instance=stm)
        except:
            continue
        main_post = c.is_main_post()
        already_voted = False
        if c.time_elapsed() > timedelta(hours=156):
            continue

        for v in c["active_votes"]:
            if v["voter"] in accounts:
                already_voted = True
        if already_voted:
            postTrx.update_voted(author, created, already_voted)
            continue
        vote_delay_sec = 15 * 60
        if member["upvote_delay"] is not None:
            vote_delay_sec = member["upvote_delay"]
        if c.time_elapsed() < timedelta(seconds=vote_delay_sec):
            continue
コード例 #6
0
                                    if vote["voter"] == a:
                                        continue
                                    if a not in ["quarry", "steemdunk"]:
                                        print(a)
                                    if a in [
                                            "smartsteem", "smartmarket",
                                            "minnowbooster"
                                    ]:
                                        vote_did_sign = False

                                if not vote_did_sign:
                                    continue
                            except:
                                continue

                        if c.is_main_post():
                            if acc_name == "steembasicincome":
                                rshares = int(
                                    vote["rshares"]) * upvote_multiplier
                                if rshares < rshares_per_cycle:
                                    rshares = rshares_per_cycle
                            else:
                                rshares = int(
                                    vote["rshares"]) * upvote_multiplier
                            member_data[
                                vote["voter"]]["earned_rshares"] += rshares
                            member_data[
                                vote["voter"]]["curation_rshares"] += rshares
                            member_data[
                                vote["voter"]]["balance_rshares"] += rshares
                        else:
コード例 #7
0
    def run(self, start_block):
        self.stm.wallet.unlock(self.config["wallet_password"])
        self.blockchain = Blockchain(mode='head', steem_instance=self.stm)
        stop_block = self.blockchain.get_current_block_num()

        if start_block is not None:
            last_block_num = start_block - 1
        self.log_data["start_block_num"] = start_block
        for op in self.blockchain.stream(start=start_block,
                                         stop=stop_block,
                                         opNames=["comment"],
                                         max_batch_size=50):
            self.log_data = print_block_log(self.log_data, op,
                                            self.config["print_log_at_block"])
            last_block_num = op["block_num"]

            if op["type"] == "comment":
                token = None

                for key in self.token_config:
                    if op["body"].find(
                            self.token_config[key]["comment_command"]) >= 0:
                        token = key
                if token is None:
                    continue
                if op["author"] == self.token_config[token]["token_account"]:
                    continue

                try:
                    c_comment = Comment(op, steem_instance=self.stm)
                    c_comment.refresh()
                except:
                    logger.warn("Could not read %s/%s" %
                                (op["author"], op["permlink"]))
                    continue
                if c_comment.is_main_post():
                    continue
                if abs((c_comment["created"] -
                        op['timestamp']).total_seconds()) > 9.0:
                    logger.warn("Skip %s, as edited" % c_comment["authorperm"])
                    continue
                already_replied = False
                for r in c_comment.get_all_replies():
                    if r["author"] == self.token_config[token][
                            "token_account"]:
                        already_replied = True
                if already_replied:
                    continue

                muting_acc = Account(self.token_config[token]["token_account"],
                                     steem_instance=self.stm)
                blocked_accounts = muting_acc.get_mutings()
                if c_comment["author"] in blocked_accounts:
                    logger.info("%s is blocked" % c_comment["author"])
                    continue

                # Load bot token balance
                bot_wallet = Wallet(self.token_config[token]["token_account"],
                                    steem_instance=self.stm)
                symbol = bot_wallet.get_token(
                    self.token_config[token]["symbol"])

                # parse amount when user_can_specify_amount is true
                amount = self.token_config[token]["default_amount"]
                if self.token_config[token]["user_can_specify_amount"]:
                    start_index = c_comment["body"].find(
                        self.token_config[token]["comment_command"])
                    stop_index = c_comment["body"][start_index:].find("\n")
                    if stop_index >= 0:
                        command = c_comment["body"][start_index +
                                                    1:start_index + stop_index]
                    else:
                        command = c_comment["body"][start_index + 1:]

                    command_args = command.replace('  ', ' ').split(" ")[1:]

                    if len(command_args) > 0:
                        try:
                            amount = float(command_args[0])
                        except Exception as e:
                            exc_type, exc_obj, exc_tb = sys.exc_info()
                            fname = os.path.split(
                                exc_tb.tb_frame.f_code.co_filename)[1]
                            logger.warn("%s - %s - %s" %
                                        (str(exc_type), str(fname),
                                         str(exc_tb.tb_lineno)))
                            logger.info("Could not parse amount")
                    if self.token_config[token][
                            "maximum_amount_per_comment"] and amount > self.token_config[
                                token]["maximum_amount_per_comment"]:
                        amount = self.token_config[token][
                            "maximum_amount_per_comment"]

                if not self.config["no_broadcast"] and self.stm.wallet.locked(
                ):
                    self.stm.wallet.unlock(self.config["wallet_password"])

                self.log_data["new_commands"] += 1
                wallet = Wallet(c_comment["author"], steem_instance=self.stm)
                token_in_wallet = wallet.get_token(
                    self.token_config[token]["symbol"])
                if token_in_wallet is not None:
                    balance = float(token_in_wallet["balance"])
                    if "stake" in token_in_wallet:
                        balance += float(token_in_wallet['stake'])
                    if 'delegationsIn' in token_in_wallet and float(
                            token_in_wallet['delegationsIn']) > 0:
                        balance += float(token_in_wallet['delegationsIn'])
                    if 'pendingUnstake' in token_in_wallet and float(
                            token_in_wallet['pendingUnstake']) > 0:
                        balance += float(token_in_wallet['pendingUnstake'])

                    if balance > self.token_config[token][
                            "min_token_in_wallet"]:
                        if self.token_config[token][
                                "token_in_wallet_for_each_outgoing_token"] > 0:
                            max_token_to_give = int(
                                balance / self.token_config[token]
                                ["token_in_wallet_for_each_outgoing_token"])
                        else:
                            max_token_to_give = self.token_config[token][
                                "maximum_amount_per_comment"]
                    else:
                        max_token_to_give = 0
                else:
                    max_token_to_give = 0

                db_data = read_data(self.data_file)
                if "accounts" in db_data and c_comment["author"] in db_data[
                        "accounts"] and token in db_data["accounts"][
                            c_comment["author"]]:
                    if db_data["accounts"][c_comment["author"]][token][
                            "last_date"] == date.today(
                            ) and self.token_config[token][
                                "token_in_wallet_for_each_outgoing_token"] > 0:
                        max_token_to_give = max_token_to_give - db_data[
                            "accounts"][c_comment["author"]][token]["amount"]

                if amount > max_token_to_give:
                    amount = max_token_to_give
                if amount > self.token_config[token][
                        "maximum_amount_per_comment"]:
                    amount = self.token_config[token][
                        "maximum_amount_per_comment"]

                if token_in_wallet is None or float(
                        token_in_wallet["balance"]
                ) < self.token_config[token]["min_token_in_wallet"]:
                    reply_body = self.token_config[token]["fail_reply_body"]
                elif max_token_to_give < 1:
                    reply_body = self.token_config[token][
                        "no_token_left_for_today"]
                elif c_comment["parent_author"] == c_comment["author"]:
                    reply_body = "You cannot sent token to yourself."
                elif float(symbol["balance"]) < amount:
                    reply_body = self.token_config[token]["no_token_left_body"]
                else:
                    if "{}" in self.token_config[token]["sucess_reply_body"]:
                        reply_body = (self.token_config[token]
                                      ["sucess_reply_body"]).format(
                                          c_comment["parent_author"])
                    else:
                        reply_body = self.token_config[token][
                            "sucess_reply_body"]
                    if "{}" in self.token_config[token]["token_memo"]:
                        token_memo = (
                            self.token_config[token]["token_memo"]).format(
                                c_comment["author"])
                    else:
                        token_memo = self.token_config[token]["token_memo"]

                    sendwallet = Wallet(
                        self.token_config[token]["token_account"],
                        steem_instance=self.stm)

                    try:
                        logger.info(
                            "Sending %.2f %s to %s" %
                            (amount, self.token_config[token]["symbol"],
                             c_comment["parent_author"]))
                        sendwallet.transfer(c_comment["parent_author"], amount,
                                            self.token_config[token]["symbol"],
                                            token_memo)

                        if "accounts" in db_data:
                            accounts = db_data["accounts"]
                        else:
                            accounts = {}
                        if c_comment["author"] not in accounts:
                            accounts[c_comment["author"]] = {}
                            accounts[c_comment["author"]][token] = {
                                "last_date": date.today(),
                                "n_comments": 1,
                                "amount": amount
                            }
                        elif token not in accounts[c_comment["author"]]:
                            accounts[c_comment["author"]][token] = {
                                "last_date": date.today(),
                                "n_comments": 1,
                                "amount": amount
                            }
                        else:
                            if accounts[c_comment["author"]][token][
                                    "last_date"] < date.today():
                                accounts[c_comment["author"]][token] = {
                                    "last_date": date.today(),
                                    "n_comments": 1,
                                    "amount": amount
                                }
                            else:
                                accounts[c_comment["author"]][token][
                                    "n_comments"] += 1
                                accounts[c_comment["author"]][token][
                                    "amount"] += amount

                        store_data(self.data_file, "accounts", accounts)
                        logger.info(
                            "%s - %s" %
                            (c_comment["author"],
                             str(accounts[c_comment["author"]][token])))

                    except Exception as e:
                        exc_type, exc_obj, exc_tb = sys.exc_info()
                        fname = os.path.split(
                            exc_tb.tb_frame.f_code.co_filename)[1]
                        logger.warn(
                            "%s - %s - %s" %
                            (str(exc_type), str(fname), str(exc_tb.tb_lineno)))
                        logger.warn("Could not send %s token" %
                                    self.token_config[token]["symbol"])
                        continue

                reply_identifier = construct_authorperm(
                    c_comment["parent_author"], c_comment["parent_permlink"])
                if self.config["no_broadcast"]:
                    logger.info("%s" % reply_body)
                else:
                    try:
                        self.stm.post(
                            "",
                            reply_body,
                            author=self.token_config[token]["token_account"],
                            reply_identifier=reply_identifier)
                    except Exception as e:
                        exc_type, exc_obj, exc_tb = sys.exc_info()
                        fname = os.path.split(
                            exc_tb.tb_frame.f_code.co_filename)[1]
                        logger.warn(
                            "%s - %s - %s" %
                            (str(exc_type), str(fname), str(exc_tb.tb_lineno)))
                        logger.warn("Could not reply to post")
                        continue
                    if self.token_config[token]["usage_upvote_percentage"] > 0:
                        try:
                            c_comment.upvote(self.token_config[token]
                                             ["usage_upvote_percentage"],
                                             voter=self.token_config[token]
                                             ["token_account"])
                        except Exception as e:
                            exc_type, exc_obj, exc_tb = sys.exc_info()
                            fname = os.path.split(
                                exc_tb.tb_frame.f_code.co_filename)[1]
                            logger.warn("%s - %s - %s" %
                                        (str(exc_type), str(fname),
                                         str(exc_tb.tb_lineno)))
                            logger.warn("Could not upvote comment")

                time.sleep(4)
        return last_block_num
コード例 #8
0
ファイル: Check_for_voters-v1.py プロジェクト: idikuci/Herbie
        #    sleep(10)
        authorperm = post[0]
        author = post[1]
        voter = post[6]
        vote_weight = post[7]

        #    print(post)

        try:
            commentobj = Comment(authorperm, steem_instance=w)
        except:
            commentobj = []

#p    print(commentobj)
        if commentobj:
            if commentobj.is_main_post():
                print(" Is Main Post")
                WLS_URL = make_URL(authorperm)
                for poster in votesin:
                    if poster == author:
                        print("  Watching Author")
                        success = False
                        watchers = get_watcherslist(poster, 'votein')
                        success = store_watchers(watchers, WLS_URL, voter,
                                                 'votein', author, vote_weight)
                        break

                for Pvoter in votesout:
                    if Pvoter == voter:
                        print("   Watching voter")
                        success = False
コード例 #9
0
    def run(self, start_block):
        self.stm.wallet.unlock(self.config["wallet_password"])  
        self.blockchain = Blockchain(mode='head', steem_instance=self.stm)
        stop_block = self.blockchain.get_current_block_num()

        if start_block is not None:
            last_block_num = start_block - 1
        self.log_data["start_block_num"] = start_block
        for op in self.blockchain.stream(start=start_block, stop=stop_block, opNames=["comment"],  max_batch_size=50):
            self.log_data = print_block_log(self.log_data, op, self.config["print_log_at_block"])
            last_block_num = op["block_num"]
            
            if op["type"] == "comment":
                token = None
                
                for key in self.token_config:
                    if op["body"].find(self.token_config[key]["comment_command"]) >= 0:
                        token = key
                if token is None:
                    continue
                if op["author"] == self.token_config[token]["scot_account"]:
                    continue

                try:
                    c_comment = Comment(op, steem_instance=self.stm)
                    c_comment.refresh()
                except:
                    logger.warn("Could not read %s/%s" % (op["author"], op["permlink"]))
                    continue
                if c_comment.is_main_post():
                    continue
                if abs((c_comment["created"] - op['timestamp']).total_seconds()) > 9.0:
                    logger.warn("Skip %s, as edited" % c_comment["authorperm"])
                    continue
                already_replied = False
                for r in c_comment.get_all_replies():
                    if r["author"] == self.token_config[token]["scot_account"]:
                        already_replied = True
                if already_replied:
                    continue
                # Load scot token balance
                scot_wallet = Wallet(self.token_config[token]["scot_account"], steem_instance=self.stm)
                scot_token = scot_wallet.get_token(self.token_config[token]["scot_token"])

                # parse amount when user_can_specify_amount is true
                amount = self.token_config[token]["maximum_amount"]
                if self.token_config[token]["user_can_specify_amount"]:
                    start_index = c_comment["body"].find(self.token_config[token]["comment_command"])
                    stop_index = c_comment["body"][start_index:].find("\n")
                    if stop_index >= 0:
                        command = c_comment["body"][start_index + 1:start_index + stop_index]
                    else:
                        command = c_comment["body"][start_index + 1:]
                        
                    command_args = command.replace('  ', ' ').split(" ")[1:]          
                    
                    if len(command_args) > 0:
                        try:
                            amount = float(command_args[0])
                        except Exception as e:
                            exc_type, exc_obj, exc_tb = sys.exc_info()
                            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
                            logger.warn("%s - %s - %s" % (str(exc_type), str(fname), str(exc_tb.tb_lineno)))                        
                            logger.info("Could not parse amount")
                
                if not self.config["no_broadcast"] and self.stm.wallet.locked():
                    self.stm.wallet.unlock(self.config["wallet_password"])                
                
                self.log_data["new_commands"] += 1
                wallet = Wallet(c_comment["author"], steem_instance=self.stm)
                token_in_wallet = wallet.get_token(self.token_config[token]["scot_token"])
                if token_in_wallet is None or float(token_in_wallet["balance"]) < self.token_config[token]["min_staked_token"]:
                    reply_body = self.token_config[token]["fail_reply_body"]
                elif c_comment["parent_author"] == c_comment["author"]:
                    reply_body = "You cannot sent token to yourself."
                elif float(scot_token["balance"]) < amount:
                    reply_body = self.token_config[token]["no_token_left_body"]
                else:
                    if "%s" in self.token_config[token]["sucess_reply_body"]:
                        reply_body = self.token_config[token]["sucess_reply_body"] % c_comment["parent_author"]
                    else:
                        reply_body = self.token_config[token]["sucess_reply_body"]
                    if "%s" in self.token_config[token]["token_memo"]:
                        token_memo = self.token_config[token]["token_memo"] % c_comment["author"]
                    else:
                        token_memo = self.token_config[token]["token_memo"]
                        
                    sendwallet = Wallet(self.token_config[token]["scot_account"], steem_instance=self.stm)

                    try:
                        logger.info("Sending %.2f %s to %s" % (amount, self.token_config[token]["scot_token"], c_comment["parent_author"]))
                        sendwallet.transfer(c_comment["parent_author"], amount, self.token_config[token]["scot_token"], token_memo)
                    except Exception as e:
                        exc_type, exc_obj, exc_tb = sys.exc_info()
                        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
                        logger.warn("%s - %s - %s" % (str(exc_type), str(fname), str(exc_tb.tb_lineno)))                     
                        logger.warn("Could not send %s token" % self.token_config[token]["scot_token"])
                        continue
                        
                reply_identifier = construct_authorperm(c_comment["parent_author"], c_comment["parent_permlink"])
                if self.config["no_broadcast"]:
                    logger.info("%s" % reply_body)
                else:
                    try:
                        self.stm.post("", reply_body, author=self.token_config[token]["scot_account"], reply_identifier=reply_identifier)
                    except Exception as e:
                        exc_type, exc_obj, exc_tb = sys.exc_info()
                        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
                        logger.warn("%s - %s - %s" % (str(exc_type), str(fname), str(exc_tb.tb_lineno)))                     
                        logger.warn("Could not reply to post")
                        continue
                    if self.token_config[token]["usage_upvote_percentage"] > 0:
                        try:
                            c_comment.upvote(self.token_config[token]["usage_upvote_percentage"], voter=self.token_config[token]["scot_account"])
                        except Exception as e:
                            exc_type, exc_obj, exc_tb = sys.exc_info()
                            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
                            logger.warn("%s - %s - %s" % (str(exc_type), str(fname), str(exc_tb.tb_lineno)))                        
                            logger.warn("Could not upvote comment")
                            
                time.sleep(4)
        return last_block_num
コード例 #10
0
        voter = c_comment["author"]

        voter_acc = Account(voter, steem_instance=stm)
        posting_auth = False
        for a in voter_acc["posting"]["account_auths"]:
            if a[0] == "rewarding":
                posting_auth = True

        already_voted = False
        for v in c_comment.get_votes():
            if v["voter"] == rewarding_account:
                already_voted = True
        if already_voted:
            continue

        if c_comment.is_main_post():
            c = c_comment
        else:
            c = Comment(construct_authorperm(c_comment["parent_author"],
                                             c_comment["parent_permlink"]),
                        steem_instance=stm)
        if not (c.is_pending() and valid_age(c)):
            body = "The reward of this comment goes 100 %% to the author %s. This is done by setting the beneficiaries of this comment to 100 %%.\n\n" % (
                c["author"])
            comment_beneficiaries = [{"account": c["author"], "weight": 10000}]
            permlink = derive_permlink("rewarding %s" % c["author"],
                                       c_comment["permlink"])
            stm.post("rewarding %s" % c["author"],
                     body,
                     author=rewarding_account,
                     permlink=permlink,
コード例 #11
0
for com_json in BLOCKCHAIN_INSTANCE.stream(opNames=['comment'],
                                           start=start_block_id,
                                           stop=stop_block_id):
    watched_count += 1
    logger.info(
        f"watched count:  {watched_count}, kept: {len(KEEPED)} ,  cur: @{com_json.get('author')}/{com_json.get('permlink')}"
    )
    try:
        comment = Comment('@{}/{}'.format(com_json.get('author'),
                                          com_json.get('permlink')),
                          blockchain_instance=HIVE_INSTANCE)
    except ContentDoesNotExistsException as e:
        logger.warning(e)
        continue

    if not only_main_post and not comment.is_main_post():
        print('not main post')
        continue

    # print(com_json)
    if com_json.get('json_metadata') != '':
        metadata = json.loads(com_json.get('json_metadata'))

    for b_tag in blacklist_tags:
        if b_tag in metadata.get('tags', []):
            continue

    lock = False
    for a_tag in allow_tags:
        if a_tag in metadata.get('tags', []):
            lock = True
コード例 #12
0
                        p = float(curation_rewards_SBD["active_votes"][vote["voter"]]) / vote_SBD * 100
                        if p > best_performance:
                            best_performance = p
                            best_vote_delay_min = ((vote["time"]) - c["created"]).total_seconds() / 60
                    if voter_rshares > 0:
                        rshares_before += voter_rshares
                vote_log["is_pending"] = False
                

            if acc_data is not None and acc_data["optimize_vote_delay"] and abs(vote_delay_diff) < 1.0 and not vote_log["trail_vote"]:

                optimize_threshold = 1 + (acc_data["optimize_threshold"] / 100)
                optimize_ma_length = acc_data["optimize_ma_length"]
                vote_not_optimized = vote_log["optimized_vote_delay_min"] is None
                age_min = (addTzInfo(datetime.utcnow()) - c["created"]).total_seconds() / 60 
                vote_rule = voteRulesTrx.get(vote_log["voter"], c["author"], c.is_main_post())
                if vote_rule is not None and not vote_rule["disable_optimization"] and age_min > maximum_vote_delay + 1 and vote_not_optimized:
                    vote_delay_min = vote_rule["vote_delay_min"]
                    old_vote_delay_min = vote_rule["vote_delay_min"]
                    vote_log["vote_delay_optimized"] = True
                    if best_performance > performance * optimize_threshold and vote_delay_min <= maximum_vote_delay + 0.1 and vote_delay_min >= minimum_vote_delay -0.1:
                        if optimize_ma_length > 1:
                            vote_delay_min = (vote_delay_min * (optimize_ma_length - 1) + best_vote_delay_min) / optimize_ma_length
                        else:
                            vote_delay_min = best_vote_delay_min
                        if vote_delay_min > maximum_vote_delay:
                            vote_delay_min = maximum_vote_delay
                        elif vote_delay_min < minimum_vote_delay:
                            vote_delay_min = minimum_vote_delay
                        vote_weight = vote_log["vote_weight"]
                        if acc_data["optimize_vote_delay_slope"] != 0 and vote_log["vote_weight"] > 0: