Skip to content

Commit

Permalink
Merge pull request #679 from RockChinQ/feat/botpy-qq
Browse files Browse the repository at this point in the history
Feat: 接入 QQ 官方 API
  • Loading branch information
RockChinQ authored Feb 7, 2024
2 parents 71b54fd + 7366ca5 commit cf58348
Show file tree
Hide file tree
Showing 8 changed files with 414 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ bard.json
!/docker-compose.yaml
res/instance_id.json
.DS_Store
/data
/data
botpy.log
1 change: 1 addition & 0 deletions pkg/audit/center/apigroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def _do(
headers: dict = {},
**kwargs
):
self._runtime_info['account_id'] = "{}".format(self.ap.im_mgr.bot_account_id)

url = self.prefix + path
data = json.dumps(data)
Expand Down
2 changes: 0 additions & 2 deletions pkg/command/cmdmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ async def execute(

if f'{query.launcher_type.value}_{query.launcher_id}' in self.ap.system_cfg.data['admin-sessions']:
privilege = 2

print(f'privilege: {privilege}')

ctx = entities.ExecuteContext(
query=query,
Expand Down
18 changes: 6 additions & 12 deletions pkg/platform/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@ async def initialize(self):

aiocqhttp_config = self.ap.platform_cfg.data['aiocqhttp-config']
self.adapter = AiocqhttpAdapter(aiocqhttp_config, self.ap)
# elif config['msg_source_adapter'] == 'nakuru':
# from pkg.platform.sources.nakuru import NakuruProjectAdapter
# self.adapter = NakuruProjectAdapter(config['nakuru_config'])
# self.bot_account_id = self.adapter.bot_account_id

# 保存 account_id 到审计模块
from ..audit.center import apigroup
apigroup.APIGroup._runtime_info['account_id'] = "{}".format(self.bot_account_id)
elif self.ap.platform_cfg.data['platform-adapter'] == 'qq-botpy':
from pkg.platform.sources.qqbotpy import OfficialAdapter

qqbotpy_config = self.ap.platform_cfg.data['qq-botpy-config']
self.adapter = OfficialAdapter(qqbotpy_config, self.ap)

async def on_friend_message(event: FriendMessage):

Expand Down Expand Up @@ -137,10 +134,7 @@ async def on_group_message(event: GroupMessage):
async def send(self, event, msg, check_quote=True, check_at_sender=True):

if check_at_sender and self.ap.platform_cfg.data['at-sender'] and isinstance(event, GroupMessage):
msg.insert(
0,
Plain(" \n")
)

msg.insert(
0,
At(
Expand Down
1 change: 1 addition & 0 deletions pkg/platform/sources/aiocqhttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def __init__(self, config: dict, ap: app.Application):
async def send_message(
self, target_type: str, target_id: str, message: mirai.MessageChain
):
# TODO 实现发送消息
return super().send_message(target_type, target_id, message)

async def reply_message(
Expand Down
Loading

0 comments on commit cf58348

Please sign in to comment.