OneBotConnecter 0.3.7__tar.gz → 0.3.9__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.7
3
+ Version: 0.3.9
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.07"
7
+ version = "0.3.09"
8
8
  authors = [
9
9
  { name="Sugar51243", email="1733682365@qq.com" },
10
10
  ]
@@ -80,8 +80,6 @@ class OneBot:
80
80
  if self.owner != None: print(f"机器人管理员: {self.owner}")
81
81
  if self.localtion != None: print(f"机器人根目录地址: {self.localtion}")
82
82
  print(f"开始监听机器人信息推送\n")
83
- #持续从接口收取信息
84
- counter = 0
85
83
  while True:
86
84
  #连接失败 => 直到连接成功为止,持续尝试重连
87
85
  if self.bot == None:
@@ -93,7 +91,7 @@ class OneBot:
93
91
  await asyncio.sleep(5)
94
92
  #连接正常
95
93
  if self.bot != None:
96
- print(f"下一轮信息收集[{counter}]", needPrint=self.testMode)
94
+ print(f"下一轮信息收集", needPrint=self.testMode)
97
95
  #从接口收取信息,并进行信息处理
98
96
  task = asyncio.create_task(self._receive_messages(on_message))
99
97
  try:
@@ -102,8 +100,7 @@ class OneBot:
102
100
  #可以不作处理
103
101
  except Exception: pass
104
102
  await asyncio.sleep(sleep_time)
105
- print(f"此轮结束[{counter}]", needPrint=self.testMode)
106
- counter+=1
103
+ print(f"此轮结束\n", needPrint=self.testMode)
107
104
 
108
105
  #收到信息时
109
106
  async def _receive_messages(self, callback: __module__):
@@ -113,7 +110,7 @@ class OneBot:
113
110
  if self.get_message:
114
111
  message = await self.bot.recv()
115
112
  message = json.loads(message)
116
- print(f"获取信息:\n{message}", needPrint=self.testMode)
113
+ print(f"获取信息: {message}", needPrint=self.testMode)
117
114
  #处理 => 缓存
118
115
  try:
119
116
  #识别是否为心跳信息
@@ -132,7 +129,7 @@ class OneBot:
132
129
  while len(self.message_list) > 0:
133
130
  try:
134
131
  message = self.message_list.pop(0)
135
- print(f"正在处理: \n{message}", needPrint=self.testMode)
132
+ print(f"正在处理: {message}", needPrint=self.testMode)
136
133
  await callback(self, message)
137
134
  except Exception as e:
138
135
  tb = e.__traceback__
@@ -178,7 +175,7 @@ class OneBot:
178
175
  #从接口收取信息
179
176
  callback = await self.bot.recv()
180
177
  message = json.loads(callback)
181
- print(f"数据包发送后收取: \n{message}", needPrint=self.testMode)
178
+ print(f"数据包发送后收取: {message}", needPrint=self.testMode)
182
179
  #识别是否为正常信息
183
180
  try:
184
181
  #正常信息 => 缓存
@@ -20,5 +20,6 @@ def print(data: str = "", needPrint = True):
20
20
  #文件写入
21
21
  if not os.path.isdir("log"): os.makedirs("log")
22
22
  file = open(f'log/OneBotConnecter_{current_time}.log', 'a', encoding="utf-8")
23
- file.write(f"{data}\n")
23
+ now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
24
+ file.write(f"[{now}]: {data}\n")
24
25
  file.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: OneBotConnecter
3
- Version: 0.3.7
3
+ Version: 0.3.9
4
4
  Summary: 基于websocket(服务器正向)连接的onebot11通用python接口
5
5
  Author-email: Sugar51243 <1733682365@qq.com>
6
6
  License: MIT License
File without changes