[SockoBot] Added $delegate & $help and an option to disable $register and check_for_payments().

in #utopian-io6 years ago (edited)

sockobotlogo.jpg

SockoBot is trying to be the only tool you'll ever need on your Discord Server or Facebook Page when it comes to steem, while also being easily expandable to anyone that knows a bit of Python.

SockoBot

New Features

What feature(s) did you add?

  • The $delegate command was added to provide an easy way to delegate SP from one account to another (utilizing SteemConnect for security).
elif text.lower().startswith('delegate'):
        try:
            user_name = text.split(' ')[1].lower()
            value = float(text.split(' ')[2])
            target_user_name = text.split(' ')[3].lower()
        except IndexError:
            await client.send_message(msg.channel, error_message)
            return None

        await client.send_message(msg.channel, 'To delegate using **SteemConnect**, click the link below: \n %s' % (delegate(value, user_name, target_user_name)))
  • The $help command as well as the help message and a new error message were added for quality of life purposes.

$help

    elif text.lower().startswith('help'):
        if client.pm_help == True:
            await client.send_message(msg.author, help_message)
        else:
            await client.send_message(msg.channel, help_message)

messages

help_message = str('Please, refer to <https://github.com/Jestemkioskiem/steem-sockobot/blob/master/README.md> for more desriptive help. \n\n \
**Commands and their arguments:**\n\n\
%(p)s*ping*\n\
%(p)s*convert* <value> <coin1> <coin2>\n\
%(p)s*delegate* <delegator> <value> <delegatee>\n\
%(p)s*payout* <username> <days>\n\
%(p)s*price* <coin>\n\
%(p)s*register* <username>\n\
%(p)s*sp* <username>\n\
%(p)s*vote* <username>\n\
%(p)s*wallet* <username>\n\n\
To get help regarding non-command functionality, refer to the github page\'s README.md file and it\'s Wiki, or contact the developer at Jestemkioskiem#5566') % {'p' : client.command_prefix}


error_message = str("The command you tried doesn't exist or you didn't provide enough arguments to run it. Use %shelp to see a list of commands and their arguments.") %(client.command_prefix)
  • An option to disable $register and check_for_payments() was added, leaving them disabled by default.
REGISTRATION = False # True to enable the use of the REGISTER command.
if REGISTRATION:
    ROLE_NAME = '' # Put Discord server's granted role name, used with the REGISTER command.
    SERVER_ID = '' # Put Discord server's ID
    minimum_payment = 1.000 # Price of registration, in STEEM
  • The NAME, TOKEN and KEY variables got their names changed to SB_NAME, SB_TOKEN and SB_KEY respectively to avoid issues with building the bot alongside other system applications.

  • To use $delegate, a delegate() function was created.

def delegate(sp, user_name, target_user_name):
    link = 'https://v2.steemconnect.com/sign/delegateVestingShares?delegator=%s&delegatee=%s&vesting_shares=%s' % (user_name, target_user_name, round(sp, 3))
    return link + '%20SP'
  • Some of the code was rewritten to be more clear and a few new comments were provided.

  • On top of that, all of the above functionality (except register which is different on messenger) has been properly altered and added to the capabilities of the Messenger iteration.

Bugfixes

  • Fixed an issue where $payout without an argument would not return an error message.
  • Fixed an issue where the bot would not use the newest data from coinmarketcap when using a command that had to pull a price of a coin, instead using old, cached data.

How did you implement it/them?

Nearly all of the code can be found in the examples above with proper explanation, but you can look it up in the commits as well: 8ff240f, 97756d9.

sockobotdarksmall.png



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @jestemkioskiem I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.27
TRX 0.11
JST 0.031
BTC 67320.55
ETH 3709.85
USDT 1.00
SBD 3.78