Adding wifi qr code generator to dale bot
This commit is contained in:
parent
baa1254e99
commit
793f254477
@ -1,7 +1,8 @@
|
|||||||
from discord.ext import commands
|
|
||||||
from discord import option
|
from discord import option
|
||||||
|
from discord.ext import commands
|
||||||
import discord
|
import discord
|
||||||
import os
|
import os
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
class ActualUtils(commands.Cog):
|
class ActualUtils(commands.Cog):
|
||||||
@ -107,6 +108,38 @@ class ActualUtils(commands.Cog):
|
|||||||
except Exception:
|
except Exception:
|
||||||
return await ctx.send_followup("Sorry, I'm unable to answer that")
|
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(
|
@commands.slash_command(
|
||||||
guld_ids=None,
|
guld_ids=None,
|
||||||
name="stock",
|
name="stock",
|
||||||
|
@ -10,5 +10,6 @@ markovify
|
|||||||
openai
|
openai
|
||||||
owotext
|
owotext
|
||||||
requests
|
requests
|
||||||
|
wifi-qrcode-generator
|
||||||
wolframalpha
|
wolframalpha
|
||||||
yfinance
|
yfinance
|
Loading…
x
Reference in New Issue
Block a user