I'm working on a bot that checks specific ether addr and checks token transfers. Everything is done api and stuff but I can't get checking part working. It checks for addrs and it outputs if it changes but how to run it every 30 sec and that output get to discord.
my code:
import requests, time, json, sys, discord
result = requests.get('myapi')
result.json()
results = "soon:tm:"
def price_of_gas(inp):
def recursive_function(inp):
if type(inp) is list:
for i in inp:
ans = recursive_function(i)
if ans != None:
return ans
elif type(inp) is dict:
if 'name' in inp:
return inp['name']
for i in inp:
ans = recursive_function(inp[i])
if ans != None:
return ans
else:
return None
ans = recursive_function(inp)
return ans if ans else "Could NOT find the new token tx"
message.channel.send(price_of_gas(result.json()['operations'][0]['tokenInfo']['name']))
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if message.content == '.get':
#send message
#checking other commands like '.help'
while True:
# Code executed here
print ('done')
time.sleep(1)
client = MyClient()
client.run("mytoken")
Look it like this when script check and if output token, then program to run .get command down there or something like that. i was working on it for 7 hours and i cant get it working.