Example #1
0
def getBotTime(botname,
               accountname='soteyapanbot',
               amount=4.5,
               iteration=4,
               critical=4.5,
               timesleep=3,
               minsBefore=0.97):
    """
        Retrieves bot voting time given the botname.
    """
    url = "https://steembottracker.net/bid_bots"
    stm = steemlib()
    with urllib.request.urlopen(url) as url2:
        data = json.loads(url2.read().decode())
        for i in range(len(data)):
            if data[i]['name'] == botname:
                minsLeft = data[i]['next'] / (60 * 1000)
                if minsLeft < minsBefore:
                    # Retrieve updated balance, voted List and vote queue
                    balance = samount(
                        stm.get_account(accountname)["balance"]).amount
                    voted = votedList()
                    voteQue = postGetter(accountname)
                    print(("{} minutes left for the next minnowvotes round."
                           ).format(minsLeft))
                    # Send bids for the existing round
                    finished, memo = sendBids(stm, balance, voteQue, voted,
                                              amount, iteration, critical,
                                              timesleep, accountname, botname)
                    # Finished will be bigger than one after a successful round
                    if finished >= 1:
                        print("Sleeping after successful round for 5 minutes.")
                        time.sleep(300)  #180
                else:
                    time.sleep(1)
Example #2
0
def getRshares(accountname='soteyapanbot'):
    s = steemlib()
    c = Converter()
    account = s.get_account(accountname)
    vests = samount(account['vesting_shares']).amount
    delegated_vests = samount(account['delegated_vesting_shares']).amount
    received_vests = samount(account['received_vesting_shares']).amount
    current_vests = float(vests) - float(delegated_vests) + float(
        received_vests)
    steem_power = c.vests_to_sp(current_vests)
    rshares = c.sp_to_rshares(steem_power)
    return (rshares)
Example #3
0
def defineWallet(key,
                 stm,
                 accountname,
                 amount,
                 memo,
                 toacc='minnowvotes',
                 amounttype='STEEM'):
    """
        This may be updated to transfer.
        Defines wallet and executes the transfer.
    """
    steem = steemlib(keys=[key])
    steem.transfer(toacc, amount, amounttype, memo, account=accountname)
Example #4
0
def getBreakeven():
    s = steemlib()
    c = Converter()
    steemPrice = float(s.get_current_median_history_price()['base'].replace(
        "SBD", "")) / float(
            s.get_current_median_history_price()['quote'].replace("STEEM", ""))
    for i in range(400000, 500000, 1000):
        rshares = c.sp_to_rshares(i)
        claims = getClaims(rshares)
        steemRewards, steemRewardsOld = rwdComp(claims, rshares, i, steemPrice,
                                                s, c)
        if math.fabs(steemRewards - steemRewardsOld) <= 0.001:
            print(steemRewards, steemRewardsOld, i)
            break
    return (steemRewards, steemRewardsOld, i)
Example #5
0
def postGetter(accountname='soteyapanbot'):
    """
        Outputs comments by the author.
        Finds the ones that are not voted by minnowvotes.
        indicator goes up by 1 everytime a minnowvotes has seen.
        aVotes = [{voter:x, value:y},
                    {voter:z,value:k}]
        voteQue = [url1, url2, url3, ...]

    """
    s = steemlib()
    utc = pytz.UTC
    dt5 = utc.localize(datetime.datetime.now() - datetime.timedelta(days=6))
    dt4 = utc.localize(datetime.datetime.now() - datetime.timedelta(days=0))
    last5days = utc.localize(datetime.datetime.now() -
                             datetime.timedelta(days=6))
    # Get posts of selected account
    posts = s.get_discussions_by_author_before_date(
        author=accountname,
        start_permlink='',
        before_date=dt5.strftime("%Y-%m-%dT%H:%M:%S"),
        limit=50)
    voteQue = []

    for post in posts:
        adjDt = utc.localize(
            parse(post['created']) - datetime.timedelta(hours=4))
        if (adjDt > dt5) == True:
            if (adjDt < dt4) == True:
                url = 'https://steemit.com' + post['url']
                aVotes = post['active_votes']
                indicator = 0
                if len(aVotes) > 0:
                    for i in range(len(aVotes)):
                        if aVotes[i]['voter'] == 'minnowvotes':
                            indicator += 1
                if indicator >= 1:
                    pass
                else:
                    voteQue.append(url)

    return voteQue
Example #6
0
def commentGetter(accountname):
    """
        Outputs comments by the author.
        Finds the ones that are not voted by minnowvotes.
        indicator goes up by 1 everytime a minnowvotes has seen.
        aVotes = [{voter:x, value:y},
                    {voter:z,value:k}]
        voteQue = [url1, url2, url3, ...]

    """
    s = steemlib()
    utc = pytz.UTC
    dt5 = utc.localize(datetime.datetime.now() - datetime.timedelta(days=6))
    dt4 = utc.localize(datetime.datetime.now() - datetime.timedelta(days=0))
    stop = datetime.datetime.utcnow() - timedelta(days=5)
    voteQue = []
    query2 = {
        "limit": 50,  #number of comments
        "start_author": accountname  #selected user
    }
    # get comments of selected account
    comments = s.get_discussions_by_comments(query2)
    for comment in comments:
        indicator = 0
        url = "https://steemit.com" + comment['url']
        aVotes = comment['active_votes']
        adjDt = utc.localize(
            parse(comment['created']) - datetime.timedelta(hours=4))
        if (adjDt > dt5) == True:
            if (adjDt < dt4) == True:
                if len(aVotes) > 0:
                    for i in range(len(aVotes)):
                        if aVotes[i]['voter'] == 'minnowvotes':
                            indicator += 1
                if indicator >= 1:
                    pass
                else:
                    voteQue.append(url)
    return voteQue
Example #7
0
async def on_message(message):
    config = pd.read_csv('config.csv')
    accountname = config['accountname'][0]
    if message.author == client.user:
        return
    if str(message.author) in adminAccounts:
        if message.content.lower() == "blackboard":
            returned = '__Blackboard__ \n' + bringList()
            await client.send_message(message.channel, returned)
        if message.content.lower().startswith("burda misin sote"):
            returned = 'Burdayim abicim, burdayim...'
            await client.send_message(message.channel, returned)
        if message.content.lower().startswith("nasilsin sote"):
            returned = 'Iyi valla, sizleri sormali?'
            await client.send_message(message.channel, returned)
        if message.content.lower().startswith("sampiyon kim"):
            returned = 'Galatasaray :yellow_heart: :heart:'
            await client.send_message(message.channel, returned)
        if message.content.startswith("blackboard add"):
            username = message.content.rsplit(" ")[2]
            msg = '{} is added to the blackboard list by {}.'.format(
                username, message.author.mention)
            returned = dbHandler(username, message.author, 'add')
            if returned.startswith('Success'):
                await client.send_message(message.channel, msg)
            if returned.startswith('Error'):
                await client.send_message(message.channel, returned)
        if message.content.startswith("blackboard remove"):
            username = message.content.rsplit(" ")[2]
            msg = '{} is removed from the blackboard list by {}.'.format(
                username, message.author.mention)
            returned = dbHandler(username, message.author, 'remove')
            if returned.startswith('Success'):
                await client.send_message(message.channel, msg)
            if returned.startswith('Error'):
                await client.send_message(message.channel, returned)
        if message.content.lower() == "share update":
            returned = shareUpdate("soteyapanbot")
    if str(message.author) in allowedAccounts:
        if len(message.content) == 14 and message.content.lower(
        ) == "sote kar zarar":
            accountname = str(message.author).rsplit("#")[0]
            print(message.author, ' requested rshare calculation.')
            print(len(message.content))
            returned = 'Thank you for your message '
            try:
                rewards, rewardsold, steemp = getBreakeven()
                returned += str(
                    message.author.mention
                ) + '\nThe breakeven point requires = {}k Steem power.\nThis equals to= ${:0.2f}'.format(
                    int(steemp / 1000), rewards)
            except:
                returned += "\n We cannot calculate the breakeven point at the moment. Sorry for the inconvenience."
            await client.send_message(message.channel, returned)
        if len(message.content) == 11 and message.content.lower(
        ) == "sote rshare":
            accountname = str(message.author).rsplit("#")[0]
            print(message.author, ' requested rshare calculation.')
            print(len(message.content))
            returned = 'Thank you for your message '
            try:
                rshares = getRshares(accountname)
                returned += str(message.author.mention
                                ) + '\n Your rshare is = {}'.format(rshares)
            except:
                returned += "\n We cannot find your username on steemit."
            await client.send_message(message.channel, returned)
        if len(message.content) > 11:
            if message.content.startswith("sote"):
                if message.content.endswith("rshare"):
                    accountname = message.content.rsplit(" ")[1]
                    print(message.author, ' requested rshare calculation.')
                    returned = 'Thank you for your message '
                    try:
                        rshares = getRshares(accountname)
                        returned += str(message.author.mention
                                        ) + "\n {}'s rshare is = {}".format(
                                            accountname, rshares)
                    except:
                        returned += "\n We cannot find your username on steemit."
                    await client.send_message(message.channel, returned)
        if message.content.lower() == "sote voteque":
            newQue = list(set(postGetter(accountname)) - set(tempLinks()))
            returned = '__Current Vote Queue__ \n' + listtoChat(newQue)
            await client.send_message(message.channel, returned)
        if message.content.lower() == "sote latest":
            returned = '__Temp Links__ \n' + listtoChat(tempLinks())
            await client.send_message(message.channel, oreturned)
        if message.content.lower().startswith("sote sendbids"):
            await client.send_message(
                message.channel,
                f'{time.asctime()} -> {message.author.mention}')
            inp = message.content.lower().rsplit(' ')
            failed = 0
            botname = inp[2]
            iteration = inp[4]
            returned = 'Waiting for the API response.'
            # Try to get the amount
            try:
                if isinstance(float(inp[3]), float) == True:
                    amount = float(inp[3])
            except:
                failed = 1
                returned = 'The **amount** value should be the 4th item in the order\n\n __Example:__\n sote sendbids botname __*bidvalue*__ iteration linkname'
            # Try to get the memo
            try:
                if inp[5].startswith('http'):
                    memo = inp[5]
                else:
                    returned = 'The link should start with http.'
            except:
                failed = 1
                returned = 'The **link** should be the 5th item in the order\n\n __Example:__\n sote sendbids botname bidvalue iteration __*linkname*__'
            await client.send_message(message.channel, returned)
            if failed == 0:
                stm = steemlib()
                voted = votedList()
                voteQue = postGetter(accountname)
                balance = samount(
                    stm.get_account(accountname)["balance"]).amount
                finished, memo2 = sendBids(stm,
                                           balance,
                                           voteQue,
                                           voted,
                                           amount,
                                           critical=2,
                                           iteration=int(inp[4]),
                                           accountname=accountname,
                                           botname=botname,
                                           memo=memo)
                returned = 'The bid for {} has successfully transferred.'.format(
                    memo2)
            await client.send_message(message.channel, returned)