feat : 接入服务器信息 上下文传指令参 嵌入文本md
This commit is contained in:
@@ -6,9 +6,10 @@ from botpy.message import (Message,GroupMessage)
|
||||
from botpy.flags import (Flag,fill_with_flags)
|
||||
from botpy import( logger,Intents,Client)
|
||||
from botpy.gateway import (BotWebSocket)
|
||||
from botpy.types.gateway import MessagePayload
|
||||
from botpy.types.gateway import (MessagePayload)
|
||||
import queue
|
||||
from botpy.types.session import Session
|
||||
from botpy.types.message import MarkdownPayload
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
import types
|
||||
@@ -16,6 +17,7 @@ from bobby import bobbySession
|
||||
from mcwatcher import watcher
|
||||
from threading import Thread
|
||||
import asyncio
|
||||
from serverGET import ServerGet
|
||||
#环境配置
|
||||
|
||||
class Intents_ex(Intents):
|
||||
@@ -114,20 +116,23 @@ class djtuWebsocket (Client) :
|
||||
self.group_add(msg.group_openid)
|
||||
commands:dict[str,types.MethodType|types.FunctionType] = {
|
||||
r'/邀请码' : bobby.getInviteCode,
|
||||
r'吃什么' : lambda :"是啊吃什么"
|
||||
r'吃什么' : lambda ctx:"是啊吃什么" ,
|
||||
r'/服务器' : ServerGet.GetNames,
|
||||
}
|
||||
required = msg.content
|
||||
reply = ""
|
||||
for cmd,func in commands.items():
|
||||
if required.find(cmd) != -1:
|
||||
try:
|
||||
reply = func()
|
||||
ctx = required.split(cmd)[1]
|
||||
reply = func(ctx)
|
||||
except:
|
||||
reply = "服务异常"
|
||||
break
|
||||
if reply.__len__() == 0:
|
||||
reply = "你在发什么东西我怎么看不懂?"
|
||||
await msg.reply(content=reply)
|
||||
md = MarkdownPayload(content=reply)
|
||||
await msg.reply(msg_type=2, markdown=md)
|
||||
|
||||
def group_add(self,gid :str):
|
||||
# 加入群聊
|
||||
|
||||
Reference in New Issue
Block a user