Пример #1
0
async def on_message(message):
    msg = message
    msgcon = msg.content
    msgaut = '@' + msg.author.name

    if bot_role not in [
        y.name.lower() for y in message.author.roles] and \
                    message.channel.id in allowed_channels:

        if message.content.startswith('https://steemit') or \
                message.content.startswith('steemit'):
            smsgcon = msgcon.split('@')[1]
            tmsgcon = msgcon.split('/')[3]
            sp = Post(smsgcon)

            if sp.time_elapsed() > datetime.timedelta(hours=2) and \
                    sp.time_elapsed() < datetime.timedelta(hours=48):
                tempmsg = await client.send_message(
                    message.channel,
                    'The post is ' + str(sp.time_elapsed())[:-7] +
                    ' hours old and earned ' + str(sp.reward))

                res = await client.wait_for_reaction(['☑'], message=msg)
                if moderating_roles[0] in [
                        y.name.lower() for y in res.user.roles
                ] or moderating_roles[1] in [
                        y.name.lower() for y in res.user.roles
                ]:
                    await client.delete_message(msg)
                    await client.delete_message(tempmsg)

                    if tmsgcon in tag_list:
                        dest_channel = tag_list.index(tmsgcon)
                    else:
                        dest_channel = tag_list.len()

                    await client.send_message(
                        client.get_channel(channels_list[dest_channel]),
                        content=msgaut + ' sent: ' + msgcon)

            else:
                tempmsg = await client.send_message(
                    message.channel,
                    'Your post has to be between 2h and 48h old.')
                await client.delete_message(msg)

        elif message.content.startswith('!ping') and moderating_roles[0] in [
                y.name.lower() for y in message.author.roles
        ] or moderating_roles[1] in [
                y.name.lower() for y in message.author.roles
        ]:
            await client.send_message(message.channel, ':ping_pong: Pong!')

        elif bot_role not in [y.name.lower() for y in message.author.roles]:
            await client.delete_message(msg)
            await client.send_message(message.channel,
                                      content=msgaut +
                                      ' Your link has to start with '
                                      '"https://steemit" or "steemit"')
Пример #2
0
async def check_age(msg,low,high):
	link = str(msg.content).split(' ')[0]
	p = Post(link.split('@')[1])

	if p.time_elapsed() > datetime.timedelta(hours=low) and p.time_elapsed() < datetime.timedelta(hours=high):
		return True
	else:
		age_error = await client.send_message(msg.channel, 'Your post has to be between 2h and 48h old.')
		await client.delete_message(msg)
		await asyncio.sleep(6)
		await client.delete_message(age_error)
		return False
Пример #3
0
async def get_info(msg):
    link = str(msg.content).split(' ')[0]
    p = Post(link.split('@')[1])
    if check_age(p, 2, 48):
        embed = discord.Embed(color=0xe3b13c)
        embed.add_field(name="Title", value=str(p.title), inline=False)
        embed.add_field(name="Author", value=str("@" + p.author), inline=True)
        embed.add_field(name="Nominator",
                        value=str('<@' + msg.author.id + '>'),
                        inline=True)
        embed.add_field(name="Age",
                        value=str(p.time_elapsed())[:-10] + " hours",
                        inline=False)
        embed.add_field(name="Payout", value=str(p.reward), inline=True)
        embed.add_field(name="Payout in USD",
                        value=await payout(p.reward, sbd_usd, ste_usd),
                        inline=True)
        embed.set_footer(
            text="Marshal - a Steem bot by Vctr#5566 (@jestemkioskiem)")
        return embed
    else:
        age_error = await client.send_message(
            msg.channel, 'Your post has to be between 2h and 48h old.')
        await client.delete_message(msg)
        await asyncio.sleep(6)
        await client.delete_message(age_error)
Пример #4
0
async def get_info(msg):
	link = str(msg.content).split(' ')[0]
	p = Post(link.split('@')[1])
	embed=discord.Embed(color=0xe3b13c)
	embed.add_field(name="Title", value=str(p.title), inline=False)
	embed.add_field(name="Author", value=str("@"+p.author), inline=True)
	embed.add_field(name="Nominator", value=str('<@'+ msg.author.id +'>'), inline=True)
	embed.add_field(name="Age", value=str(p.time_elapsed())[:-10] +" hours", inline=False)
	embed.add_field(name="Payout", value=str(p.reward), inline=True)
	embed.add_field(name="Payout in USD", value=await payout(p.reward,sbd_usd,ste_usd), inline=True)
	return embed
Пример #5
0
def profile_as_json():

    steemd_instance = get_steemd_instance()

    if request.method == "GET":
        links = request.args.get("links")
    else:
        links = request.form.get("links")

    rewards = []
    links = links.split(",")
    for link in links:
        try:
            post = Post(link, steemd_instance=steemd_instance)
        except PostDoesNotExist:
            abort(404)

        total, curation, author, beneficiaries, sbd_amount, sp_amount, \
            usd_amount = calculate_rewards(steemd_instance, post)

        rewards.append({
            "link":
            link,
            "total":
            total,
            "curation":
            curation,
            "author":
            author,
            "beneficiaries":
            beneficiaries,
            "cashout_time":
            post["cashout_time"],
            "is_main_post":
            post.is_main_post(),
            "title":
            post["title"],
            "elapsed_seconds":
            int(post.time_elapsed().total_seconds()),
            "sbd_amount":
            sbd_amount,
            "sp_amount":
            sp_amount,
            "usd_amount":
            usd_amount,
        })

    rewards = sorted(rewards, key=lambda k: k['elapsed_seconds'])

    return jsonify({"rewards": rewards})
Пример #6
0
async def get_info(msg):
    link = str(msg.content).split(' ')[0]
    p = Post(link.split('@')[1])

    embed = discord.Embed(color=0xe3b13c)
    embed.add_field(name="Title", value=str(p.title), inline=False)
    embed.add_field(name="Author", value=str("@" + p.author), inline=True)
    embed.add_field(name="Nominator",
                    value=str('<@' + msg.author.id + '>'),
                    inline=True)
    embed.add_field(name="Age",
                    value=str(p.time_elapsed())[:-10] + " hours",
                    inline=False)
    embed.set_footer(text="Onelovebot")
    return embed
Пример #7
0
def curate(mysql_uri, vote_caster, posting_key, weight=+50,
         self_vote=False, limit=20, apply_to_categories=None,
         vote_delay=+30, nodes=None):
    last_posts = get_last_approved_posts(limit)
    s = Steem(keys=[posting_key], nodes=nodes)
    for utopian_post in last_posts:

        if utopian_post["author"] == vote_caster and not self_vote:
            logger.info("Skipping %s. No self-vote.", post.identifier)
            continue

        post = Post(
            "@%s/%s" % (utopian_post["author"], utopian_post["permlink"]))

        elapsed_minutes = int(post.time_elapsed().seconds / 60)
        if elapsed_minutes < vote_delay:
            logger.info(
                "Skipping %s. I will wait until %s minutes.",
                post.identifier,
                vote_delay - elapsed_minutes
            )
            continue

        if already_voted(mysql_uri, post):
            logger.info("Skipping %s. Already voted.", post.identifier)
            continue

        if apply_to_categories:
            if utopian_post["json_metadata"]["type"] \
                    not in apply_to_categories:
                logger.info(
                    "Skipping %s, This posts category: %s",
                    post.identifier,
                    utopian_post["json_metadata"]["type"]
                )
                continue

        try:
            s.commit.vote(post.identifier, weight, account=vote_caster)
            add_log(mysql_uri, post)
            logger.info(
                "Casted vote on: %s with weight: %s", post.identifier, weight)
            time.sleep(3)
        except Exception as error:
            if 'already voted' in error.args[0]:
                add_log(mysql_uri, post)
            logger.error(error)
            continue
Пример #8
0
def get_post_details(s, identifier):
    try:
        p = Post(identifier)
    except Exception as error:
        return {
            "error": "Couldn't fetch the post.",
            "message": str(error),
        }

    reward_fund = s.get_reward_fund()
    reward_balance, recent_claims = reward_fund["reward_balance"], \
                                    reward_fund["recent_claims"]
    base_price = s.get_current_median_history_price()["base"]

    total_payout = 0
    bot_payout = 0
    used_bots = []
    for vote in p.get("active_votes", []):
        vote_payout = get_payout_from_rshares(vote["rshares"], reward_balance,
                                              recent_claims, base_price)

        if vote["voter"] in BOT_LIST and vote_payout > MINIMUM_RSHARE_PAYOUT:
            bot_payout += vote_payout
            used_bots.append({
                "bot": vote["voter"],
                "payout": round(vote_payout, 2),
            })

        total_payout += vote_payout

    stats = {
        "total": round(total_payout, 2),
        "bot": round(bot_payout, 2),
        "organic": round((total_payout - bot_payout), 2),
        "net_votes": p["net_votes"],
        "elapsed_time": p.time_elapsed(),
        "comment_count": p.children,
    }

    return stats
Пример #9
0
async def get_info(msg):
    link = str(msg.content).split(' ')[0]
    p = Post(link.split('@')[1])
    sbd_usd = cmc.ticker("steem-dollars", limit="3",
                         convert="USD")[0].get("price_usd", "none")
    ste_usd = cmc.ticker("steem", limit="3",
                         convert="USD")[0].get("price_usd", "none")

    embed = discord.Embed(color=0xe3b13c)
    embed.add_field(name="Title", value=str(p.title), inline=False)
    embed.add_field(name="Author", value=str("@" + p.author), inline=True)
    embed.add_field(name="Nominator",
                    value=str('<@' + msg.author.id + '>'),
                    inline=True)
    embed.add_field(name="Age",
                    value=str(p.time_elapsed())[:-10] + " hours",
                    inline=False)
    embed.add_field(name="Payout", value=str(p.reward), inline=True)
    embed.add_field(name="Payout in USD",
                    value=await payout(p.reward, sbd_usd, ste_usd),
                    inline=True)
    embed.set_footer(
        text="SockoBot - a Steem bot by Jestemkioskiem#5566 (@jestemkioskiem)")
    return embed
Пример #10
0
### Calculating author and beneficiary rewards
def estimate_rewards(post):
    votes = [vote for vote in post["active_votes"]]
    total_share = sum([float(vote["rshares"]) * reward_share * base for vote in votes])
    curation_share = sum([curation_reward(post, vote) for vote in votes])
    author_share = (total_share - curation_share) * (1.0 - beneficiaries_pct(post))
    beneficiary_share = (total_share - curation_share) * beneficiaries_pct(post)

    print(f"Estimated total reward for this post is ${total_share:.2f}")
    print(f"Estimated author reward for this post is ${author_share:.2f}")
    print(f"Estimated beneficiary reward for this post is ${beneficiary_share:.2f}")
    print(f"Estimated curation reward for this post is ${curation_share:.2f}\n")

### Estimating rewards in last `N` days
account = "steempytutorials"
time_period  = timedelta(days=3)

posts = set()
for post in Account(account).history_reverse(filter_by="comment"):
    try:
        post = Post(post)
        if post.time_elapsed() < time_period:
            if post.is_main_post() and not post["title"] in posts:
                posts.add(post["title"])
                print(post["title"])
                estimate_rewards(post)
        else:
            break
    except Exception as error:
        continue
Пример #11
0
all_posts = []
acc_posts = []
post_dict = {}
total = 0

for a in blog: # Storing all posts in a list as links.
	astr = str(a).split("-")[1:]
	astr = "-".join(astr)
	astr = astr.replace(">", "")
	astr = "https://steemit.com/" + astr
	all_posts.append(astr)

x = 0
while x < len(all_posts): # Storing all posts that are less than a week old in a list, with an accuracy of 1 minute.
	post = Post(str(all_posts[x]))
	if post.time_elapsed() < datetime.timedelta(days=7):
		acc_posts.append(all_posts[x])
	x+= 1

x = 0
while x < len(acc_posts): # Collecting rewards for each post and storing them in the "total" variable.
	post = Post(acc_posts[x])
	reward = str(post.reward)
	reward = float(reward.replace("SBD", ""))
	total += reward
	post_dict[acc_posts[x]] = post.reward # Storing all of the posts with their rewards in a dictionary. This is not used in this program, but might be useful to you.
	x+= 1

cmc = Market() # Coinmarketcap API call.
# Checking the live values of Steem and SBD.
ste_usd = cmc.ticker("steem", limit="3", convert="USD")