You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.4 KiB
Python

import click
import db
import wownero
import commands
@click.group()
def cli():
pass
@click.command()
def get_users():
users = db.User.select()
wallet = wownero.Wallet()
for u in users:
balances = wallet.balances(account=u.account_index)
address = wallet.addresses(account=u.account_index)[0]
click.echo(f'{u.account_index} - {u.telegram_user} ({u.telegram_id}) - {float(balances[0])} locked, {float(balances[1])} unlocked - {address}')
@click.command()
@click.argument('account_index')
def get_address(account_index):
address = wownero.Wallet().addresses(account=int(account_index))[0]
click.echo(address)
@click.command()
def get_wallet_accounts():
accounts = wownero.Wallet().accounts()
click.echo(accounts)
@click.command()
@click.argument('dest_address')
@click.argument('amount')
def transfer(dest_address, amount):
tx = wownero.Wallet().transfer(dest_address=dest_address, amount=amount, priority=2, account=0)
@click.command()
def generate_bot_help():
for cmd in commands.all_commands:
c = commands.all_commands[cmd]
if not 'admin' in c:
click.echo(f'{cmd} - {commands.all_commands[cmd]["help"]}')
cli.add_command(get_users)
cli.add_command(get_address)
cli.add_command(transfer)
cli.add_command(generate_bot_help)
cli.add_command(get_wallet_accounts)
if __name__ == '__main__':
cli()