dcchbot 1.9__py3-none-any.whl → 1.9.3__py3-none-any.whl

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.
dcchbot/__init__.py CHANGED
@@ -1,5 +1,6 @@
1
1
  #init
2
2
  from .main import run
3
- print("Discord chinese bot v1.9 ok")
3
+ cu_ver = "1.9.3"
4
+ print(f"Discord chinese bot v{cu_ver} ok")
4
5
  print("by I_am_from_taiwan")
5
6
  run()
dcchbot/main.py CHANGED
@@ -1,23 +1,37 @@
1
- # v1.9 main.py
1
+ # v1.9.1 main.py
2
2
  import logging
3
3
  import os
4
4
  import queue
5
5
  import threading
6
6
  import time
7
- import traceback
7
+ import traceback as tb
8
8
  from datetime import datetime, timedelta
9
9
  import requests
10
10
  import discord
11
11
  from discord import app_commands
12
12
  from discord.ext import commands
13
13
  from discord.utils import utcnow
14
-
15
- """v1.9"""
14
+ import random as rd
16
15
  package = "dcchbot"
17
- url = "https://evan0708.rf.gd/pypi-backup/json"
18
- data = requests.get(url).json()
19
- API_URL = "https://evan0708.rf.gd/pypi-backup/json"
20
- latest_version = data["info"]["version"]
16
+ CURRENT_VERSION = "1.9.3"
17
+ API_URL = f"https://pypi.org/pypi/{package}/json"
18
+ test = rd.random()
19
+ ttt = time.time()
20
+ tb = tb
21
+ try:
22
+ response = requests.get(API_URL, timeout=5)
23
+ response.raise_for_status() # HTTP 錯誤會直接丟例外
24
+ data = response.json()
25
+ latest_version = data["info"]["version"]
26
+
27
+ if latest_version != CURRENT_VERSION:
28
+ print(f"⚠ 有新版本可用: {latest_version}(目前版本 {CURRENT_VERSION})")
29
+ else:
30
+ print(f"✅ 目前已是最新版 {CURRENT_VERSION}")
31
+
32
+ except Exception as e:
33
+ latest_version = CURRENT_VERSION # 失敗時至少不讓變數缺失
34
+ print(f"❌ 無法檢查更新:{e}")
21
35
  # ─── 全域參數 ─────────────────────────────────────────
22
36
  OWNER_ID = None
23
37
  LOG_CHANNEL_ID = None
@@ -25,11 +39,9 @@ token = None
25
39
  bot: commands.Bot | None = None
26
40
  CODER_ID = 1317800611441283139
27
41
  _now = datetime.now()
28
- tmp_owner_id = None
29
- tmp_log_channel_id = None
30
42
  # thread-safe queue 用於在任意 thread 放 log,並由 bot loop 背景 worker 傳送到 Discord
31
43
  _log_queue: "queue.Queue[str]" = queue.Queue()
32
- now_version = "1.9"
44
+ now_version = "1.9.1"
33
45
  # ─── Logging 設定 ────────────────────────────────────
34
46
  os.makedirs("logs", exist_ok=True)
35
47
  logging.basicConfig(
@@ -96,23 +108,25 @@ async def _discord_log_worker(bot_instance: commands.Bot, channel_id: int):
96
108
 
97
109
  # ─── Bot 程式主體與指令 ─────────────────────────────────
98
110
  def run():
99
- global OWNER_ID, LOG_CHANNEL_ID, token, bot,tmp_owner_id,tmp_log_channel_id
111
+ global OWNER_ID, LOG_CHANNEL_ID, token, bot
100
112
 
101
113
  # 互動式輸入(你也可以改成從環境變數讀取)
102
- tmp_owner_id = input("請輸入你的 Discord User ID:\n> ").strip()
103
- if isinstance(tmp_owner_id,int):
104
- OWNER_ID = tmp_owner_id
105
- tmp_owner_id = None
106
- else:
107
- print("格式錯誤,請重新輸入")
108
- logger.error("E:vError ownerid")
109
- tmp_log_channel_id = input("請輸入你的 Log 頻道 ID:\n> ").strip()
110
- if isinstance(tmp_log_channel_id,int):
111
- LOG_CHANNEL_ID = tmp_log_channel_id
112
- tmp_log_channel_id = None
113
- else:
114
- print("格式錯誤,請重新輸入")
115
- logger.error("E:vError channelid")
114
+ while True:
115
+ OWNER_ID = input("請輸入你的 Discord User ID:\n> ").strip()
116
+ if not OWNER_ID or not str(OWNER_ID).isdigit():
117
+ print("格式錯誤,請重新輸入")
118
+ logger.error("E:vError ownerid")
119
+ else:
120
+ OWNER_ID=int(OWNER_ID)
121
+ break
122
+ while True:
123
+ LOG_CHANNEL_ID = input("請輸入你的 Log 頻道 ID:\n> ").strip()
124
+ if not LOG_CHANNEL_ID or not str(LOG_CHANNEL_ID).isdigit():
125
+ print("格式錯誤,請重新輸入")
126
+ logger.error("E:vError channelid")
127
+ else:
128
+ LOG_CHANNEL_ID = int(LOG_CHANNEL_ID)
129
+ break
116
130
  token = input("請輸入你的 Discord Bot Token:\n> ").strip()
117
131
 
118
132
  intents = discord.Intents.all()
@@ -293,14 +307,14 @@ def run():
293
307
 
294
308
  @bot.tree.command(name="version", description="顯示機器人版本")
295
309
  async def version(interaction: discord.Interaction):
296
- await interaction.response.send_message("dcchbot 1.9")
310
+ await interaction.response.send_message(f"dcchbot {CURRENT_VERSION}")
297
311
  @bot.tree.command(name="bot-check-update",description="檢查更新")
298
312
  async def getnewestversion(interaction: discord.Interaction):
299
313
  if not is_admin:
300
314
  return await interaction.response.send_message("你沒有權限執行此指令。", ephemeral=True)
301
315
  else:
302
- if latest_version != now_version:
303
- await interaction.response.send_message(f"最新版本是{latest_version}現版本為{now_version},請更新")
316
+ if latest_version != CURRENT_VERSION:
317
+ await interaction.response.send_message(f"最新版本是{latest_version}現版本為{CURRENT_VERSION},請更新")
304
318
  else:
305
319
  await interaction.response.send_message("已是最新版本")
306
320
  @bot.tree.command(name="bot-update",description="更新")
@@ -340,7 +354,7 @@ def run():
340
354
  logger.info(f"[Shell 輸入] {cmd}")
341
355
  enqueue_log(f"[Shell] {cmd}")
342
356
  if cmd == "!!help":
343
- print("可用指令:!!token-display / !!token-reset / !!id-reset-owner / !!id-display-owner / !!id-reset-logch / !!id-display-logch / !!log / !!reload / !!exit")
357
+ print("可用指令:!!token-display / !!token-reset / !!id-reset-owner / !!id-display-owner / !!id-reset-logch / !!id-display-logch / !!log / !!reload / !!exit/!!check-version-dont-update/!!check-version-and-update")
344
358
  elif cmd == "!!token-display":
345
359
  print(f"token: {token}")
346
360
  elif cmd == "!!token-reset":
@@ -378,6 +392,20 @@ def run():
378
392
  bot.loop.create_task(_reload())
379
393
  else:
380
394
  print("Bot 尚未就緒,無法重新載入。")
395
+ elif cmd == "!!check-version-dont-update":
396
+ if latest_version != CURRENT_VERSION:
397
+ print(f"最新版本是{latest_version}現版本為{CURRENT_VERSION},請更新")
398
+ else:
399
+ print("已是最新版本")
400
+ elif cmd == "!!check-version-and-update":
401
+ if latest_version != now_version:
402
+ print(f"正在更新到{latest_version}")
403
+ os.system(f"pip install dcchbot=={latest_version}")
404
+ print("更新成功,將會重啟機器人")
405
+ bot.close()
406
+ os.system("dcchbot")
407
+ else:
408
+ print("已是最新版本")
381
409
  elif cmd == "!!exit":
382
410
  logger.info("Shell 要求關閉 bot")
383
411
  enqueue_log("Shell 關閉機器人")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dcchbot
3
- Version: 1.9
3
+ Version: 1.9.3
4
4
  Summary: 一個簡單的中文 Discord 管理機器人,支援 GUI 按鈕封鎖/禁言/警告
5
5
  Author-email: I_am_from_taiwan <102109040j@gmail.com>
6
6
  License: MIT
@@ -10,6 +10,6 @@ License-File: LICENSE
10
10
  Requires-Dist: discord.py>=2.3.0
11
11
  Dynamic: license-file
12
12
 
13
- # discordmodbot
13
+ # dcchbot
14
14
 
15
15
  一個支援 GUI 控制面板的 Discord 管理機器人。
@@ -0,0 +1,9 @@
1
+ dcchbot/__init__.py,sha256=TuQRGtSD8Z8WeNCtlvqz-fVxh2ZS87QSmN4VCJent0s,127
2
+ dcchbot/__main__.py,sha256=5FwoJspcKFt5_1AlXoxlWROiQSp9wgnFEltU6ufz9QE,30
3
+ dcchbot/main.py,sha256=f4iGx993EFBS_NDOo0Udw3sksPx-6CRl_dZYkt82iAU,25230
4
+ dcchbot-1.9.3.dist-info/licenses/LICENSE,sha256=_5HM5sddbG63Amw1X9WfCK-_5xBLHlAV_HaUKBqeTpE,1063
5
+ dcchbot-1.9.3.dist-info/METADATA,sha256=zO4-mSJG2-azgFSkisTMn6ho3m1Q3eH-cuvJgcV3CUQ,440
6
+ dcchbot-1.9.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ dcchbot-1.9.3.dist-info/entry_points.txt,sha256=90T16CGc_Tx-4pFaLCcbuuh7Vi9l4gsLovBkydqxP9Y,45
8
+ dcchbot-1.9.3.dist-info/top_level.txt,sha256=jiDTz8UmwZgXN9KzokwDRYhoWxsVmWcnqmrANeTFMck,8
9
+ dcchbot-1.9.3.dist-info/RECORD,,
@@ -6,5 +6,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
 
7
7
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
8
 
9
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
-
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,9 +0,0 @@
1
- dcchbot/__init__.py,sha256=4TDmBIfPXx5oA9Yv_2b2JOzd4slRS3Dznx9kgRlSP2o,103
2
- dcchbot/__main__.py,sha256=5FwoJspcKFt5_1AlXoxlWROiQSp9wgnFEltU6ufz9QE,30
3
- dcchbot/main.py,sha256=xCYfU5D78B_IF9UGLudwKAtDCCcvdvcpM5g2rBmi6uA,23890
4
- dcchbot-1.9.dist-info/licenses/LICENSE,sha256=l3hyIOCB7NYorC-bjV5yZM0PgAJbMgAWNLE644dR7H4,1065
5
- dcchbot-1.9.dist-info/METADATA,sha256=frDsnIZcZaQjt0xp4VKKdPaiy_Ld8Wm9o6iY8wzirYM,444
6
- dcchbot-1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- dcchbot-1.9.dist-info/entry_points.txt,sha256=90T16CGc_Tx-4pFaLCcbuuh7Vi9l4gsLovBkydqxP9Y,45
8
- dcchbot-1.9.dist-info/top_level.txt,sha256=jiDTz8UmwZgXN9KzokwDRYhoWxsVmWcnqmrANeTFMck,8
9
- dcchbot-1.9.dist-info/RECORD,,
File without changes