Beispiel #1
0
     cnt2 += 1
 try:
     c = Comment(authorperm, steem_instance=stm)
 except:
     continue
 cnt3 = 0
 for vote in c["active_votes"]:
     cnt3 += 1
     if int(vote["rshares"]) == 0:
         continue
     if (addTzInfo(datetime.utcnow()) - (vote["time"])
         ).total_seconds() / 60 / 60 / 24 <= 7:
         continue
     if vote["voter"] not in member_data:
         continue
     if authorperm in comments_transfer and stm.rshares_to_sbd(
             int(vote["rshares"])) >= 0.05:
         try:
             if cnt3 % 10 == 0:
                 print("%d/%d votes" %
                       (cnt3, len(c["active_votes"])))
             block_num = b.get_estimated_block_num(
                 vote["time"])
             current_block_num = b.get_current_block_num()
             transaction = None
             block_search_list = [
                 0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5
             ]
             block_cnt = 0
             while transaction is None and block_cnt < len(
                     block_search_list):
                 if block_num + block_search_list[
 def outgoing_from_account(self):
     nodes = NodeList().get_nodes()
     stm = Steem(node=nodes)
     set_shared_steem_instance(stm)
     #list to store dictionary variables
     self.vote_list = []
     account = (self.account or input("Downvoter User Account? "))
     try:
         downvoter_account = Account(account)
     except AccountDoesNotExistsException:
         print(
             'The specified account does not exist on the Steem blockchain.'
         )
         sys.exit(1)
     #prompts to be used for datetime variable in format.
     if (self.stop_date == None):
         #input option to enable input of self.start_date
         stop_option = input("Would you like to specify stop date? y/n ")
         if (stop_option == 'y'):
             self.stop_date = prompt_start_stop_time()
         else:
             self.stop_date = None
     if (self.start_date == None):
         #input option to enable input of self.start_date
         start_option = input("Would you like to specify start date? y/n ")
         #start date prompts
         if (start_option == 'y'):
             self.start_date = prompt_start_stop_time()
         else:
             self.start_date = None
     try:
         if type(self.start_date
                 ) is not datetime.datetime and self.start_date != None:
             raise TypeError("Improper start_date format!")
     except TypeError as e:
         print(e)
         sys.exit(1)
     try:
         if type(self.stop_date
                 ) is not datetime.datetime and self.stop_date != None:
             raise TypeError("Improper stop_date format!")
     except TypeError as e:
         print(e)
         sys.exit(1)
     start_v_ops = downvoter_account.estimate_virtual_op_num(
         self.start_date or datetime.datetime.utcnow())
     stop_v_ops = downvoter_account.estimate_virtual_op_num(
         self.stop_date or datetime.datetime(1969, 12, 31, 23, 59, 59))
     start_stop_op_dif = start_v_ops - stop_v_ops
     if (start_stop_op_dif > 10000):
         print(
             "Operations Scope exceeds Get_Account_History limit. Splitting into multiple calls with index."
         )
         hist_index = 10000
         while hist_index <= start_stop_op_dif:
             for vote in (downvoter_account.get_account_history(
                     hist_index,
                     10000,
                     start=self.start_date,
                     stop=self.stop_date,
                     only_ops=['vote'])):
                 if vote['voter'] == downvoter_account.name and vote[
                         'weight'] < 0:
                     try:
                         downvote = downvoter_account.get_vote(
                             vote['author'] + '/' + vote['permlink'])
                         downvoted_post = Comment(vote['author'] + '/' +
                                                  vote['permlink'])
                     except ContentDoesNotExistsException:
                         print(vote['permlink'] +
                               "Does Not Exist! Skipping.")
                         continue
                     pending_payout_value = downvoted_post[
                         'pending_payout_value']
                     downvote_sbd_amount = round(
                         stm.rshares_to_sbd(downvote['rshares']), 3)
                     link = '[Comment](https://steemit.com/@' + downvoted_post.identifier + ')'
                     report_dict = {
                         'Downvoter': '@' + vote['voter'],
                         'Comment': link,
                         'SBD amount': str(downvote_sbd_amount),
                         'rshares': downvote['rshares'],
                         'Remaining Rewards': str(pending_payout_value),
                         'Timestamp': vote['timestamp'],
                         'ID': vote['_id']
                     }
                     self.vote_list.append(report_dict)
             hist_index += 1000
     else:
         for vote in (downvoter_account.get_account_history(
                 -1,
                 10000,
                 start=self.start_date,
                 stop=self.stop_date,
                 only_ops=['vote'])):
             if vote['voter'] == downvoter_account.name and vote[
                     'weight'] < 0:
                 try:
                     downvote = downvoter_account.get_vote(vote['author'] +
                                                           '/' +
                                                           vote['permlink'])
                     downvoted_post = Comment(vote['author'] + '/' +
                                              vote['permlink'])
                 except ContentDoesNotExistsException:
                     print(vote['permlink'] + "Does Not Exist! Skipping.")
                     continue
                 pending_payout_value = downvoted_post[
                     'pending_payout_value']
                 downvote_sbd_amount = round(
                     stm.rshares_to_sbd(downvote['rshares']), 3)
                 link = '[Comment](https://steemit.com/@' + downvoted_post.identifier + ')'
                 report_dict = {
                     'Downvoter': '@' + vote['voter'],
                     'Comment': link,
                     'SBD amount': str(downvote_sbd_amount),
                     'rshares': downvote['rshares'],
                     'Remaining Rewards': str(pending_payout_value),
                     'Timestamp': vote['timestamp'],
                     'ID': vote['_id']
                 }
                 self.vote_list.append(report_dict)
     #remove duplicates
     self.vote_list = [
         dict(t) for t in {tuple(d.items())
                           for d in self.vote_list}
     ]
     export_csv('outgoing_downvote_report', self.vote_list)
     return self.vote_list
            member_data[ops["author"]]["last_comment"] = c["created"]
            status_command = c.body.find("!sbi status")
            if status_command > -1 and abs(
                (ops["timestamp"] - c["created"]).total_seconds()) <= 10:

                rshares_denom = member_data[
                    ops["author"]]["rewarded_rshares"] + member_data[
                        ops["author"]]["balance_rshares"]

                reply_body = "Hi @%s!\n\n" % ops["author"]
                reply_body += "* you have %d units and %d bonus units\n" % (
                    member_data[ops["author"]]["shares"],
                    member_data[ops["author"]]["bonus_shares"])
                reply_body += "* your rshares balance is %d or %.3f $\n" % (
                    member_data[ops["author"]]["balance_rshares"],
                    stm.rshares_to_sbd(
                        member_data[ops["author"]]["balance_rshares"]))

                if member_data[ops["author"]]["comment_upvote"] == 0:
                    rshares = member_data[ops["author"]][
                        "balance_rshares"] / comment_vote_divider
                    if rshares > minimum_vote_threshold:
                        reply_body += "* your next SBI upvote is predicted to be %.3f $\n" % (
                            stm.rshares_to_sbd(rshares))
                    else:
                        reply_body += "* you need to wait until your upvote value (current value: %.3f $) is above %.3f $\n" % (
                            stm.rshares_to_sbd(rshares),
                            stm.rshares_to_sbd(minimum_vote_threshold))
                else:
                    # rshares =  member_data[ops["author"]]["balance_rshares"] / (comment_vote_divider ** 2)
                    # reply_body += "* as you did not wrote a post within the last 7 days, your comments will be upvoted.\n"
                    if rshares > minimum_vote_threshold * 20:
Beispiel #4
0
class Beem:
    def __init__(self, bot, settings):
        self.bot = bot
        self.settings = settings
        self.stm = Steem()

    def _is_admin(self, member, channel, guild):
        # Check for admin/bot-admin
        isAdmin = member.permissions_in(channel).administrator
        if not isAdmin:
            checkAdmin = self.settings.getServerStat(guild, "AdminArray")
            for role in member.roles:
                for aRole in checkAdmin:
                    # Get the role that corresponds to the id
                    if str(aRole['ID']) == str(role.id):
                        isAdmin = True
        return isAdmin

    @commands.command(pass_context=True)
    async def account(self, ctx, *, account: str = None):
        """Retuns information about an account"""
        if account is None:
            regAccount = self.settings.getUserStat(ctx.message.author,
                                                   ctx.message.guild,
                                                   "SteemAccount")
            if regAccount is not None and regAccount != "":
                account = regAccount
            else:
                account = ctx.message.author
                account = str(account).split('#')[0]
        a = Account(account, steem_instance=self.stm)
        response = a.print_info(return_str=True)
        await ctx.channel.send("```" + response + "```")

    @commands.command(pass_context=True)
    async def register(self, ctx, *, account: str = None):
        """Register your steemit name"""
        if account is None:
            await ctx.channel.send("I do nothing!")
            return
        try:
            Account(account, steem_instance=self.stm)
        except:
            await ctx.channel.send("Could not register %s!" % account)
            return
        self.settings.setUserStat(ctx.message.author, ctx.message.guild,
                                  "SteemAccount", account)
        await ctx.channel.send("Registered!")

    @commands.command(pass_context=True)
    async def updatenodes(self, ctx):
        """Retuns information about the current node"""
        t = PrettyTable(["node", "Version", "score"])
        t.align = "l"
        nodelist = NodeList()
        nodelist.update_nodes(steem_instance=self.stm)
        nodes = nodelist.get_nodes()
        sorted_nodes = sorted(nodelist,
                              key=lambda node: node["score"],
                              reverse=True)
        for node in sorted_nodes:
            if node["url"] in nodes:
                score = float("{0:.1f}".format(node["score"]))
                t.add_row([node["url"], node["version"], score])
        response = t.get_string()
        self.stm.set_default_nodes(nodes)

        await ctx.channel.send("```" + response + "```")

    @commands.command(pass_context=True)
    async def pricehistory(self, ctx, width: int = 75):
        """Retuns information about the current steem price"""

        feed_history = self.stm.get_feed_history()
        current_base = Amount(feed_history['current_median_history']["base"],
                              steem_instance=self.stm)
        current_quote = Amount(feed_history['current_median_history']["quote"],
                               steem_instance=self.stm)
        price_history = feed_history["price_history"]
        price = []
        for h in price_history:
            base = Amount(h["base"], steem_instance=self.stm)
            quote = Amount(h["quote"], steem_instance=self.stm)
            price.append(base.amount / quote.amount)
        # charset = u'ascii'
        charset = u'utf8'
        chart = AsciiChart(height=10,
                           width=width,
                           offset=4,
                           placeholder='{:6.2f} $',
                           charset=charset)
        response = "Price history for STEEM (median price %4.2f $)\n" % (
            float(current_base) / float(current_quote))

        chart.adapt_on_series(price)
        chart.new_chart()
        chart.add_axis()
        chart._draw_h_line(chart._map_y(
            float(current_base) / float(current_quote)),
                           1,
                           int(chart.n / chart.skip),
                           line=chart.char_set["curve_hl_dot"])
        chart.add_curve(price)
        response += str(chart)
        await ctx.channel.send("```" + response + "```")

    @commands.command(pass_context=True)
    async def curation(self, ctx, *, authorperm: str):

        show_all_voter = False

        all_posts = False
        t = PrettyTable([
            "Voter", "Voting time", "Vote", "Early vote loss", "Curation",
            "Performance"
        ])
        t.align = "l"
        index = 0

        index += 1
        comment = Comment(authorperm, steem_instance=self.stm)
        payout = None
        curation_rewards_SBD = comment.get_curation_rewards(
            pending_payout_SBD=True, pending_payout_value=payout)
        curation_rewards_SP = comment.get_curation_rewards(
            pending_payout_SBD=False, pending_payout_value=payout)
        rows = []
        sum_curation = [0, 0, 0, 0]
        max_curation = [0, 0, 0, 0, 0, 0]
        highest_vote = [0, 0, 0, 0, 0, 0]
        for vote in comment["active_votes"]:
            vote_SBD = self.stm.rshares_to_sbd(int(vote["rshares"]))
            curation_SBD = curation_rewards_SBD["active_votes"][vote["voter"]]
            curation_SP = curation_rewards_SP["active_votes"][vote["voter"]]
            if vote_SBD > 0:
                penalty = (
                    (comment.get_curation_penalty(vote_time=vote["time"])) *
                    vote_SBD)
                performance = (float(curation_SBD) / vote_SBD * 100)
            else:
                performance = 0
                penalty = 0
            vote_befor_min = ((
                (vote["time"]) - comment["created"]).total_seconds() / 60)
            sum_curation[0] += vote_SBD
            sum_curation[1] += penalty
            sum_curation[2] += float(curation_SP)
            sum_curation[3] += float(curation_SBD)
            row = [
                vote["voter"], vote_befor_min, vote_SBD, penalty,
                float(curation_SP), performance
            ]
            if row[-1] > max_curation[-1]:
                max_curation = row
            if row[2] > highest_vote[2]:
                highest_vote = row
            rows.append(row)
        sortedList = sorted(rows, key=lambda row: (row[1]), reverse=False)
        new_row = []
        new_row2 = []
        voter = []
        voter2 = []

        voter = [""]
        voter2 = [""]
        for row in sortedList:
            if show_all_voter:
                if not all_posts:
                    voter = [row[0]]
                if all_posts:
                    new_row[0] = "%d. %s" % (index, comment.author)
                t.add_row(new_row + voter + [
                    "%.1f min" % row[1],
                    "%.3f SBD" % float(row[2]),
                    "%.3f SBD" % float(row[3]),
                    "%.3f SP" % (row[4]),
                    "%.1f %%" % (row[5])
                ])

                new_row = new_row2
        t.add_row(new_row2 + voter2 + ["", "", "", "", ""])
        if sum_curation[0] > 0:
            curation_sum_percentage = sum_curation[3] / sum_curation[0] * 100
        else:
            curation_sum_percentage = 0
        sum_line = new_row2 + voter2
        sum_line[-1] = "High. vote"

        t.add_row(sum_line + [
            "%.1f min" % highest_vote[1],
            "%.3f SBD" % float(highest_vote[2]),
            "%.3f SBD" % float(highest_vote[3]),
            "%.3f SP" % (highest_vote[4]),
            "%.1f %%" % (highest_vote[5])
        ])
        sum_line[-1] = "High. Cur."
        t.add_row(sum_line + [
            "%.1f min" % max_curation[1],
            "%.3f SBD" % float(max_curation[2]),
            "%.3f SBD" % float(max_curation[3]),
            "%.3f SP" % (max_curation[4]),
            "%.1f %%" % (max_curation[5])
        ])
        sum_line[-1] = "Sum"
        t.add_row(sum_line + [
            "-",
            "%.3f SBD" % (sum_curation[0]),
            "%.3f SBD" % (sum_curation[1]),
            "%.3f SP" % (sum_curation[2]),
            "%.2f %%" % curation_sum_percentage
        ])
        response = "curation for %s\n" % (authorperm)
        response += t.get_string()
        await ctx.channel.send("```" + response + "```")
Beispiel #5
0
                print("%d/%d scanned" % ())
            try:
                acc = Account(m, steem_instance=stm)
            except KeyboardInterrupt:
                aborted = True
            except:
                print("%s is not a valid account" % m)
                missing_accounts.append(m)
    


    shares = 0
    bonus_shares = 0
    balance_rshares = 0
    for m in member_data:
        shares += member_data[m]["shares"]
        bonus_shares += member_data[m]["bonus_shares"]
        balance_rshares += member_data[m]["balance_rshares"]
    
    
    print("units: %d" % shares)
    print("bonus units: %d" % bonus_shares)
    print("total units: %d" % (shares + bonus_shares))
    print("----------")
    print("balance_rshares: %d" % balance_rshares)
    print("balance_rshares: %.3f $" % stm.rshares_to_sbd(balance_rshares))
    if len(missing_accounts) > 0:
        print("%d not existing accounts: " % len(missing_accounts))
        print(missing_accounts)
    
                c = Comment(authorperm, steem_instance=stm)
                
                try:
                    
                    curation_rewards_SBD = c.get_curation_rewards(pending_payout_SBD=True)
                    curation_SBD = curation_rewards_SBD["active_votes"][vote["voter"]]
                    if vote_SBD > 0:
                        performance = (float(curation_SBD) / vote_SBD * 100)
                    else:
                        performance = 0                    
                except:
                    performance = 0
                    curation_rewards_SBD = None
                    
                rshares = int(vote["rshares"])
                vote_SBD = stm.rshares_to_sbd(int(vote["rshares"]))

                best_performance = 0
                best_time_delay = 0
                for v in c.get_votes():
                    v_SBD = stm.rshares_to_sbd(int(v["rshares"]))
                    if v_SBD > 0 and int(v["rshares"]) > rshares * 0.5 and curation_rewards_SBD is not None:
                        p = float(curation_rewards_SBD["active_votes"][v["voter"]]) / v_SBD * 100
                        if p > best_performance:
                            best_performance = p
                            if "time" in v:
                                best_time_delay = ((v["time"]) - c["created"]).total_seconds()
                            elif "last_update" in v:
                                best_time_delay = ((v["last_update"]) - c["created"]).total_seconds()
                            else:
                                best_time_delay = upvote_delay
Beispiel #7
0
            best_vote_delay_min = 0            
            performance = 0
            rshares = 0
            voter_rshares = 0

            if c.is_pending():
                for vote in c["active_votes"]:
                    if vote["voter"] == vote_log["voter"]:
                        rshares = int(vote["rshares"])
                for vote in c["active_votes"]:

                    voter_rshares = int(vote["rshares"])
                    
                    curation_SBD = curation_rewards_SBD["active_votes"][vote["voter"]]
                    if voter_rshares > 0 and vote["voter"] == vote_log["voter"]:
                        vote_SBD = stm.rshares_to_sbd(voter_rshares)
                        performance = (float(curation_SBD) / vote_SBD * 100)   
                    if voter_rshares > 0 and voter_rshares > rshares / rshares_divider:
                        vote_SBD = stm.rshares_to_sbd(voter_rshares)
                        p = float(curation_rewards_SBD["active_votes"][vote["voter"]]) / vote_SBD * 100
                        if p > best_performance:
                            best_performance = p
                            best_vote_delay_min = ((vote["time"]) - c["created"]).total_seconds() / 60                    
            else:
                rshares_sum = 0
                rshares_before = 0
                rshares_after = 0
                try:
                    activeVotes = ActiveVotes(authorperm, steem_instance=stm2).get_sorted_list()
                except:
                    continue