Add command to get UPS status
parent
d2d59fe919
commit
c96351df0b
|
@ -6,3 +6,4 @@ Here is the the list of possible commands at this point in time:
|
|||
!pokeme: make the bot poke you gently
|
||||
!switch: display time until the switch comes out!
|
||||
!wtf: Don't use unless you want a wall of copypasta
|
||||
!ups: Print the status of the main UPS. Updated once a minute.
|
13
pocketbot.py
13
pocketbot.py
|
@ -13,6 +13,14 @@ bot_channel_id = discord.Object(id=config.get("configuration", "bot_channel_id")
|
|||
|
||||
client = discord.Client()
|
||||
|
||||
#Subroutine to get UPS Status
|
||||
@asyncio.coroutine
|
||||
def ups_check():
|
||||
while not client.is_closed:
|
||||
yield from asyncio.create_subprocess_exec("/bin/bash", "/srv/discord-pocketbot/ups_status.sh")
|
||||
yield from asyncio.sleep(60)
|
||||
|
||||
|
||||
@client.event
|
||||
@asyncio.coroutine
|
||||
def on_ready():
|
||||
|
@ -48,7 +56,10 @@ def on_message(message):
|
|||
switchdelta = switchdate - now
|
||||
switchmsg = "<:switchl:283809380137435139>Only **%s** until the Switch comes out!<:switchr:283809391835349004>" % (switchdelta)
|
||||
yield from client.send_message(message.channel, switchmsg)
|
||||
elif message.content.lower().startswith('!ups'):
|
||||
ups_status = open("/tmp/ups_status.txt","r")
|
||||
yield from client.send_message(message.channel, ups_status.read())
|
||||
|
||||
|
||||
|
||||
client.loop.create_task(ups_check())
|
||||
client.run(token)
|
|
@ -0,0 +1,17 @@
|
|||
#=====================================
|
||||
#ups_status.sh |
|
||||
#Version 1.0 |
|
||||
#Written by pocketjawa yo |
|
||||
#http://twitter.com/pocketjawa |
|
||||
#Do what you want (with this script) |
|
||||
#'Cause a pirate is free |
|
||||
#YOU ARE A PIRATE |
|
||||
#=====================================
|
||||
|
||||
#!/bin/sh -u
|
||||
# UTF-8 (international) script header
|
||||
PATH=/bin:/usr/bin ; export PATH # add /sbin and /usr/sbin if needed
|
||||
umask 022 # use 077 for secure scripts
|
||||
unset LC_ALL # unset the over-ride variable
|
||||
|
||||
/sbin/apcaccess |egrep '^DATE|HOSTNAME|MODEL|STATUS|LOADPCT|BCHARGE|TIMELEFT' >/tmp/ups_status.txt
|
Loading…
Reference in New Issue