def handle_operation(self, op_type, op_value): if op_type != "comment": return if op_value.get("author") == self.account: return if 'espoem' in op_value.get("body"): p = Post(op_value) repliers = [r.get("author") for r in p.get_replies()] if self.account in repliers: logger.info("Already stated facts on this. Skipping.") return p.reply(self.get_random_fact(), author=self.account) logger.info("Replied to %s" % p.identifier) time.sleep(20)
def index(request): if request.method == 'POST': try: pk = [request.POST['pk']] steem = Steem(keys=pk[0], nodes=["https://api.steemit.com"]) postToComment = Post(request.POST['i'], steem) texto = request.POST['b'] cuenta = request.POST['a'] postToComment.reply(body=texto, author=cuenta) return HttpResponse('ok', content_type='text/plain') except: return HttpResponse('An error has occurred while posting the reply', content_type='text/plain') else: return HttpResponse('This is a POST request. To reply to a post, send the following parameters:\n' 'pk = private key\n' 'i = post identifier\n' 'b = reply body\n' 'a = account', content_type='text/plain')
def freePost(self, memo): memo = "https://" + memo post = Post(memo) # Check to see if memo is in the database if self.data.get(memo): #continue # send message saying that post has already been upvoted and send money back if # steemy got paid print("Already upvoted this post") else: self.data.set(memo, memo) # get a voting weight between 80 and 100 vote_weight = float(random.randint(+5, +9)) # Upvote the post post.commit.vote(post.identifier, vote_weight, account="steemybot") print("I ran") post.reply( "This post was upvoted by @steemybot, Send at least 0.01 STEEM or SBD " "and get an upvote. Join my discord server for free weighted upvoting for each post, just put the command !upvote before the web address of the post and you will get a free upvote within 2 mins." "<br><br>@steemybot our mission is to support high quality posts which will raise the value of the STEEM Blockchain.", "", "steemybot")
class Testcases(unittest.TestCase): def __init__(self, *args, **kwargs): super(Testcases, self).__init__(*args, **kwargs) self.post = Post(identifier, steem_instance=steem) def test_getOpeningPost(self): self.post._getOpeningPost() def test_reply(self): try: self.post.reply(body="foobar", title="", author=testaccount, meta=None) except InsufficientAuthorityError: pass except MissingKeyError: pass def test_upvote(self): try: self.post.upvote(voter=testaccount) except VotingInvalidOnArchivedPost: pass except InsufficientAuthorityError: pass except MissingKeyError: pass def test_downvote(self, weight=-100, voter=testaccount): try: self.post.downvote(voter=testaccount) except VotingInvalidOnArchivedPost: pass except InsufficientAuthorityError: pass except MissingKeyError: pass def test_edit(self): try: steem.edit(identifier, "Foobar") except InsufficientAuthorityError: pass except MissingKeyError: pass def test_post(self): try: steem.post("title", "body", meta={"foo": "bar"}, author=testaccount) except InsufficientAuthorityError: pass except MissingKeyError: pass def test_create_account(self): try: steem.create_account("xeroc-create", creator=testaccount, password="******", storekeys=False) except InsufficientAuthorityError: pass except MissingKeyError: pass def test_transfer(self): try: steem.transfer("fabian", 10, "STEEM", account=testaccount) except InsufficientAuthorityError: pass except MissingKeyError: pass def test_withdraw_vesting(self): try: steem.withdraw_vesting(10, account=testaccount) except InsufficientAuthorityError: pass except MissingKeyError: pass def test_transfer_to_vesting(self): try: steem.transfer_to_vesting(10, to=testaccount, account=testaccount) except InsufficientAuthorityError: pass except MissingKeyError: pass def test_get_replies(self): steem.get_replies(author=testaccount) def test_get_posts(self): steem.get_posts() def test_get_categories(self): steem.get_categories(sort="trending") def test_get_balances(self): steem.get_balances(testaccount) def test_getPost(self): self.assertEqual( Post("@xeroc/piston", steem_instance=steem).url, "/piston/@xeroc/piston") self.assertEqual( Post({ "author": "@xeroc", "permlink": "piston" }, steem_instance=steem).url, "/piston/@xeroc/piston")
count += 1 print "[%i] [%s] %s \n" % (count, tempo, url) for post_unit in post_stack: post_url = post_unit[0] post_timestamp = post_unit[1] if now >= post_timestamp: print "\nVotando no post %s" % post_url try: upvote = Post(post_url) upvote.upvote(weight=+5, voter=username) print "Enviando comentario no post..." upvote.reply( body= "Obrigado por postar! Esse comentário é o novo bot que dará upvote 5% para todos os posts que usam a tag #pt. [Ainda não votou em mim como witness? Clique aqui e dê o seu voto! É rápido!](https://app.steemconnect.com/sign/account-witness-vote?witness=tiagoferezin&approve=true)", title="", author=username) print "OK! Proximo...\n" post_stack.remove(post_unit) except: print "Esse post ja foi votado! Proximo...\n" post_stack.remove(post_unit) # Verifica se ha post diferente do anterior na query try: novo_post = s.get_discussions_by_created(query) novo_author = novo_post[0]["author"] novo_permlink = novo_post[0]["permlink"] novo_post = str("@" + novo_author + "/" + novo_permlink) except:
for reply in replies: if reply[1]['op'][1]['permlink'] in voted_permlink: pass reply_post = None # 대댓글 달기 try: reply_post = Post('@' + reply[1]['op'][1]['author'] + '/' + reply[1]['op'][1]['permlink']) except Exception as e: pass while (True): try: reply_post.reply(body="금손봇", author=acc_name) break except Exception as e: print(e) time.sleep(17) # 보팅하기 reply_post.upvote(10, acc_name) # 대댓글과 보팅한 댓글을 저장 voted_permlink.insert(0, reply[1]['op'][1]['permlink']) # 확인 기록(past_seq_num) 갱신 past_seq_num = recent_seq_num print(voted_permlink)
def handle_command(self, post): if post["author"] in self.config["blacklisted_users"]: logger.info("User on blacklist. (%s). Skipping", post["permlink"]) return # welcome command if re.findall("@%s\s!(welcome)" % self.account, post["body"]): main_post = Post(post.root_identifier, steemd_instance=self.steem) already_welcomed = self.get_table('welcome').find_one( author=main_post["author"]) if already_welcomed: logger.info("This user: %s already welcomed. Skipping" % main_post["author"]) return body = open(self.config["welcome_message"]).read() body = body.replace("$username", main_post["author"]) main_post.reply( body=body, author=self.account, ) if not main_post.is_main_post(): logger.info("Skipping. Not a main post.") return try: self.upvote(main_post) except Exception as e: logger.error(e) logger.info("Replied and upvoted user: %s", main_post["author"]) self.get_table('welcome').insert( dict( author=main_post["author"], permlink=main_post["permlink"], created_at=str(datetime.now()), )) if self.config["send_welcome_gift"] == "yes": self.commit.transfer(main_post["author"], self.config["welcome_gift"], memo=self.config["welcome_gift_message"], asset="SBD", account=self.account) # handle help commands help_commands = [ "creating_new_accounts", "bots", "curation_rewards", "downvote", "esteem", "security", "voting_power", "upvote", "tag_spam", "comment_spam", "wallet", "plagiarism", "posting" ] for command in help_commands: if re.findall("@%s\s!(%s)" % (self.account, command), post["body"]): message_path = "%s%s.md" % (self.config["help_commands_path"], command) main_post = Post(post.root_identifier, steemd_instance=self.steem) body = open(message_path).read() body = body.replace("$username", main_post["author"]) if not main_post.is_main_post(): logger.info("Skipping. Not a main post.") return main_post.reply( body=body, author=self.account, ) logger.info("Posted %s command reply." % command)
def listenForTrans(self): while True: transfers = self.lastTransaction() for transfer in transfers: if transfer["to"] != "steemybot": #This transfer does not belong to steemybot continue else: try: post = Post(transfer.get("memo")) amount = transfer.get("amount") memo = transfer.get("memo") sender = transfer.get("from") block = transfer.get("block") timestamp = transfer.get("timestamp") transId = transfer.get("trx_id") # Parse string for coin type coin = amount.split(" ") print(coin[1]) # Print the amount crypcoin = float(coin[0]) # Crypto value cryptoType = coin[1] # Crypto type if not memo: self.s.transfer( sender, float(amount), crypcoin, "Your memo is empty, here is your refund", "steemybot") if self.data.get(memo): print("Already upvoted this post") # Give a refund self.refund(sender, float(amount), crypcoin, memo, "steemybot") # post.reply( # "You received a refund from Steemy Bot, your post was already upvoted", # "", "steemybot") continue else: # coin = amount.split(" ") # print(coin[1]) # Print the amount # crypcoin = float(coin[0]) # Crypto value # cryptoType = coin[1] # Crypto type # Init and put memo into the database self.data.set(memo, memo) # Set transaction ID to prove that post was already upvoted self.data.set(transId, transId) post.reply( "This post was upvoted by @steemybot, Send at least 0.01 STEEM or SBD " "and get an upvote. Join my discord server discord.gg/MEBXbbY for free weighted upvoting for each post, just put the command !upvote before the web address of the post and you will get a free upvote within 2 mins." "<br><br>@steemybot our mission is to support high quality posts which will raise the value of the STEEM Blockchain.", "", "steemybot") if cryptoType == "STEEM": print("This is steem") # print("Amount Sent => " + crypcoin) # Calculate vote power based on amount sent if crypcoin < 1.000: # get a voting weight between 80 and 100 vote_weight = float( random.randint(+10, +40)) # Upvote the post post.commit.vote(post.identifier, vote_weight, account="steemybot") elif crypcoin >= 1.000 and crypcoin < 3.000: # get a voting weight between 80 and 100 vote_weight = float( random.randint(+40, +60)) # Upvote the post post.commit.vote(post.identifier, vote_weight, account="steemybot") elif crypcoin >= 3.000: # get a voting weight vote_weight = float( random.randint(+60, +95)) # Upvote the post post.commit.vote(post.identifier, vote_weight, account="steemybot") elif cryptoType == "SBD": print("This is SBD") # print("Amount Sent => " + crypcoin) # Calculate vote power based on amount sent if crypcoin < 1.000: # get a voting weight between 80 and 100 vote_weight = float( random.randint(+10, +40)) # Upvote the post post.commit.vote(post.identifier, vote_weight, account="steemybot") elif crypcoin >= 1.000 and crypcoin < 3.000: # get a voting weight between 80 and 100 vote_weight = float( random.randint(+40, +60)) # Upvote the post post.commit.vote(post.identifier, vote_weight, account="steemybot") elif crypcoin >= 3.000: # get a voting weight between 80 and 100 vote_weight = float( random.randint(+60, +95)) # Upvote the post post.commit.vote(post.identifier, vote_weight, account="steemybot") else: print("Nothing Happened, I wonder why") except ValueError as e: if 'Invalid identifier' == e.args[0]: print( "Invalid post link. Consider a refund. [%s]" % transfer.get("memo")) if self.data(transfer.get("trx_id")): continue else: amount = transfer.get("amount") coin = amount.split(" ") crypcoin = float(coin[0]) self.s.transfer( transfer.get("from"), crypcoin, coin[1], "Your memo is empty, here is your refund", "steemybot") print("Sleeping for 3 seconds") time.sleep(3)
#!/usr/bin/env python # -*- coding: utf-8 -*- from steem.post import Post from steem import Steem import sys ENCODING = sys.stdout.encoding if sys.stdout.encoding else 'utf-8' pk = [sys.argv[4]] steem = Steem(keys=pk[0], nodes=["https://api.steemit.com"]) postToComment = Post(sys.argv[1], steem) texto = sys.argv[2] cuenta = sys.argv[3] postToComment.reply(body=texto, author=cuenta) print("ok")