Compare commits

..

2 Commits

Author SHA1 Message Date
5544cb02ad
2024-09-02 01:12:55 +08:00
71fe61d9f4
reeee 2024-09-02 01:12:42 +08:00
2 changed files with 42 additions and 8 deletions

View File

@ -3,7 +3,6 @@ import io
import time import time
import requests import requests
import traceback import traceback
import urllib.parse
# import PIL # import PIL
@ -17,7 +16,7 @@ else:
IcaNewMessage = TypeVar("NewMessage") IcaNewMessage = TypeVar("NewMessage")
IcaClient = TypeVar("IcaClient") IcaClient = TypeVar("IcaClient")
_version_ = "2.8.0-rs" _version_ = "2.8.1-rs"
backend_version = "unknown" backend_version = "unknown"
def format_data_size(data_bytes: float) -> str: def format_data_size(data_bytes: float) -> str:
@ -213,6 +212,10 @@ def bmcl_rank_general(msg, client):
client.send_message(reply) client.send_message(reply)
FULL_DISPLAY = 3
MAX_DISPLAY = 20
def bmcl_rank(msg: IcaNewMessage, client: IcaClient | TailchatClient, name: str) -> None: def bmcl_rank(msg: IcaNewMessage, client: IcaClient | TailchatClient, name: str) -> None:
req_time = time.time() req_time = time.time()
# 记录请求时间 # 记录请求时间
@ -237,8 +240,8 @@ def bmcl_rank(msg: IcaNewMessage, client: IcaClient | TailchatClient, name: str)
# 如果找到 > 3 个节点, 则提示 不显示 # 如果找到 > 3 个节点, 则提示 不显示
counts = [f for f in finds if f] counts = [f for f in finds if f]
ranks = [rank_data[i] for i, f in enumerate(finds) if f] ranks = [rank_data[i] for i, f in enumerate(finds) if f]
if len(counts) > 3: if len(counts) > FULL_DISPLAY:
if len(counts) > 10: if len(counts) > MAX_DISPLAY:
reply = msg.reply_with(f"搜索|{name}|到{len(counts)}个节点, 请用更精确的名字") reply = msg.reply_with(f"搜索|{name}|到{len(counts)}个节点, 请用更精确的名字")
else: else:
# 4~10 个节点 只显示名称和次序 # 4~10 个节点 只显示名称和次序
@ -273,14 +276,14 @@ def bmcl_rank(msg: IcaNewMessage, client: IcaClient | TailchatClient, name: str)
# client.send_message(reply) # client.send_message(reply)
help = """/bmcl -> dashboard help = f"""/bmcl -> dashboard
/bmcl rank -> all rank /bmcl rank -> all rank
/bmcl rank <name> -> rank of <name> /bmcl rank <name> -> rank of <name>
/brrs <name> -> rank of <name> /brrs <name> -> rank of <name>
搜索限制: 搜索限制:
1- 3 显示全部信息 1- {FULL_DISPLAY} 显示全部信息
4-10 显示状态名称 {FULL_DISPLAY+1}-{MAX_DISPLAY} 显示状态名称
11+ 不显示 {MAX_DISPLAY+1}+ 不显示
""" """
# /bm93 -> 随机怪图 # /bm93 -> 随机怪图

31
plugins/re_send.py Normal file
View File

@ -0,0 +1,31 @@
from __future__ import annotations
from typing import TYPE_CHECKING, TypeVar
if TYPE_CHECKING:
from ica_typing import IcaNewMessage, IcaClient
from ica_typing import TailchatReciveMessage, TailchatClient
else:
IcaNewMessage = TypeVar("NewMessage")
IcaClient = TypeVar("IcaClient")
TailchatReciveMessage = TypeVar("TailchatReciveMessage")
TailchatClient = TypeVar("TailchatClient")
TC_client: TailchatClient | None = None
TC_msg: TailchatReciveMessage | None = None
def on_tailchat_message(msg: TailchatReciveMessage, client: TailchatClient) -> None:
global TC_client, TC_msg
TC_client = client
if msg.is_reply or msg.is_from_self:
return
if msg.content == "/send-here":
TC_msg = msg
def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None:
if TC_client is None or TC_msg is None:
return
reply = TC_msg.reply_with(f"From ICA:|{msg.room_id}|{msg.sender_id}|{msg.sender_name}|{msg.content}")
TC_client.send_message(reply)