def init(): global _json global _database global _mariadb_connection s = Steem() # add file handling in here in place of further functions - TODO TODAY! # default timestamp in lastpaid at start of the script datetime.min.isoformat() # also csv header creation is needed in HERE _database = MySQLdb.connect( host="localhost", user="******", passwd="password", db="NOVADB") # db username, db user pass, db name # steeming it up! try: _json = s.get_account_history('steemnova', -1, limit=300) # getting account history except: raise NameError( "init() faild at downloading history. \tData response:\n\t " + data)
if not author in upvote_receiver: upvote_receiver.append(author) #normal upvotes else: if (i["percent"] > 0): upvotes += 1 if not author in upvote_receiver: upvote_receiver.append(author) return self_upvotes, upvotes, len(upvote_receiver), downvotes history = s.get_account_history('blocktrades', index_from=1350000, limit=10000) for i in history: if (i[1]["op"][0] == "delegate_vesting_shares"): timestamp.append(i[1]["timestamp"]) names.append(i[1]["op"][1]["delegatee"]) SP = vests_to_sp(float(i[1]["op"][1]["vesting_shares"].split(" ")[0])) if (SP != None): amount.append(str(SP).replace(".", ",")) pricecal = (float(amount[x].replace(",", ".")) / 1841.635) * 885.15 price.append(str(pricecal).replace(".", ","))
from steem import Steem s = Steem() from steem.transactionbuilder import TransactionBuilder from steembase import operations import time, random, os rposts = s.get_account_history('makerhacks', -1, 10000) total = 0 for post in rposts: operation = post[1]['op'][0] if operation == "transfer": if post[1]['op'][1]['from'] == "makerhacks" and not post[1]['op'][1][ 'to'] == "themarkymark": print(post[1]['op'][1]['to'] + "\t\t\t" + str(post[1]['op'][1]['amount'])) total = total + float(post[1]['op'][1]['amount'].replace( ' SBD', '')) print("\n\n" + str(total) + " SBD \n\n\n")
from steem import Steem import sys account_name = sys.argv[1] s = Steem() latest_operation = s.get_account_history(account_name, index_from=-1, limit=0) total_operations = latest_operation[0][0] print('This user has {} operations on STEEM'.format(total_operations)) num_iteration = int(total_operations/1000) + 1 # Num of times we have to request get_account_history permlink_list = [] title_list = [] for i in range(1, num_iteration+1): # i = 1,2,3,...num_iteration _index_from = i*1000 history = s.get_account_history(account_name, index_from=_index_from, limit=1000) for operation in history: op = operation[1]['op'] # 取出大List if op[0] == 'comment': if op[1]['parent_author'] == '': _permlink = op[1]['permlink'] _title = op[1]['title'] if _permlink not in permlink_list: permlink_list.append(_permlink) title_list.append(_title) print('[Title] {}\n [Permlink] {}'.format(_title, _permlink))
report.write("| <audio src='http://142.93.27.131:8080/ipfs/"+r[0]+"'>[Direct Link](http://142.93.27.131:8080/ipfs/"+r[0]+")</audio> |") report.write("["+r[1]+"](https://dsound.audio/#!/@"+r[1]+") | ["+r[2]+"](https://dsound.audio/#!/@"+r[1]+"/"+r[3]+") | "+str(r[5])+" |\n") report.close if len(sys.argv) > 1 and sys.argv[1]: argument = sys.argv[1] if argument == "report": print("Report generating") report_generator("audio") elif argument == "check": print("Checking pins") check_pins("audio",sys.argv[2]) elif argument == "oggify": print("Oggifying stored content") oggify_and_share("audio") else: print(argument) else: helpie_cake = s.get_account_history('helpiecake', index_from=-1, limit = 10000) n = -1 while n < 10000: if 'author' in helpie_cake[n][1]['op'][1]: if 'parent_author' in helpie_cake[n][1]['op'][1]: author = helpie_cake[n][1]['op'][1]['author'] parent_author = helpie_cake[n][1]['op'][1]['parent_author'] if author == 'helpiecake': if parent_author !='helpiecake': permlink = helpie_cake[n][1]['op'][1]['parent_permlink'] scan_post(parent_author,permlink) n += 1
def retrieve(keyword=[], account="anarchyhasnogods",sent_to="randowhale", position=-1, recent = 1, step = 10000, minblock = -1, node="wss://steemd.privex.io", not_all_accounts = True, type_thing="transfer"): print(account, "account1") print(keyword) # minblock is blocks before current block # account is the account that sent the memo # sent-to is account that it was sent to # keyword is what it looks for in the json ["type","account"] would bring back memos with the type account # -1 position means the latest, anything else means a specific memo where the position is known # step means how many actions it grabs at once # notallaccounts is wether or not it looks at every account print(node) print("NODE") #node_connection = create_connection(node) s = Steem(node=node) print("FIRST CONNECTION DONE") memo_list = [] if position > -1: # This returns the memo based on a saved position print("position > -1") memo = get_memo(s.get_account_history(sent_to, position, 0),type_thing) return memo else: print("else") # If the first is 0, it checks the first one with the keyword or account #(or and depending on keyword and account) found = True memo_list = [] # This gets the total amount of items in the accounts history # This it to prevent errors related to going before the creation of the account if type_thing == "transfer": memo_thing = s.get_account_history(sent_to,-1,0) elif type_thing == "curation_reward": memo_thing = s.get_account_history(account,-1,0) size = memo_thing[0][0] print("SIZE") if minblock > 0: minblock = memo_thing[0][1]["block"] - minblock print(minblock) position = size #print("POSITIONS") if position < 0: position = step +1 if step > position: step = position - 1 while found: # print("WHILE FOUND") # Checks if it has enough memos (ignores if its set to get all memos with not_all_accounts) if (recent > 0 and len(memo_list) > 0) and not_all_accounts: if len(memo_list) >= recent: break # print("while found 2") if type_thing =="transfer": history = s.get_account_history(sent_to, position, step) memos = get_memo(history, type_thing) elif type_thing=="curation_reward": history = s.get_account_history(account,position,step) memos = get_memo(history, type_thing) has_min_block = False #print(len(memos),keyword) # print("while found 3") for i in range(len(memos)-1, -1, -1): # print(memos) # goes through memos one at a time, starting with latest if len(memo_list) >= recent and not_all_accounts: # ends if there are enough memos print("here") break # print("HAS keyword") has_keyword = False if type_thing == "transfer": # print("transfer") if memos[i][3] < minblock: has_min_block = True has_account = False if memos[i][1] == account: has_account = True if type_thing == "curation_reward": print("curation award") if memos[i][2] < minblock: has_min_block = True has_account = True if keyword != []: # checks if keyword is in the memo #print("HERE") try: new_memo = json.loads(str(memos[i][2])) # print(new_memo) for ii in keyword: # print(i) has_keyword = False if new_memo[ii[0]] == ii[1]: has_keyword = True if not has_keyword: break except Exception as e: pass else: # not having a keyword is not advisible for transfer memos has_keyword = True if has_keyword and has_account or type_thing == "curation_reward": memo_list.append(memos[i]) if has_min_block: break if position == step+1 or has_min_block or (recent <= len(memo_list) and not_all_accounts): # ends if it has gone through all the memos, reached the min block, or has too many memos # print("break") break elif position-step <= step: position = step+1 else: position -=step return memo_list
import requests import json import psycopg2 import os from steem import Steem ''' r = requests.get('https://webapi.steemdata.com/Operations?where={"type": "transfer", "to": "steemvisit"}') json = json.loads(r.text) for item in json["_items"]: amount = float(str(item["amount"]["amount"])) memo = item["memo"] ''' s = Steem() for i in s.get_account_history('steemvisit',index_from=-1,limit=1): memo = i[1]['op'][1]['memo'] amount = float(i[1]['op'][1]['amount'][:-3]) conn = psycopg2.connect((os.environ['DATABASE_URL']),sslmode='require') #conn = psycopg2.connect("dbname='my_database_development' user='******' host='127.0.0.1' password=''") cur = conn.cursor() cur.execute("""UPDATE users SET steem = u.steem + %s FROM transactions t INNER JOIN users u ON t.id = u.transactionid WHERE t.name =%s""",(amount,memo,)) cur.execute("""DELETE FROM transactions WHERE name LIKE %s""",(memo,)) cur.close() conn.commit() conn.close()
import sys import random from steem import Steem user = sys.argv[1] steem = Steem() history = steem.get_account_history(user, index_from=-1, limit=2000) list = [] for entry in history: if entry[1]['op'][0] == 'transfer' and entry[1]['op'][1]['from'] != user: list.append(entry[1]['op'][1]['from']) for winner in range(10): print(list[random.randint(0, len(list))])
def retrieve(keyword="", account="anarchyhasnogods",sent_to="randowhale", position=-1, keyword_and_account = False, recent = 1, step = 10000, minblock = -1, node="wss://steemd-int.steemit.com", remove_keyword = True): node_connection = create_connection(node) s = Steem(node=node_connection) memo_list = [] if position > -1: # This returns the memo based on a saved position return get_memo(s.get_account_history(sent_to, position, 1)) else: # If the first is 0, it checks the first one with the keyword or account #(or and depending on keyword and account) found = True memo_list = [] # This gets the total amount of items in the accounts history # This it to prevent errors related to going before the creation of the account size = s.get_account_history(sent_to,-1,0)[0][0] #print(size) position = size if position < 0: position = step +1 while found: # Checks if the if recent > 0 and len(memo_list) > 0: if len(memo_list) >= recent: break history = s.get_account_history(sent_to, position, step) memos = get_memo(history) has_min_block = False for i in range(len(memos)-1, -1, -1): if len(memo_list) >= recent: break has_keyword = False if memos[i][3] < minblock: has_min_block = True if keyword != "": memos[i][2].split(keyword) if type(memos[i][2]) == list: for seg in memos[i][2]: if seg != keyword and remove_keyword: memos[i][2] += seg has_keyword = True has_account = memos[i][1] == account #print(memos[i][1], account) if keyword_and_account: if has_keyword and has_account: memo_list.append(memos[i]) else: if has_account or has_keyword: #print("added") memo_list.append(memos[i]) if position == step+1 or has_min_block: break elif position-step <= step: position = step+1 else: position -=step return memo_list
def retrieve(keyword=[], account="anarchyhasnogods", sent_to="randowhale", position=-1, recent=1, step=10000, minblock=-1, node="wss://steemd.privex.io", not_all_accounts=True): # minblock is blocks before current block # account is the account that sent the memo # sent-to is account that it was sent to # keyword is what it looks for in the json ["type","account"] would bring back memos with the type account # -1 position means the latest, anything else means a specific memo where the position is known # step means how many actions it grabs at once # notallaccounts is wether or not it looks at every account node_connection = create_connection(node) s = Steem(node=node_connection) memo_list = [] if position > -1: # This returns the memo based on a saved position return get_memo(s.get_account_history(sent_to, position, 1)) else: # If the first is 0, it checks the first one with the keyword or account #(or and depending on keyword and account) found = True memo_list = [] # This gets the total amount of items in the accounts history # This it to prevent errors related to going before the creation of the account memo_thing = s.get_account_history(sent_to, -1, 0) size = memo_thing[0][0] if minblock > 0: minblock = memo_thing[0][1]["block"] - minblock position = size if position < 0: position = step + 1 if step > position: step = position - 1 while found: # Checks if the if (recent > 0 and len(memo_list) > 0) and not_all_accounts: if len(memo_list) >= recent: break history = s.get_account_history(sent_to, position, step) memos = get_memo(history) has_min_block = False #print(len(memos),keyword) for i in range(len(memos) - 1, -1, -1): # goes through memos one at a time, starting with latest if len(memo_list) >= recent and not_all_accounts: # ends if there are enough memos # print("here") break has_keyword = False if memos[i][3] < minblock: has_min_block = True has_account = False if memos[i][1] == account: has_account = True if keyword != []: # checks if keyword is in the memo #print("HERE") try: new_memo = json.loads(str(memos[i][2])) # print(new_memo) for ii in keyword: # print(i) has_keyword = False # print(new_memo) #print(new_memo[i[0]], "This") print(keyword, ii, new_memo) if new_memo[ii[0]] == ii[1]: print("MEMO KEYYYYYYYYYYYYYYYYYYYYYYYYY") has_keyword = True if not has_keyword: # print("this_pos") break #print("her") except Exception as e: #print(e) pass if has_keyword and has_account: # print("THIS", i) memo_list.append(memos[i]) # print(memo_list) #print("here") if position == step + 1 or has_min_block or ( recent <= len(memo_list) and not_all_accounts): # ends if it has gone through all the memos, reached the min block, or has too many memos # print("break") break elif position - step <= step: position = step + 1 else: position -= step #print(memo_list) print("HEREEE") print(memo_list) return memo_list
s.commit.vote(post["identifier"], weight, account=account_name) print("Casted vote({}%) on: {}.".format(weight, post["identifier"])) except Exception as error: print("Error : {}".format(error)) target_username = sys.argv[1] account_name = sys.argv[2] account_postkey = sys.argv[3] vote_weight = sys.argv[4] s = Steem("https://api.steemit.com", keys=[account_postkey]) target_post = {} history = s.get_account_history(target_username, index_from=-1, limit=1000) for operation in reversed(history): op = operation[1]['op'] if op[0] == 'comment': if op[1]['parent_author'] == '': _permlink = op[1]['permlink'] # Check if the Post has already been upvoted by my account if account_name in [ v["voter"] for v in s.get_active_votes(target_username, _permlink) ]: print("Already voted on this. Skipping... {}".format( op[1]['title'])) continue