-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNetaPriceBot.py
More file actions
69 lines (61 loc) · 2.17 KB
/
Copy pathNetaPriceBot.py
File metadata and controls
69 lines (61 loc) · 2.17 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#By CamelJuno 🐪
import discord
import requests
import random
import json
import base64
import string
import time
client = discord.Client()
def getJUNOGecko():
headers = {
'Host': 'api.coingecko.com',
'Accept': '*/*'
}
a = requests.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=juno-network',headers=headers,timeout=10)
if a.status_code == 200:
z = json.loads(a.text)[0]['current_price']
if z == None:
getJUNOGecko()
else:
return z
else:
getJUNOGecko()
def getNETA2JUNO():
headers = {
'Host': 'rpc-juno.itastakers.com',
'Content-Type': 'application/json',
}
jsonData = {"jsonrpc":"2.0","id":genId(),"method":"abci_query","params":{"path":"/cosmwasm.wasm.v1.Query/SmartContractState","data":"0a3f6a756e6f3165386e366368376d736b7334383765637a6e796561676d7a64356d6c327071397467656471743275363376726130713072396d71726a7936797312377b22746f6b656e325f666f725f746f6b656e315f7072696365223a7b22746f6b656e325f616d6f756e74223a2231303030303030227d7d","prove":False}}
a = requests.post('https://rpc-juno.itastakers.com/',headers=headers,json=jsonData,timeout=10)
if a.status_code == 200:
a = round(float(base64.b64decode(json.loads(a.text)['result']['response']['value']).split('"token1_amount":"'.encode('utf-8'),1)[1].split('"}'.encode('utf-8'),1)[0])/1000000,2)
return a
else:
getNETA2JUNO()
def genId():
res = ''
for i in range(12):
res = res+random.choice(string.digits)
return int(res)
@client.event
async def on_ready():
print(f'You have logged in as {client}')
guild = client.get_guild(guildID)
member = guild.get_member(memberID)
while(True):
try:
NETAPrice = round(getJUNOGecko()*getNETA2JUNO(),2)
await member.edit(nick="NETA $"+str(NETAPrice))
time.sleep(1)
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=str(NETA2JUNO)+" JUNO"))
print(str(JUNO2UST*NETA2JUNO))
time.sleep(60)
except:
continue
guildID = 0
memberID = 0
BOT_TOKEN = 'PLACE_AUTH_TOKEN_HERE'
client.run(BOT_TOKEN)