Added Wolfram!
This commit is contained in:
parent
5c4c6631ba
commit
526d9d72ef
4 changed files with 27 additions and 38 deletions
|
@ -1,29 +0,0 @@
|
||||||
import discord
|
|
||||||
from discord.ext import commands
|
|
||||||
import re
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
class Logger(commands.Cog):
|
|
||||||
def __init__(self, client):
|
|
||||||
self.client = client
|
|
||||||
self.first = True
|
|
||||||
self.last_update = datetime.now()
|
|
||||||
self.most_common = []
|
|
||||||
|
|
||||||
@commands.Cog.listener()
|
|
||||||
async def on_message(self, message):
|
|
||||||
if message.author.bot:
|
|
||||||
return
|
|
||||||
|
|
||||||
if message.channel.id != 439466964625391637:
|
|
||||||
return
|
|
||||||
|
|
||||||
if message.content.startswith(('.', '!', '-', '?', '/')):
|
|
||||||
return
|
|
||||||
|
|
||||||
with open('data/naughty_step.txt', 'a') as file:
|
|
||||||
file.write(message.content + '\n')
|
|
||||||
|
|
||||||
|
|
||||||
def setup(client):
|
|
||||||
client.add_cog(Logger(client))
|
|
|
@ -1,17 +1,14 @@
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from textgenrnn import textgenrnn
|
|
||||||
|
|
||||||
class Responses(commands.Cog):
|
class Responses(commands.Cog):
|
||||||
|
|
||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
self.client = client
|
self.client = client
|
||||||
self.model = textgenrnn("data/textgenrnn_weights.hdf5")
|
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_message(self, message: discord.Message):
|
async def on_message(self, message: discord.Message):
|
||||||
if message.author == self.client.user:
|
if message.author == self.client.user:
|
||||||
print("Cock")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# @applesauce
|
# @applesauce
|
||||||
|
@ -19,12 +16,6 @@ class Responses(commands.Cog):
|
||||||
await message.channel.send(f"Stop pinging us {message.author.mention} <:pinged:451198700832817202>")
|
await message.channel.send(f"Stop pinging us {message.author.mention} <:pinged:451198700832817202>")
|
||||||
return
|
return
|
||||||
|
|
||||||
if "<@!657709911337074698>" in message.content:
|
|
||||||
print("In")
|
|
||||||
result = self.model.generate(temperature=0.7, return_as_list=True)[0]
|
|
||||||
await message.channel.send(result)
|
|
||||||
return
|
|
||||||
|
|
||||||
if message.author.id == 478006431589728259:
|
if message.author.id == 478006431589728259:
|
||||||
if message.content == "<@&380535423233032193> NUMBERS REEEEEEEE":
|
if message.content == "<@&380535423233032193> NUMBERS REEEEEEEE":
|
||||||
await message.channel.send(f"<@&380535423233032193> {message.author.mention} REEEEEEEE")
|
await message.channel.send(f"<@&380535423233032193> {message.author.mention} REEEEEEEE")
|
||||||
|
|
27
cogs/fun/wolfram.py
Normal file
27
cogs/fun/wolfram.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
from wolframclient.evaluation import WolframLanguageSession
|
||||||
|
from wolframclient.language import wl, wlexpr
|
||||||
|
from util import embed
|
||||||
|
|
||||||
|
class WolframAlpha(commands.Cog):
|
||||||
|
def __init__(self, client):
|
||||||
|
self.client = client
|
||||||
|
self.session = WolframLanguageSession()
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.session.terminate()
|
||||||
|
|
||||||
|
@commands.command(name="WolframLanguage", description="Evaluates WolframLanguage expressions (Not to be confused with WolframAlpha!)", usage="WolframLanguage <expression>", aliases=["wl"])
|
||||||
|
async def WolframLanguage(self, ctx, *expr):
|
||||||
|
msg = await ctx.send(embed=embed.make_embed("WolframLanguage", "Thinking..."))
|
||||||
|
expr = " ".join(expr)
|
||||||
|
evaluate = self.session.evaluate(expr)
|
||||||
|
|
||||||
|
self.session.evaluate(wl.Export("eval.png", evaluate, "PNG"))
|
||||||
|
await msg.delete()
|
||||||
|
data = embed.make_embed_image("Result", "eval.png")
|
||||||
|
await ctx.send(embed=data[0], file=data[1])
|
||||||
|
|
||||||
|
def setup(client):
|
||||||
|
client.add_cog(WolframAlpha(client))
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue