Compare commits
4 Commits
gpt
..
crypto-update
| Author | SHA1 | Date | |
|---|---|---|---|
| e904451037 | |||
| cde205aad7 | |||
| 2e91781fad | |||
| 58ce3a8565 |
+8
-3
@@ -292,7 +292,9 @@ class Chatbot(commands.Cog):
|
||||
if random.random() > 0.9:
|
||||
try:
|
||||
# GPT request moet echt even in een non-blocking executortje, anders loopt de hele boel vast
|
||||
return await self.bot.loop.run_in_executor(None,self.getResponseForMessageOnline, wordsToRespondTo)
|
||||
response = await self.bot.loop.run_in_executor(None,self.getResponseForMessageOnline, wordsToRespondTo)
|
||||
if response:
|
||||
return response # Anders door naar local
|
||||
except:
|
||||
pass # Door naar local call
|
||||
return self.getResponseForMessageLocal(wordsToRespondTo)
|
||||
@@ -303,8 +305,11 @@ class Chatbot(commands.Cog):
|
||||
return req.json()["translations"][0]["text"]
|
||||
|
||||
def getResponseForMessageOnline(self, wordsToRespondTo):
|
||||
text = self.translateTo("en", " ".join(wordsToRespondTo))
|
||||
req = requests.post('http://gpt.hoekveen.net/complete', json={"prompt": text, "max_tokens": 60})
|
||||
prompt = " ".join(wordsToRespondTo)
|
||||
if not prompt:
|
||||
prompt = self.getResponseForMessageLocal([])
|
||||
text = self.translateTo("en", prompt)
|
||||
req = requests.post('http://gpt.hoekveen.net/complete', json={"prompt": text, "max_tokens": 80})
|
||||
print(req.json())
|
||||
respons = req.json()["text"]
|
||||
respons = respons[0:respons.rfind(".")+1] # Alles weg na de laatste punt
|
||||
|
||||
+8
-10
@@ -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)
|
||||
|
||||
+22
@@ -98,3 +98,25 @@ class General(commands.Cog):
|
||||
msg = 'Stemmen en nomineren kan hier: {}\n'.format(self.muzak_url)
|
||||
msg += '*Er zijn al {} nummers genomineerd*\n'.format(data['stemCount'])
|
||||
await ctx.channel.send(msg)
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
async def pollen(self, ctx):
|
||||
"Hoe veel last van pollen kun je verwachten?"
|
||||
poll = 'https://app.everviz.com/embed/apyvera/' # Thanks hooikoortsradar
|
||||
response = requests.get(poll)
|
||||
if response:
|
||||
# one-liner want eet stront
|
||||
cijfer = float(re.findall(r";\d\.?\d?;", json.loads([x for x in response.text.splitlines() if "var options =" in x][0].partition("=")[2].strip(";, "))["data"]["csv"])[-1].strip(";"))
|
||||
msg = ""
|
||||
if cijfer < 3:
|
||||
msg = f"Nou, het lijkt goed te gaan. Recentelijk gaven mensen hun klachten maar een {cijfer}. Lekker!"
|
||||
elif cijfer < 6:
|
||||
msg = f"Het lijkt allemaal mee te vallen. Men gaf hun klachten een {cijfer} deze week. Moet te doen zijn."
|
||||
elif cijfer < 7.5:
|
||||
msg = f"Ai. Het gaat lekker met de pollen, maar het ergste moet nog komen of is al geweest. Klachtencijfer van {cijfer}; Sterkte alvast."
|
||||
else:
|
||||
msg = f"Balen dit. Klachtencijfer van {cijfer}, dus bekijk het maar. Joe."
|
||||
await ctx.channel.send(ctx.author.mention + ' ' + msg)
|
||||
else:
|
||||
await ctx.channel.send(ctx.author.mention + ' Er lijkt even geen klachtencijfer beschikbaar te zijn. Probeer het later nog eens')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user