add WOL to allow waking stable diffusion
This commit is contained in:
parent
1ceebed52f
commit
b1645bc968
1 changed files with 33 additions and 0 deletions
33
cogs/wake_on_lan.py
Normal file
33
cogs/wake_on_lan.py
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
import wakeonlan
|
||||||
|
|
||||||
|
|
||||||
|
class WakeOnLan(commands.Cog):
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
self.admin_id = 242018983241318410
|
||||||
|
self.logger = logging.getLogger("bot")
|
||||||
|
self.mac_address = "9C-6B-00-38-08-8D"
|
||||||
|
|
||||||
|
def wake_on_lan(self, mac_address):
|
||||||
|
self.logger.info(f"WakeOnLan: Waking up {mac_address}")
|
||||||
|
wakeonlan.send_magic_packet(mac_address)
|
||||||
|
|
||||||
|
def sleep_on_lan(self, mac_address):
|
||||||
|
self.logger.info(f"WakeOnLan: Sleeping {mac_address}")
|
||||||
|
wakeonlan.send_magic_packet(mac_address, magic_packet="000000000000")
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def wake(self, ctx):
|
||||||
|
if ctx.author.id != self.admin_id:
|
||||||
|
return
|
||||||
|
self.wake_on_lan(self.mac_address)
|
||||||
|
await ctx.send(f"Waking up !imagine server")
|
||||||
|
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(WakeOnLan(bot))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue