新增功能菜单。
This commit is contained in:
28
utils/ai/pollinations_ai.py
Normal file
28
utils/ai/pollinations_ai.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import requests
|
||||
import urllib.parse
|
||||
|
||||
prompt = "创作一幅超照片级的亚洲美女单人自拍肖像,仿若用高端智能手机(如iPhone 16 Pro或同等设备)拍摄。她具有[光泽柔顺的黑色波浪长发、杏仁状深棕色眼睛带细致虹膜纹理、光滑瓷白皮肤带微妙自然瑕疵、自信迷人的微笑]。自拍在[时尚的城市屋顶夜景灯光]中拍摄。她穿着[修身丝质连衣裙带微妙领口],散发优雅且微妙的性感气质。构图模仿自然自拍角度,面部略微偏离中心,持相机角度自然讨巧,姿势优雅放松,凸显魅力。皮肤、头发和眼睛的纹理超现实,包含细致细节如单根发丝、微小皮肤毛孔和眼中真实反射。光线自然动态,带有柔和阴影和高光,模仿现实世界条件(如黄金时段阳光或室内环境光),突出她的特征。表情自信迷人,带有随性、栩栩如生的氛围。背景清晰但自然模糊(浅景深效果,f/1.8光圈)。完全避免油画感、艺术化风格、笔触、卡通化元素,不要呈现文字或任何数字瑕疵。输出为高分辨率,超详细,与真实高分辨率照片无异。"
|
||||
params = {
|
||||
"width": 1080,
|
||||
"height": 1920,
|
||||
"seed": 44,
|
||||
"model": "flux",
|
||||
"nologo": "true", # Optional
|
||||
# "transparent": "true", # Optional - generates transparent background (gptimage model only)
|
||||
# "referrer": "MyPythonApp" # Optional
|
||||
}
|
||||
encoded_prompt = urllib.parse.quote(prompt)
|
||||
url = f"https://image.pollinations.ai/prompt/{encoded_prompt}"
|
||||
|
||||
try:
|
||||
response = requests.get(url, params=params, timeout=300) # Increased timeout for image generation
|
||||
response.raise_for_status() # Raise an exception for bad status codes
|
||||
|
||||
with open('generated_image.jpg', 'wb') as f:
|
||||
f.write(response.content)
|
||||
print("Image saved as generated_image.jpg")
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"Error fetching image: {e}")
|
||||
# Consider checking response.text for error messages from the API
|
||||
# if response is not None: print(response.text)
|
||||
@@ -155,18 +155,10 @@ class GroupBotManager:
|
||||
@staticmethod
|
||||
def handle_command(group_id, command_str):
|
||||
"""统一处理群功能指令"""
|
||||
# print(f"PermissionStatus handle_command command_str: {command_str}")
|
||||
# print(f"PermissionStatus robot_menu command_str: {command_str}")
|
||||
# 命令解析
|
||||
command_parts = command_str.strip().split("-")
|
||||
|
||||
# 如果是MENU指令,返回功能列表
|
||||
if command_str.strip().upper() == "菜单":
|
||||
return f"群ID:{group_id} \n {GroupBotManager.get_enabled_features(group_id)}"
|
||||
|
||||
# 如果是MENU-STATUS指令,返回功能列表及其状态
|
||||
if command_str.strip().upper() == "菜单状态":
|
||||
return f"群ID:{group_id} \n {GroupBotManager.display_menu_status(group_id)}"
|
||||
|
||||
# 如果是GROUP_LIST指令,返回 group:list 清单
|
||||
if command_str.strip().upper() == "群列表":
|
||||
return GroupBotManager.get_group_list()
|
||||
@@ -239,53 +231,6 @@ class GroupBotManager:
|
||||
permissions[feature] = status if status else PermissionStatus.DISABLED # 默认为禁用状态
|
||||
return permissions
|
||||
|
||||
@staticmethod
|
||||
def display_menu():
|
||||
"""显示所有功能列表及其当前状态"""
|
||||
menu = []
|
||||
for feature in Feature:
|
||||
menu.append(f"{feature.value}. {feature.description}")
|
||||
return "\n".join(menu)
|
||||
|
||||
@staticmethod
|
||||
def get_enabled_features(group_id):
|
||||
"""获取某个群已启用的功能列表及其描述,并返回格式化的字符串
|
||||
只返回描述中包含指令(方括号[])的功能
|
||||
|
||||
Args:
|
||||
group_id: 群ID
|
||||
|
||||
Returns:
|
||||
str: 格式化的已启用功能列表字符串
|
||||
"""
|
||||
enabled_features = []
|
||||
|
||||
# 检查群是否在列表中
|
||||
if group_id not in GroupBotManager.local_cache["group_list"]:
|
||||
return "该群未启用机器人功能"
|
||||
|
||||
# 遍历所有功能,检查哪些已启用且包含指令
|
||||
for feature in Feature:
|
||||
status = GroupBotManager.get_group_permission(group_id, feature)
|
||||
# 只添加已启用且描述中包含方括号的功能
|
||||
if status == PermissionStatus.ENABLED and "[" in feature.description and "]" in feature.description:
|
||||
enabled_features.append({
|
||||
"id": feature.value,
|
||||
"name": feature.name,
|
||||
"description": feature.description
|
||||
})
|
||||
|
||||
# 如果没有启用任何带指令的功能
|
||||
if not enabled_features:
|
||||
return "该群未启用任何带指令的功能"
|
||||
|
||||
# 构建格式化的字符串
|
||||
result = f"不支持@交互,请通过指令触发\n 群功能菜单:\n"
|
||||
for feature in enabled_features:
|
||||
result += f"{feature['id']}.{feature['description']}\n"
|
||||
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def get_group_list():
|
||||
"""返回所有启用了群机器人的群组清单,格式为集合"""
|
||||
|
||||
Reference in New Issue
Block a user