Skip to content

Commit 0e968f1

Browse files
author
Chris
committed
partial wol
1 parent bbc4b72 commit 0e968f1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

source/bot.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from init import *
2-
import pathlib,importlib.util,logging,os,datetime,sys,time,aiofiles,os,aiohttp
3-
import os,traceback
2+
import os,traceback,pathlib,logging,datetime,sys,time,aiofiles,os,aiohttp,urllib.parse,ipaddress
3+
import wol
44
logger = logging.getLogger(os.path.splitext(os.path.basename(__file__))[0])
55
loop = None
66
lastsend = None
@@ -54,6 +54,13 @@ async def tell(room, message):
5454
elif match.is_not_from_this_bot(): #regualr message to bot
5555
for server in servers:
5656
if server.room == room.room_id:
57+
if hasattr(server,'wol'):
58+
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(connect=0.3)) as session:
59+
async with session.post(server.url) as resp:
60+
r = await resp.text
61+
purl = urllib.parse.urlparse(server.url)
62+
net = ipaddress.IPv4Network(purl.host + '/' + '255.255.255.0', False)
63+
wol.WakeOnLan(server.wol,net.broadcast_address)
5764
async with aiohttp.ClientSession() as session:
5865
headers = {"Content-Type": "application/json"}
5966
if hasattr(server,'apikey'):

0 commit comments

Comments
 (0)