Adding wifi qr code generator to dale bot
This commit is contained in:
parent
4a967f7656
commit
62d54950b4
@ -1,7 +1,8 @@
|
||||
from discord.ext import commands
|
||||
from discord import option
|
||||
from discord.ext import commands
|
||||
import discord
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
|
||||
class ActualUtils(commands.Cog):
|
||||
@ -107,6 +108,38 @@ class ActualUtils(commands.Cog):
|
||||
except Exception:
|
||||
return await ctx.send_followup("Sorry, I'm unable to answer that")
|
||||
|
||||
@commands.slash_command(
|
||||
guild_ids=None,
|
||||
name="wifiqr",
|
||||
description="Generate a qr code for your wifi network",
|
||||
)
|
||||
@option(
|
||||
name="network_name",
|
||||
required=True,
|
||||
description="The name of your network",
|
||||
)
|
||||
@option(
|
||||
name="password", required=True, description="Your wifi password", min_length=8
|
||||
)
|
||||
async def wifiqr(self, ctx, network_name, password):
|
||||
import wifi_qrcode_generator.generator
|
||||
|
||||
qr_code = wifi_qrcode_generator.generator.wifi_qrcode(
|
||||
ssid=network_name,
|
||||
hidden=False,
|
||||
authentication_type="WPA",
|
||||
password=password,
|
||||
)
|
||||
|
||||
await ctx.defer()
|
||||
try:
|
||||
file, file_path = tempfile.mkstemp()
|
||||
qr_code.make_image().save(file_path + ".png")
|
||||
return await ctx.send_followup(file=discord.File(file_path + ".png"))
|
||||
os.remove(file_path + ".png")
|
||||
except Exception as e:
|
||||
return await ctx.send_followup(f"Something went wrong,\n{e}")
|
||||
|
||||
@commands.slash_command(
|
||||
guld_ids=None,
|
||||
name="stock",
|
||||
|
@ -10,5 +10,6 @@ markovify
|
||||
openai
|
||||
owotext
|
||||
requests
|
||||
wifi-qrcode-generator
|
||||
wolframalpha
|
||||
yfinance
|
Loading…
x
Reference in New Issue
Block a user