OneBotConnecter 0.3.4__tar.gz → 0.3.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: OneBotConnecter
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: 基于websocket(服务器正向)连接的onebot11通用python接口
5
5
  Author-email: Sugar51243 <1733682365@qq.com>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "OneBotConnecter"
7
- version = "0.3.04"
7
+ version = "0.3.06"
8
8
  authors = [
9
9
  { name="Sugar51243", email="1733682365@qq.com" },
10
10
  ]
@@ -1,9 +1,14 @@
1
1
  #import
2
+ try:
3
+ from OneBotConnecter.logger import print
4
+ except:
5
+ print("File [logger.py] missing")
6
+ raise Exception("File [logger.py] missing")
2
7
  try:
3
8
  from OneBotConnecter.MessageType import Message, ReplyMessage, AtMessage, MessageChain
4
9
  except:
5
10
  print("File [OneBotMessageType.py] missing")
6
- raise Exception()
11
+ raise Exception("File [OneBotMessageType.py] missing")
7
12
  from typing import Literal
8
13
  import os
9
14
  moduleList = ["traceback", "asyncio", "json", "websockets"]
@@ -60,7 +65,7 @@ class OneBot:
60
65
  if self.bot != None:
61
66
  self.bot = await websockets.connect(self._uri)
62
67
  message = await self.bot.recv() #测试接口可用性
63
- print(f"\n地址{self._uri}连接已完成")
68
+ print(f"地址{self._uri}连接已完成")
64
69
  callback = await self.get_login_info() #更新机器人本体信息
65
70
  if callback == None:
66
71
  print(f"地址{self._uri}连接中断")
@@ -84,6 +89,7 @@ class OneBot:
84
89
  await asyncio.sleep(5)
85
90
  #连接正常
86
91
  if self.bot != None:
92
+ if self.testMode: print("Next Loop")
87
93
  #从接口收取信息,并进行信息处理
88
94
  task = asyncio.create_task(self._receive_messages(on_message))
89
95
  try:
@@ -123,6 +129,7 @@ class OneBot:
123
129
  traceback.print_exc()
124
130
  print("")
125
131
  if self.testMode: print(f"信息列表处理完毕\n")
132
+ if not self.get_message: self.get_message = True
126
133
  #连接失败
127
134
  except websockets.exceptions.ConnectionClosed:
128
135
  print("与机器人连接已断开\n")
@@ -0,0 +1,24 @@
1
+ #引用库
2
+ import time, os
3
+ import builtins as __builtin__
4
+
5
+ #系统时间 => 日志文件名字
6
+ current_time = time.strftime("%Y-%m-%d_%H_%M_%S", time.localtime())
7
+ loger_time = time.strftime("%Y-%m-%d", time.localtime()) #每日轮换文件
8
+
9
+
10
+ #日志写入
11
+ def print(data: str = ""):
12
+ #每日轮换文件
13
+ today = time.strftime("%Y-%m-%d", time.localtime())
14
+ global current_time
15
+ global loger_time
16
+ if today != loger_time:
17
+ loger_time = time.strftime("%Y-%m-%d", time.localtime())
18
+ #后台打印
19
+ __builtin__.print(data)
20
+ #文件写入
21
+ if not os.path.isdir("log"): os.makedirs("log")
22
+ file = open(f'log/OneBotConnecter_{current_time}.log', 'a', encoding="utf-8")
23
+ file.write(f"{data}\n")
24
+ file.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: OneBotConnecter
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: 基于websocket(服务器正向)连接的onebot11通用python接口
5
5
  Author-email: Sugar51243 <1733682365@qq.com>
6
6
  License: MIT License
@@ -4,6 +4,7 @@ pyproject.toml
4
4
  src/OneBotConnecter/MessageType.py
5
5
  src/OneBotConnecter/OneBot.py
6
6
  src/OneBotConnecter/__init__.py
7
+ src/OneBotConnecter/logger.py
7
8
  src/OneBotConnecter.egg-info/PKG-INFO
8
9
  src/OneBotConnecter.egg-info/SOURCES.txt
9
10
  src/OneBotConnecter.egg-info/dependency_links.txt
File without changes