improvements

This commit is contained in:
GandC Snow 2021-10-17 19:22:12 +03:00
parent 3604e52567
commit 4e5ff636ef

16
bot.py
View File

@ -1,5 +1,3 @@
#import sys, irc, subprocess, ssl
#from irc import client, connection
import irc.bot, subprocess
import irc.strings
import psutil, platform
@ -47,11 +45,11 @@ class TestBot(irc.bot.SingleServerIRCBot):
c.notice(nick, "Opers: " + ", ".join(opers))
voiced = sorted(chobj.voiced())
c.notice(nick, "Voiced: " + ", ".join(voiced))
if cmd.lower() == "load":
result = subprocess.run(["uptime" ], stderr=subprocess.PIPE, stdout=subprocess.PIPE) #result.stdout.decode()
if cmd.lower() == "uptime":
result = subprocess.run(["uptime" ], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
output = result.stdout.decode().strip()
res = output[output.find('load average'):]
c.notice(nick, res)
#res = output[output.find('load average'):]
c.notice(nick, output)
if cmd.lower() == "ram":
svmem = psutil.virtual_memory()
@ -61,11 +59,13 @@ class TestBot(irc.bot.SingleServerIRCBot):
percent = psutil.cpu_percent()
end = 'CPU load: ' + str(percent) + '%'
c.notice(nick, end)
if cmd.lower() == "help":
end = 'Available commands are: help, stats, uptime, ram, cpu'
c.notice(nick, end)
def main():
channel = '#notifications'
channel = '#main'
nickname = 'GandCStat'
server = '10.200.201.4'
bot = TestBot(channel, nickname, server)