Add command to get UPS status

pocketjawa 2017-02-24 20:22:55 -05:00
parent d2d59fe919
commit c96351df0b
3 changed files with 31 additions and 2 deletions

View File

@ -5,4 +5,5 @@ Here is the the list of possible commands at this point in time:
!sleep: sleep for like 5 seconds for some reason
!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
!wtf: Don't use unless you want a wall of copypasta
!ups: Print the status of the main UPS. Updated once a minute.

View File

@ -13,6 +13,14 @@ bot_channel_id = discord.Object(id=config.get("configuration", "bot_channel_id")
client = discord.Client()
#Subroutine to get UPS Status
def ups_check():
while not client.is_closed:
yield from asyncio.create_subprocess_exec("/bin/bash", "/srv/discord-pocketbot/")
yield from asyncio.sleep(60)
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(, switchmsg)
elif message.content.lower().startswith('!ups'):
ups_status = open("/tmp/ups_status.txt","r")
yield from client.send_message(,

17 Executable file
View File

@ -0,0 +1,17 @@
#===================================== |
#Version 1.0 |
#Written by pocketjawa yo |
# |
#Do what you want (with this script) |
#'Cause a pirate is free |
#!/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