tangled
alpha
login
or
join now
bwc9876.dev
/
bingus-bot
0
fork
atom
The world's most clever kitty cat
0
fork
atom
overview
issues
pulls
pipelines
Add learning from file (owner only)
bwc9876.dev
1 year ago
00da414b
5ba9798e
verified
This commit was signed with the committer's
known signature
.
bwc9876.dev
SSH Key Fingerprint:
SHA256:DanMEP/RNlSC7pAVbnXO6wzQV00rqyKj053tz4uH5gQ=
+16
1 changed file
expand all
collapse all
unified
split
src
bingus
cogs
markov.py
+16
src/bingus/cogs/markov.py
···
94
94
else:
95
95
await ctx.respond(f"{head}:\n{msg}")
96
96
97
97
+
@require_owner
98
98
+
@commands.slash_command()
99
99
+
async def study(
100
100
+
self, ctx: discord.ApplicationContext, file: discord.Option(discord.Attachment)
101
101
+
):
102
102
+
raw = await file.read()
103
103
+
try:
104
104
+
text = raw.decode()
105
105
+
self.markov.learn(text)
106
106
+
await ctx.respond("> Bingus learned from file!", ephemeral=True)
107
107
+
await self.update_words()
108
108
+
except UnicodeDecodeError:
109
109
+
await ctx.respond(
110
110
+
"> Bingus only understands UTF-8 text files!", ephemeral=True
111
111
+
)
112
112
+
97
113
@commands.Cog.listener()
98
114
async def on_ready(self):
99
115
await self.update_words()