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")
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')
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 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"])
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"])
def reply_message(parent_comment: Comment, message: str, account: str, retry: int = 3): """Replies to a comment with a specific message. :param parent_comment: Parent comment to reply to :type parent_comment: Comment :param message: Message content :type message: str :param account: Author of the reply :type account: str :param retry: Number of retries, defaults to 3 :param retry: int, optional """ while retry > 0: try: parent_comment.reply(body=message, author=account) except: time.sleep(3) retry -= 1 else: break
def meme_cortex(stm, account): memes = steemsql.query(q.memes_bidbotted()) found = False j = -1 i = 0 while (i < len(memes.index) and found == False): try: v = Vote('rick.c137', '@' + memes['author'][i] + '/' + memes['permlink'][i], steem_instance=stm) except: found = True j = i if j > -1: c = Comment('@' + memes['author'][j] + '/' + memes['permlink'][j]) comment_content = 'Look Morty, another bidbotted meme morty. Lets downvote it Morty. Morty look, I am AI Rick!!' c.reply(comment_content, title='Wubba Lubba Dub Dub', author=account, meta=None) c.downvote(voter=account) print('@' + memes['author'][j] + '/' + memes['permlink'][j])
def reply_message(parent_comment: Comment, message: str, account: str, retry: int = 3): """Replies to a comment with a specific message. :param parent_comment: Parent comment to reply to :type parent_comment: Comment :param message: Message content :type message: str :param account: Author of the reply :type account: str :param retry: Number of retries, defaults to 3 :param retry: int, optional """ while retry > 0: try: parent_comment.reply(body=message, author=account) except ValueError: logger.error("No Steem account provided. Can't reply on Steem.") return False except: time.sleep(3) retry -= 1 else: return True return False
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}]")
def votecall(): for b in balances: if len(blacklist) > 0 and b["account"] in blacklist: print("blacklisted user, skipping...") continue if float(b["balance"]) < 5: print("user under minimum balance") continue account = Account(b["account"]) for post in account.get_blog(limit=1): c = Comment(post, steem_instance=stm) if (c.time_elapsed().total_seconds() / 60 / 60 / 24) > max_post_age_days: print("Post is to old, skipping") time.sleep(1) continue if (c.time_elapsed().total_seconds() / 60) < min_post_age: print("Post is to new, skipping") time.sleep(1) continue tags_ok = True if len(blacklist_tags) > 0 and "tags" in c: for t in blacklist_tags: if t in c["tags"]: tags_ok = False if not tags_ok: print("skipping, as one tag is blacklisted") time.sleep(1) continue already_voted = False for v in c["active_votes"]: if v["voter"] == upvote_account: already_voted = True if already_voted: print("skipping, as already upvoted") continue upvote_weight = float(b["balance"]) / 20 if c["author"] != b["account"]: print("Skipping reblog") continue if upvote_weight > 100: upvote_weight = 100 print("upvote %s from %s with %.2f %%" % (c["permlink"], c["author"], upvote_weight)) c.upvote(weight=upvote_weight, voter=upvote_account) time.sleep(3) reply_body = "You have received a " + str( upvote_weight ) + "% upvote based on your balance of " + str( b["stake"]) + " TMPS!" c.reply(body=reply_body, author=upvote_account) print("sending comment") time.sleep(1) continue print("upvote %s from %s with %.2f %%" % (c["permlink"], c["author"], upvote_weight)) c.upvote(weight=upvote_weight, voter=upvote_account) time.sleep(3) reply_body = "You have received a " + str( upvote_weight) + "% upvote based on your balance of " + str( b["balance"]) + " TMPS!" c.reply(body=reply_body, author=upvote_account) print("sending comment") time.sleep(1) print("Process Complete!") time.sleep(5)
if False: reply_message = upvote_comment_without_check(c, pending_vote["voter"], vote_weight) if reply_message is not None: vote_count += 1 if pending_vote["leave_comment"]: try: if settings is None: settings = accountsTrx.get(pending_vote["voter"]) if settings is not None and "upvote_comment" in settings and settings["upvote_comment"] is not None: json_metadata = {'app': 'rewarding/%s' % (rewarding_version)} reply_body = settings["upvote_comment"] reply_body = reply_body.replace("{{name}}", "@%s" % c["author"] ).replace("{{voter}}", "@%s" % pending_vote["voter"]) c.reply(reply_body, author=pending_vote["voter"], meta=json_metadata) except: print("Could not leave comment!") voteLogTrx.add({"authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "author": c["author"], "timestamp": datetime.utcnow(), "vote_weight": vote_weight, "vote_delay_min": pending_vote["vote_delay_min"], "voted_after_min": age_min, "vp": vp, "vote_when_vp_reached": pending_vote["vote_when_vp_reached"], "trail_vote": pending_vote["trail_vote"], "main_post": pending_vote["main_post"], "voter_to_follow": pending_vote["voter_to_follow"]}) expiration = formatTimeString(reply_message["expiration"]).replace(tzinfo=None) delete_pending_votes.append({"authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "vote_when_vp_reached": pending_vote["vote_when_vp_reached"]}) else: expiration = datetime.utcnow() broadcastVoteTrx.add({"authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "weight": vote_weight, "vote_delay_min": pending_vote["vote_delay_min"], "min_vp": pending_vote["min_vp"],
"main_post": pending_vote["main_post"]}) delete_pending_votes.append({"authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "vote_when_vp_reached": pending_vote["vote_when_vp_reached"]}) continue # sucess = upvote_comment(c, voter_acc["name"], vote_weight) reply_message = upvote_comment_without_check(c, voter_acc["name"], vote_weight) if reply_message is not None: vote_count += 1 if pending_vote["leave_comment"]: try: if settings is None: settings = accountsTrx.get(voter_acc["name"]) if settings is not None and "upvote_comment" in settings and settings["upvote_comment"] is not None: json_metadata = {'app': 'rewarding/%s' % (rewarding_version)} reply_body = settings["upvote_comment"] reply_body = reply_body.replace("{{name}}", "@%s" % c["author"] ).replace("{{voter}}", "@%s" % voter_acc["name"]) c.reply(reply_body, author=voter_acc["name"], meta=json_metadata) except: print("Could not leave comment!") voteLogTrx.add({"authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "author": c["author"], "timestamp": datetime.utcnow(), "vote_weight": vote_weight, "vote_delay_min": pending_vote["vote_delay_min"], "voted_after_min": age_min, "vp": voter_acc.vp, "vote_when_vp_reached": pending_vote["vote_when_vp_reached"], "trail_vote": pending_vote["trail_vote"], "main_post": pending_vote["main_post"], "voter_to_follow": pending_vote["voter_to_follow"]}) broadcastVoteTrx.add({"expiration": formatTimeString(reply_message["expiration"]).replace(tzinfo=None), "authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "weight": vote_weight}) delete_pending_votes.append({"authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "vote_when_vp_reached": pending_vote["vote_when_vp_reached"]}) continue else: broadcastVoteTrx.add({"authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "weight": vote_weight, "valid": True})
reply_body += "* your next SBI upvote is predicted to be %.3f $\n" % ( stm.rshares_to_sbd( member_data[ops["author"]]["balance_rshares"] * 0.2)) else: reply_body += "* you need to wait until your upvote value (current value: %.3f $) is above %.3f $\n" % ( stm.rshares_to_sbd( member_data[ops["author"]]["balance_rshares"] * 0.2), stm.rshares_to_sbd(minimum_vote_threshold * 2)) account_name = account_list[random.randint( 0, len(account_list) - 1)] if len(c.permlink) < 255: c.reply(reply_body, author=account_name) time.sleep(4) already_voted = False for v in c["active_votes"]: if v["voter"] in accounts: already_voted = True dt_created = c["created"] dt_created = dt_created.replace(tzinfo=None) skip = False for tag in c["tags"]: if tag.lower() in ["nsfw", "sbi-skip"]: skip = True
24) > max_post_age_days: print("Post is to old, skipping") continue tags_ok = True if len(blacklist_tags) > 0 and "tags" in c: for t in blacklist_tags: if t in c["tags"]: tags_ok = False if not tags_ok: print("skipping, as one tag is blacklisted") continue already_voted = False for v in c["active_votes"]: if v["voter"] == upvote_account: already_voted = True if already_voted: print("skipping, as already upvoted") continue upvote_weight = float(h["quantity"]) * token_weight_factor if upvote_weight > 100: upvote_weight = 100 print("upvote %s from %s with %.2f %%" % (c["permlink"], c["author"], upvote_weight)) print(c.upvote(weight=upvote_weight, voter=upvote_account)) if len(reply_comment) > 0: time.sleep(4) print(c.reply(reply_comment, author=upvote_account)) time.sleep(60)
"created": datetime.utcnow(), "min_vp": 0, "vote_when_vp_reached": False, "vp_reached_order": 1, "max_net_votes": -1, "max_pending_payout": -1, "exclude_declined_payout": False, "max_votes_per_day": -1, "max_votes_per_week": -1, "vp_scaler": 0, "leave_comment": False }) elif not posting_auth: c_comment.reply( "Please give rewarding the posting authory for letting it upvote on your command. https://app.steemconnect.com/authorize/@rewarding", author=rewarding_account) confStorage.update({"last_command": last_command}) print("command parse script run %.2f s" % (time.time() - start_prep_time))
def comment_on_post(url, comment_content, comment_title, comment_author): c = Comment(url) c.reply(comment_content, title=comment_title, author = comment_author, meta=None)