updates crypto module with newer async code #25

Merged
jp merged 1 commits from crypto-update into master 2023-06-25 21:24:52 +02:00
+8 -10
View File
@@ -197,8 +197,7 @@ class Cryptocoin(commands.Cog):
#user functions below
@commands.command(pass_context=True)
@asyncio.coroutine
def coinprice(self, ctx, coinId: str, currencyId: str="USD"):
async def coinprice(self, ctx, coinId: str, currencyId: str="USD"):
"""Geeft de huidige prijs van de desbetreffende crypto currency
Bijv:
!coinprice BTC
@@ -211,20 +210,19 @@ class Cryptocoin(commands.Cog):
currencyId = currencyId.upper()
if (currencyId not in allowedCurrencies):
yield from ctx.channel.send("Valuta " + currencyId + " ken ik niet. :disappointed: ")
await ctx.channel.send("Valuta " + currencyId + " ken ik niet. :disappointed: ")
return
price = self.getCoinPrice(coinId, currencyId)
if (price == -1):
yield from ctx.channel.send("Die cryptocoin ken ik niet... :frowning2: ")
await ctx.channel.send("Die cryptocoin ken ik niet... :frowning2: ")
return
yield from ctx.channel.send(coinId + " is nu " + str(price) + " " + currencyId + " waard.")
await ctx.channel.send(coinId + " is nu " + str(price) + " " + currencyId + " waard.")
@commands.command(pass_context=True)
@asyncio.coroutine
def coinadvice(self, ctx, coinId: str=""):
async def coinadvice(self, ctx, coinId: str=""):
"""Voor al uw adviezen in monopolygeld
Vraag Stroop's mening over een specifieke coin:
!coinadvice NLG
@@ -237,7 +235,7 @@ class Cryptocoin(commands.Cog):
#Geen specieke coin? Doe random.
if(coinId == ""):
yield from ctx.channel.send( self.getRandomCoinAdvice() )
await ctx.channel.send( self.getRandomCoinAdvice() )
return
coinId = coinId.upper()
@@ -245,7 +243,7 @@ class Cryptocoin(commands.Cog):
growPercentage, coinStability, dummy = self.analyseCoin(coinId)
if (growPercentage == 0 and coinStability == 1.0): #aanname. anders moet je weer een extra call doen.
yield from ctx.channel.send("Die cryptocoin ken ik niet... :frowning2: ")
await ctx.channel.send("Die cryptocoin ken ik niet... :frowning2: ")
return
time.sleep(0.1) #don't overload the API
@@ -302,5 +300,5 @@ class Cryptocoin(commands.Cog):
if (coinStability < 0.3):
message += "Denk ik?"
yield from ctx.channel.send(message)
await ctx.channel.send(message)