fine
This commit is contained in:
parent
778e4ec410
commit
225ae7ac71
@ -1,6 +1,7 @@
|
|||||||
import io
|
import io
|
||||||
import psutil
|
import psutil
|
||||||
import platform
|
import platform
|
||||||
|
from pathlib import Path
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from typing import TYPE_CHECKING, TypeVar
|
from typing import TYPE_CHECKING, TypeVar
|
||||||
from PIL import (Image, ImageDraw, ImageFont)
|
from PIL import (Image, ImageDraw, ImageFont)
|
||||||
@ -36,17 +37,18 @@ def local_env_info() -> str:
|
|||||||
cache.write("内存: 未知\n")
|
cache.write("内存: 未知\n")
|
||||||
return cache.getvalue()
|
return cache.getvalue()
|
||||||
|
|
||||||
def local_env_image() -> bytes:
|
# def local_env_image() -> bytes:
|
||||||
img = Image.new("RGB", (800, 140), (255, 255, 255))
|
# print(Path.cwd())
|
||||||
# 往图片上写入一些信息
|
# img = Image.new("RGB", (800, 140), (255, 255, 255))
|
||||||
draw = ImageDraw.Draw(img)
|
# # 往图片上写入一些信息
|
||||||
font = ImageFont.truetype("./SMILEYSANS-OBLIQUE.TTF", size=25)
|
# draw = ImageDraw.Draw(img)
|
||||||
draw.text((10, 10), local_env_info(), fill=(0, 0, 0), font=font)
|
# font = ImageFont.truetype("SMILEYSANS-OBLIQUE.TTF", size=25)
|
||||||
img_cache = io.BytesIO()
|
# draw.text((10, 10), local_env_info(), fill=(0, 0, 0), font=font)
|
||||||
img.save(img_cache, format="PNG")
|
# img_cache = io.BytesIO()
|
||||||
raw_img = img_cache.getvalue()
|
# img.save(img_cache, format="PNG")
|
||||||
img_cache.close()
|
# raw_img = img_cache.getvalue()
|
||||||
return raw_img
|
# img_cache.close()
|
||||||
|
# return raw_img
|
||||||
|
|
||||||
def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None:
|
def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None:
|
||||||
if not (msg.is_from_self or msg.is_reply):
|
if not (msg.is_from_self or msg.is_reply):
|
||||||
@ -56,7 +58,7 @@ def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None:
|
|||||||
elif msg.content == "/bot-sys":
|
elif msg.content == "/bot-sys":
|
||||||
datas = local_env_info()
|
datas = local_env_info()
|
||||||
reply = msg.reply_with(datas)
|
reply = msg.reply_with(datas)
|
||||||
reply.set_img(local_env_image(), "image/png", False)
|
# reply.set_img(local_env_image(), "image/png", False)
|
||||||
client.send_message(reply)
|
client.send_message(reply)
|
||||||
elif msg.content == "/bot-uptime":
|
elif msg.content == "/bot-uptime":
|
||||||
uptime = client.startup_time
|
uptime = client.startup_time
|
||||||
@ -73,7 +75,7 @@ def on_tailchat_message(msg: TailchatReciveMessage, client: TailchatClient) -> N
|
|||||||
elif msg.content == "/bot-sys":
|
elif msg.content == "/bot-sys":
|
||||||
datas = local_env_info()
|
datas = local_env_info()
|
||||||
reply = msg.reply_with(datas)
|
reply = msg.reply_with(datas)
|
||||||
reply.set_img(local_env_image(), "just_img.png")
|
# reply.set_img(local_env_image(), "just_img.png")
|
||||||
client.send_message(reply)
|
client.send_message(reply)
|
||||||
elif msg.content == "/bot-uptime":
|
elif msg.content == "/bot-uptime":
|
||||||
uptime = client.startup_time
|
uptime = client.startup_time
|
||||||
|
Loading…
Reference in New Issue
Block a user