天气查询插件
This commit is contained in:
@@ -113,7 +113,6 @@ class WeatherPlugin(MessagePluginInterface):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@plugin_stats_decorator(plugin_name="天气查询")
|
@plugin_stats_decorator(plugin_name="天气查询")
|
||||||
@plugin_points_cost(1, "天气查询消耗积分", Feature.UTILITY)
|
|
||||||
async def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
|
async def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
|
||||||
"""处理消息"""
|
"""处理消息"""
|
||||||
content = str(message.get("content", "")).strip()
|
content = str(message.get("content", "")).strip()
|
||||||
@@ -124,7 +123,7 @@ class WeatherPlugin(MessagePluginInterface):
|
|||||||
bot: WechatAPIClient = message.get("bot")
|
bot: WechatAPIClient = message.get("bot")
|
||||||
|
|
||||||
# 检查权限
|
# 检查权限
|
||||||
if roomid and gbm.get_group_permission(roomid, Feature.UTILITY) == PermissionStatus.DISABLED:
|
if roomid and gbm.get_group_permission(roomid, Feature.WEATHER) == PermissionStatus.DISABLED:
|
||||||
return False, "没有权限"
|
return False, "没有权限"
|
||||||
|
|
||||||
# 处理消息内容
|
# 处理消息内容
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from loguru import logger
|
|||||||
# 连接到本地 Redis 服务
|
# 连接到本地 Redis 服务
|
||||||
r = redis.StrictRedis(host='192.168.2.40', port=6379, db=0, decode_responses=True)
|
r = redis.StrictRedis(host='192.168.2.40', port=6379, db=0, decode_responses=True)
|
||||||
|
|
||||||
|
|
||||||
class PermissionStatus(Enum):
|
class PermissionStatus(Enum):
|
||||||
"""权限状态枚举"""
|
"""权限状态枚举"""
|
||||||
ENABLED = "enabled"
|
ENABLED = "enabled"
|
||||||
@@ -45,6 +46,7 @@ class Feature(Enum):
|
|||||||
GROUP_MEMBER_CHANGE = 18, "群成员变更提醒功能"
|
GROUP_MEMBER_CHANGE = 18, "群成员变更提醒功能"
|
||||||
# KID_PHOTO_EXTRACT = 19, "儿童照片提取转发功能" # 小朋友照片提取功能
|
# KID_PHOTO_EXTRACT = 19, "儿童照片提取转发功能" # 小朋友照片提取功能
|
||||||
NEWS = 20, "全球政治经济新闻"
|
NEWS = 20, "全球政治经济新闻"
|
||||||
|
WEATHER = 21, "天气查询"
|
||||||
|
|
||||||
def __new__(cls, value, description):
|
def __new__(cls, value, description):
|
||||||
obj = object.__new__(cls)
|
obj = object.__new__(cls)
|
||||||
@@ -334,7 +336,7 @@ def simulate_commands():
|
|||||||
print(GroupBotManager.get_group_permission(group_id, Feature.AI_CAPABILITY) == PermissionStatus.DISABLED)
|
print(GroupBotManager.get_group_permission(group_id, Feature.AI_CAPABILITY) == PermissionStatus.DISABLED)
|
||||||
|
|
||||||
print(GroupBotManager.get_group_permission(group_id, Feature.SUMMARY_CAPABILITY) == PermissionStatus.ENABLED)
|
print(GroupBotManager.get_group_permission(group_id, Feature.SUMMARY_CAPABILITY) == PermissionStatus.ENABLED)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# 执行模拟命令
|
# 执行模拟命令
|
||||||
|
|||||||
Reference in New Issue
Block a user