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 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))
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()
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)
def hundred_voter(): authors = [] with open(file=config['VOTER']['throw_votes_authors'], mode='r') as f: for line in f: line = line.replace('\n', '').replace('@', '') if len(line) >= 3: authors.append(line) random.shuffle(authors) log.info('Authors list: {}'.format(authors)) comment_body = '' if config.getboolean('VOTER', 'throw_write_comment'): with open(file=config['VOTER']['throw_comment_file'], mode='rb') as file: # loading comment text comment_body = file.read().decode('iso-8859-1') log.info('Loaded comment text.') for author in authors: try: for post in Account(author).history_reverse(stop=datetime.now() - timedelta(days=5), only_ops=['comment']): if post.get('parent_author') != '': continue a_perm = '{}/{}'.format(author, post.get('permlink')) log.info(a_perm) c = Comment(authorperm=a_perm) if a.name in c.get_votes(): log.info('Already voted.') continue log.info('Try vote on {}'.format(c.authorperm)) shared_steem_instance().wallet.unlock( config['GENERAL']['wallet_key']) c.vote(weight=config.getfloat('VOTER', 'throw_votes_pct'), account=a.name) if config.getboolean('VOTER', 'write_comment'): shared_steem_instance().post( title='', body=comment_body, author=config['GENERAL']['acc_name'], reply_identifier=c.authorperm, app='https://github.com/PortalMine/portalvotes') log.debug(shared_steem_instance().broadcast()) shared_steem_instance().wallet.lock() return True except AccountDoesNotExistsException: log.info('Account {} does not exist.'.format(author)) continue else: log.info('Nothing found to burn vote.') return False
def get_votes(s, author, permlink): acc = Comment("@{}/{}".format(author, permlink), steem_instance=s) upvotes = 0 downvotes = 0 for vote in acc.get_votes(): if vote.rshares > 0: upvotes = upvotes + 1 else: downvotes = downvotes + 1 return upvotes, downvotes
def vote_contribution(contribution): """Votes on the contribution with a scaled weight (dependent on the contribution's category and weight). """ if "@amosbastian" in contribution.url: return weight = (float(contribution.weight) / max(constants.MAX_VOTE.values()) * 100.0) / constants.SCALER contribution = Comment(contribution.url) voters = [vote.voter for vote in contribution.get_votes()] if "amosbastian" not in voters: contribution.vote(weight, "amosbastian")
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.steem.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) self.assertTrue(isinstance(c.get_votes(), list)) self.assertTrue(len(c.get_votes()) > 0) self.assertTrue(isinstance(c.get_votes()[0], Vote))
def voted_by_any(voters: typing.Collection, discussion: Comment) -> bool: """Check if a post (comment) was voted by any of selected accounts. :param voters: A collection of voters :type voters: typing.Collection :param discussion: Post or comment :type discussion: Comment :return: True if any of the accounts voted else False :rtype: bool """ votes = discussion.get_votes() for account in voters: if account not in votes: return False return True
def setUpClass(cls): stm = Hive(node=get_hive_nodes()) stm.config.refreshBackup() stm.set_default_nodes(["xyz"]) del stm cls.urls = get_hive_nodes() cls.bts = Hive(node=cls.urls, nobroadcast=True, num_retries=10) set_shared_steem_instance(cls.bts) acc = Account("fullnodeupdate", steem_instance=cls.bts) comment = Comment(acc.get_blog_entries(limit=5)[1], steem_instance=cls.bts) cls.authorperm = comment.authorperm votes = comment.get_votes(raw_data=True) last_vote = votes[-1] cls.authorpermvoter = comment['authorperm'] + '|' + last_vote["voter"]
def setUpClass(cls): cls.nodelist = NodeList() cls.nodelist.update_nodes(steem_instance=Steem( node=cls.nodelist.get_nodes(hive=True), num_retries=10)) stm = Steem(node=cls.nodelist.get_nodes(hive=True)) stm.config.refreshBackup() stm.set_default_nodes(["xyz"]) del stm cls.urls = cls.nodelist.get_nodes(hive=True) cls.bts = Steem(node=cls.urls, nobroadcast=True, num_retries=10) set_shared_steem_instance(cls.bts) acc = Account("fullnodeupdate", steem_instance=cls.bts) comment = Comment(acc.get_blog_entries(limit=20)[-1], steem_instance=cls.bts) cls.authorperm = comment.authorperm votes = comment.get_votes() last_vote = votes[-1] cls.authorpermvoter = comment['authorperm'] + '|' + last_vote["voter"]
def upvote_contribution(contribution): """Upvotes the contribution with a pre-calculated weight.""" try: post = Comment(contribution["url"]) except Exception: constants.DB.pending_contributions.remove({"url": contribution["url"]}) return voters = [vote.voter for vote in post.get_votes()] if "amosbastian" in voters or "utopian-io" in voters: constants.DB_UTEMPIAN.pending_contributions.update_one( contribution, {"$set": { "upvoted": True }}) return post.vote(contribution["weight"], "amosbastian") constants.LOGGER.info((f"Upvoting contribution {contribution['url']} " f"with weight {contribution['weight']}%")) time.sleep(3)
def upvote_comment(comment): """Upvotes the contribution's moderator's comment.""" try: points = constants.CATEGORY_POINTS[comment["category"]] except KeyError: points = constants.TASK_REQUEST category_weight = points_to_weight(points) weight = (category_weight / max(constants.MAX_VOTE.values()) * 100.0) / constants.SCALER comment = Comment(comment["url"]) voters = [vote.voter for vote in comment.get_votes()] if "amosbastian" in voters or "utopian-io" in voters: constants.DB.comments.update_one(comment, {"$set": {"upvoted": True}}) comment.vote(weight, "amosbastian") constants.LOGGER.info((f"Upvoting comment {comment['url']} " f"with weight {weight}%")) time.sleep(3)
def steemstem_vote_finder_full(user): nodes = NodeList().get_nodes() stm = Steem(node=nodes) set_shared_steem_instance(stm) steemstem_user = user acc = Account(steemstem_user) perm_link_set = set() for post in acc.history_reverse(only_ops=['comment']): if post['parent_author'] == '' and post[ 'author'] == steemstem_user and post[ 'permlink'] not in perm_link_set: perm_link_set.add(post['permlink']) p_link = post['author'] + '/' + post['permlink'] print(p_link) print(post['timestamp']) com_link = Comment( p_link, steem_instance=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' ])) if 'steemstem' in com_link.get_votes(): print('+') 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()
cnt += 1 try: c = Comment(authorperm, use_tags_api=True, steem_instance=stm) except: c = None stm.rpc.next() if c is None: print("Error getting %s" % authorperm) continue main_post = c.is_main_post() already_voted = False if c.time_elapsed() > timedelta(hours=156): continue voted_after = 300 for v in c.get_votes(raw_data=True): if v["voter"] in accounts: already_voted = True try: voted_after = (v["time"] - c["created"]).total_seconds() except: voted_after = 300 if already_voted: postTrx.update_voted(author, created, already_voted, voted_after) continue vote_delay_sec = 5 * 60 if member["upvote_delay"] is not None: vote_delay_sec = member["upvote_delay"] if c.time_elapsed() < timedelta(seconds=(vote_delay_sec - upvote_delay_correction)):
cnt += 1 try: c = Comment(authorperm, use_tags_api=True, steem_instance=stm) except: c = None stm.rpc.next() if c is None: print("Error getting %s" % authorperm) continue main_post = c.is_main_post() already_voted = False if c.time_elapsed() > timedelta(hours=156): continue voted_after = 300 for v in c.get_votes(): if v["voter"] in accounts: already_voted = True try: if "time" in v: voted_after = (v["time"] - c["created"]).total_seconds() elif "last_update" in v: voted_after = (v["last_update"] - c["created"]).total_seconds() else: voted_after = 300 except: voted_after = 300 if already_voted:
def run(self, start_block, stop_block): self.hive.wallet.unlock(self.config["wallet_password"]) self.blockchain = Blockchain(mode='head', blockchain_instance=self.hive) current_block = self.blockchain.get_current_block_num() if stop_block is None or stop_block > current_block: stop_block = current_block if start_block is None: start_block = current_block last_block_num = current_block - 1 else: 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"]): 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 cnt = 0 c_comment = None c_parent = None authorperm = construct_authorperm(op) use_tags_api = True while c_comment is None and cnt < 10: cnt += 1 try: c_comment = Comment(authorperm, use_tags_api=use_tags_api, blockchain_instance=self.hive) c_comment.refresh() except: if cnt > 5: use_tags_api = False nodelist = NodeList() nodelist.update_nodes() self.hive = Hive(node=nodelist.get_hive_nodes(), num_retries=5, call_num_retries=3, timeout=15) time.sleep(3) if cnt == 10 or c_comment is None: logger.warn("Could not read %s/%s" % (op["author"], op["permlink"])) continue if 'depth' in c_comment: if c_comment['depth'] == 0: continue else: if c_comment["parent_author"] == '': continue if abs((c_comment["created"] - op['timestamp']).total_seconds()) > 9.0: logger.warn("Skip %s, as edited" % c_comment["authorperm"]) continue already_voted = False if self.token_config[token]["upvote_token_receiver"]: parent_identifier = construct_authorperm( c_comment["parent_author"], c_comment["parent_permlink"]) c_parent = Comment(parent_identifier, blockchain_instance=self.hive) for v in c_parent.get_votes(raw_data=True): if self.token_config[token]["token_account"] == v[ "voter"]: already_voted = True else: for v in c_comment.get_votes(raw_data=True): if self.token_config[token]["token_account"] == v[ "voter"]: already_voted = True if already_voted: continue already_replied = None cnt = 0 if self.token_config[token]["usage_upvote_percentage"] == 0: while already_replied is None and cnt < 5: cnt += 1 try: already_replied = False for r in c_comment.get_all_replies(): if r["author"] == self.token_config[token][ "token_account"]: already_replied = True except: already_replied = None self.hive.rpc.next() if already_replied is None: 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"], blockchain_instance=self.hive) 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"], blockchain_instance=self.hive) 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.hive.wallet.locked( ): self.hive.wallet.unlock(self.config["wallet_password"]) self.log_data["new_commands"] += 1 wallet = Wallet(c_comment["author"], blockchain_instance=self.hive) token_in_wallet = wallet.get_token( self.token_config[token]["symbol"]) balance = 0 if token_in_wallet is not None: logger.info(token_in_wallet) if self.token_config[token]["count_only_staked_token"]: balance = 0 else: 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 logger.info("token to give for %s: %f" % (c_comment["author"], max_token_to_give)) 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 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"], blockchain_instance=self.hive) 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.hive.post( "", reply_body, author=self.token_config[token]["token_account"], reply_identifier=reply_identifier) if self.token_config[token][ "usage_upvote_percentage"] <= 0: time.sleep(5) self.hive.post( "", "Command accepted!", author=self.token_config[token] ["token_account"], reply_identifier=c_comment["authorperm"]) 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: time.sleep(5) upvote_percentge = self.token_config[token][ "usage_upvote_percentage"] if self.token_config[token]["scale_upvote_weight"]: upvote_percentge = upvote_percentge * amount / self.token_config[ token]["maximum_amount_per_comment"] print("Upvote with %.2f %%" % upvote_percentge) if self.token_config[token]["upvote_token_receiver"]: if c_parent is None: c_parent = Comment( parent_identifier, blockchain_instance=self.hive) try: c_parent.upvote(upvote_percentge, 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") else: try: c_comment.upvote(upvote_percentge, 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
if vote_sbd is not None and vote_sbd > 0: vote_weight = 0 c_comment = Comment(command["authorperm"], use_tags_api=True, steem_instance=stm) 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}]