Skip to content

Commit

Permalink
Merge pull request #1 from idoknow/fix-get-login-info-401
Browse files Browse the repository at this point in the history
[Fix] 修复get_login_info的401未鉴权问题、sendPrivateForwardMsg接口支持
  • Loading branch information
RockChinQ authored Apr 24, 2023
2 parents 441cdc5 + a7156c7 commit 58c5505
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
__pycache__
__pycache__
dist/*
test_*
File renamed without changes.
File renamed without changes
17 changes: 16 additions & 1 deletion nakuru/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ async def sendGroupForwardMessage(self,
if result["status"] == "ok":
return BotMessage.parse_obj(result["data"])
return False

async def sendPrivateForwardMessage(self,
user_id: int,
messages: list) -> T.Union[BotMessage, bool]:
for i in range(len(messages)):
if isinstance(messages[i], Node):
messages[i] = messages[i].toDict()

result = await fetch.http_post(f"{self.baseurl_http}/send_private_forward_msg", {
"user_id": user_id,
"messages": messages
}, params=self.protocol_params)
if result["status"] == "ok":
return BotMessage.parse_obj(result["data"])
return False

async def recall(self, message_id: int) -> bool:
result = await fetch.http_post(f"{self.baseurl_http}/delete_msg", {
Expand Down Expand Up @@ -255,7 +270,7 @@ async def setGroupRequest(self,
return False

async def getLoginInfo(self) -> T.Union[Bot, bool]:
result = await fetch.http_post(f"{self.baseurl_http}/get_login_info")
result = await fetch.http_post(f"{self.baseurl_http}/get_login_info", params=self.protocol_params)
if result["status"] == "ok":
return Bot.parse_obj(result["data"])
return False
Expand Down
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "nakuru-project-idk"
version = "0.0.1"
authors = [
{ name="Lxns-Network", email="[email protected]" },
]
description = "一款为 go-cqhttp 的正向 WebSocket 设计的 Python SDK,支持纯 CQ 码与消息链的转换处理"
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"aiohttp",
"pydantic",
"Logbook",
"async_lru"
]

[project.urls]
"Homepage" = "https://github.com/idoknow/nakuru-project-idk"
"Bug Tracker" = "https://github.com/idoknow/nakuru-project-idk/issues"

0 comments on commit 58c5505

Please sign in to comment.