Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
a645162 committed Jul 29, 2024
1 parent 459688e commit 2a67f69
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Group Center(https://github.com/a645162/group-center) Client

[GitHub](https://github.com/a645162/group-center-client)

[PyPI](https://pypi.org/project/li-group-center/)

## Struct

- [x] Python Package For Group Center Client
Expand Down
2 changes: 1 addition & 1 deletion config/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from config import global_config

__version__ = "1.6.0"
__version__ = "1.7.0"


def get_version_path() -> str:
Expand Down
16 changes: 8 additions & 8 deletions group_center/core/feature/machine_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import threading
import time
from queue import Queue
from typing import Tuple

import requests

Expand All @@ -14,7 +13,12 @@
def send_dict_to_center(data: dict, target: str) -> bool:
url = group_center_machine.group_center_get_url(target_api=target)
try:
response = requests.post(url, json=data, timeout=10)
response = requests.post(
url=url,
params=group_center_machine.get_public_part(),
json=data,
timeout=10
)

response_dict: dict = json.loads(response.text)

Expand All @@ -37,7 +41,7 @@ def send_dict_to_center(data: dict, target: str) -> bool:
return False


task_queue: Queue[Tuple[dict, str]] = Queue()
task_queue: Queue = Queue()


class GroupCenterWorkThread(threading.Thread):
Expand All @@ -54,11 +58,7 @@ def run(self):

try:
data, target = task_queue.get(timeout=10)
final_data = {
**group_center_machine.get_public_part(),
**data,
}
if send_dict_to_center(data=final_data, target=target):
if send_dict_to_center(data=data, target=target):
task_queue.task_done()
else:
# 发送失败,将任务放回队列,以便重试
Expand Down
4 changes: 4 additions & 0 deletions group_center/core/feature/machine_user_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ def machine_user_message_directly(
}

new_message_enqueue(data_dict, "/api/client/user/message")


if __name__ == "__main__":
machine_user_message_directly("konghaomin", "test")

0 comments on commit 2a67f69

Please sign in to comment.