dcchbot 1.9__tar.gz → 1.9.3__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.
- {dcchbot-1.9 → dcchbot-1.9.3}/LICENSE +1 -2
- {dcchbot-1.9 → dcchbot-1.9.3}/PKG-INFO +2 -2
- dcchbot-1.9.3/README.md +3 -0
- dcchbot-1.9.3/dcchbot/__init__.py +6 -0
- {dcchbot-1.9 → dcchbot-1.9.3}/dcchbot/main.py +58 -30
- {dcchbot-1.9 → dcchbot-1.9.3}/dcchbot.egg-info/PKG-INFO +2 -2
- {dcchbot-1.9 → dcchbot-1.9.3}/pyproject.toml +1 -1
- dcchbot-1.9/README.md +0 -3
- dcchbot-1.9/dcchbot/__init__.py +0 -5
- {dcchbot-1.9 → dcchbot-1.9.3}/dcchbot/__main__.py +0 -0
- {dcchbot-1.9 → dcchbot-1.9.3}/dcchbot.egg-info/SOURCES.txt +0 -0
- {dcchbot-1.9 → dcchbot-1.9.3}/dcchbot.egg-info/dependency_links.txt +0 -0
- {dcchbot-1.9 → dcchbot-1.9.3}/dcchbot.egg-info/entry_points.txt +0 -0
- {dcchbot-1.9 → dcchbot-1.9.3}/dcchbot.egg-info/requires.txt +0 -0
- {dcchbot-1.9 → dcchbot-1.9.3}/dcchbot.egg-info/top_level.txt +0 -0
- {dcchbot-1.9 → dcchbot-1.9.3}/setup.cfg +0 -0
@@ -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,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
|
-
#
|
13
|
+
# dcchbot
|
14
14
|
|
15
15
|
一個支援 GUI 控制面板的 Discord 管理機器人。
|
dcchbot-1.9.3/README.md
ADDED
@@ -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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
111
|
+
global OWNER_ID, LOG_CHANNEL_ID, token, bot
|
100
112
|
|
101
113
|
# 互動式輸入(你也可以改成從環境變數讀取)
|
102
|
-
|
103
|
-
|
104
|
-
OWNER_ID
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
LOG_CHANNEL_ID =
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
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 !=
|
303
|
-
await interaction.response.send_message(f"最新版本是{latest_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
|
-
#
|
13
|
+
# dcchbot
|
14
14
|
|
15
15
|
一個支援 GUI 控制面板的 Discord 管理機器人。
|
dcchbot-1.9/README.md
DELETED
dcchbot-1.9/dcchbot/__init__.py
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|