-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathamihot.py
More file actions
26 lines (20 loc) · 726 Bytes
/
amihot.py
File metadata and controls
26 lines (20 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
class Amihot:
def __init__(self, irc):
self.irc = irc
def on_chanmsg(self, from_, chan, msg):
cputemp = Amihot.get_cpu_temp()
if (cputemp == None):
self.irc.privmsg(chan, "Can't determine my hotness...")
else:
self.irc.privmsg(chan, "CPU is at {} \u2103".format(cputemp))
def get_cpu_temp():
try:
with open("/sys/class/thermal/thermal_zone0/temp") as f:
content = str(f.readlines())
temp = float(content.strip('[ ] \' \\n')) / 1000
return format("%.2f" % temp)
except:
return None
def halp(self):
return "!amihot : Get CPU temperature of Pi"