RE: RE: ARCHON project - as it stands
You are viewing a single comment's thread from:

RE: ARCHON project - as it stands

Words
0
Reading
0 min
Listen
Play
2y
from beem import Steem
from beem.discussions import Query, Discussions_by_created, Comment_discussions_by_payout, Discussions_by_active, Discussions
from beem.nodelist import NodeList
from beem.account import Account
from hiveengine.tokenobject import Token
import json
import random
from beem.comment import Comment
import pymongo
from pymongo import MongoClient
from hiveengine.wallet import Wallet
import time
round_share = 0.005
payout_account = "ufm.pay"
ignored = ["gangstalking", "tipu", "beerlover", "hivebuzz", "ecency", "investinthefutur", "cheetah", "poshbot"]
beem_unlock_pass = ""
mongo_cluster = ""
community = "hive-179017"

def sh():
    nodelist = NodeList()
    nodelist.update_nodes()
    nodes = nodelist.get_nodes(hive=True)
    hive = Steem(node=nodes)
    q = Query(limit=55, tag=community)
    cluster = MongoClient(mongo_cluster)
    db = cluster["archon"]
    shc = db["shc_comm"]
    for h in Discussions_by_created(q):
        c = Comment(h, steem_instance=hive)
        comments = c.get_replies(raw_data=False)
        for comm in comments:
            comm_string = str(comm)
            comm_string = comm_string[9:-1]
            print(comm_string)
            peak_link = str("https://www.peakd.com/" + comm_string)
            c = Comment(comm, steem_instance=hive)
            if c.author in ignored:
                continue
            if c.is_pending() is not True:
                continue
            if c.is_comment() is False:
                continue
            check = shc.find_one({"_id": comm_string})
            if check is not None:
                continue
            print(peak_link)
            shc.insert_one({"_id": comm_string, "account": str(c.author), "paid": False, "payout": 0, "peak_link": peak_link})


def payouts():
    cluster = MongoClient(mongo_cluster)
    db = cluster["archon"]
    shc = db["shc_comm"]
    unpaid = shc.find({"paid": False})
    nodelist = NodeList()
    nodelist.update_nodes()
    nodes = nodelist.get_nodes(hive=True)
    hive = Steem(node=nodes)
    acc_table = {}
    total = 0
    for u in unpaid:
        print(u)
        try:
            acc_table[u["account"]] += 1
        except:
            acc_table[u["account"]] = 1
        total += 1
        shc.update_one({"_id": u["_id"]}, {"$set": {"paid": True}})
    print(acc_table)
    print(total)
    wallet = Wallet(payout_account, steem_instance=hive)
    a_bals = wallet.get_token("ARCHON")
    bal = a_bals["balance"]
    print(bal)
    round_cut = float(bal) * float(round_share)
    print(round_cut)
    for user in acc_table:
        per = float(acc_table[user]) / total
        share = float(per) * float(round_cut)
        hive.wallet.unlock(beem_unlock_pass)
        print(wallet.stake(share, "ARCHON", user))
        time.sleep(3)


sh()
payouts()

@taskmanager: from beem import | Ecency