-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathdeposit.py
38 lines (34 loc) · 1.06 KB
/
deposit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import discord, json, requests
from discord.ext import commands
def rpcdat(method,params,port):
try:
rpcdata = json.dumps({
"jsonrpc": 1.0,
"id":"rpctest",
"method": str(method),
"params": params,
"port": port
})
req = requests.get('http://127.0.0.1:'+port, data=rpcdata, auth=('user', 'pass'), timeout=8)
return req.json()['result']
except Exception as e:
return "Error: "+str(e)
class deposit:
def __init__(self, bot):
self.bot = bot
@commands.command(pass_context=True)
async def deposit(self, ctx):
"""Shows wallet info"""
port = "11311"
params = ctx.message.author
user_addy = rpcdat('getaddressesbyaccount',[str(params)],port)
try:
if user_addy[0] == "":
new_user_addy = rpcdat('',)
else:
await self.bot.say(params.mention+"'s Deposit Address: `"+str(user_addy[0])+"`")
except IndexError:
user_addy = rpcdat('getaccountaddress',[str(params)],port)
await self.bot.say(params.mention+"'s Deposit Address: `"+str(user_addy[0])+"`")
def setup(bot):
bot.add_cog(deposit(bot))