Added new commands
This commit is contained in:
1 parent
4e5ff636ef
commit
53e7c01a3c
2 files changed
+52
-3
No files matched your search
@@ -0,0 +1,21 @@
|
|||||||
|
Info bot
|
||||||
|
========
|
||||||
|
Statbot -- это irc бот, который может рассказать вам о загруженности вашего пк.
|
||||||
|
|
||||||
|
|
||||||
|
installing
|
||||||
|
----------
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip3 install irc psutil
|
||||||
|
```
|
||||||
|
|
||||||
|
Using
|
||||||
|
-----
|
||||||
|
```bash
|
||||||
|
python3 bot.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Commands
|
||||||
|
--------
|
||||||
|
Всего доступно 7 команд: help, stats, uptime, ram, cpu, uname, network. По желанию вы можете добавить свои.
|
||||||
@@ -51,16 +51,44 @@ class TestBot(irc.bot.SingleServerIRCBot):
|
|||||||
#res = output[output.find('load average'):]
|
#res = output[output.find('load average'):]
|
||||||
c.notice(nick, output)
|
c.notice(nick, output)
|
||||||
|
|
||||||
|
if cmd.lower() == "uname":
|
||||||
|
#>>> print(f"Version: {uname.version}")
|
||||||
|
#Version: #1 SMP Debian 4.19.208-1 (2021-09-29)
|
||||||
|
uname = platform.uname()
|
||||||
|
end = 'System name:' + uname.version
|
||||||
|
c.notice(nick, end)
|
||||||
|
|
||||||
|
|
||||||
if cmd.lower() == "ram":
|
if cmd.lower() == "ram":
|
||||||
svmem = psutil.virtual_memory()
|
svmem = psutil.virtual_memory()
|
||||||
end = 'Used Ram: '+ get_size(svmem.used)
|
total = 'Total RAM:' + get_size(svmem.total)
|
||||||
c.notice(nick, end)
|
used = 'Used Ram: '+ get_size(svmem.used)
|
||||||
|
percentage ='Percent:' + str(svmem.percent) + '%'
|
||||||
|
avail = 'Available:' + get_size(svmem.available)
|
||||||
|
c.notice(nick, total)
|
||||||
|
c.notice(nick, avail)
|
||||||
|
c.notice(nick, used)
|
||||||
|
c.notice(nick, percentage)
|
||||||
if cmd.lower() == "cpu":
|
if cmd.lower() == "cpu":
|
||||||
percent = psutil.cpu_percent()
|
percent = psutil.cpu_percent()
|
||||||
end = 'CPU load: ' + str(percent) + '%'
|
end = 'CPU load: ' + str(percent) + '%'
|
||||||
c.notice(nick, end)
|
c.notice(nick, end)
|
||||||
|
|
||||||
|
if cmd.lower() == "network":
|
||||||
|
if_addrs = psutil.net_if_addrs()
|
||||||
|
for interface_name, interface_addresses in if_addrs.items():
|
||||||
|
for address in interface_addresses:
|
||||||
|
#print(f"=== Interface: {interface_name} ===")
|
||||||
|
header = 'Interface:' + interface_name
|
||||||
|
c.notice(nick, header)
|
||||||
|
if str(address.family) == 'AddressFamily.AF_INET':
|
||||||
|
IP = 'IP Address:' + address.address
|
||||||
|
mask = 'Netmask:' + address.netmask
|
||||||
|
c.notice(nick, IP)
|
||||||
|
c.notice(nick, mask)
|
||||||
|
|
||||||
if cmd.lower() == "help":
|
if cmd.lower() == "help":
|
||||||
end = 'Available commands are: help, stats, uptime, ram, cpu'
|
end = 'Available commands are: help, stats, uptime, ram, cpu, uname, network'
|
||||||
c.notice(nick, end)
|
c.notice(nick, end)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user