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 |
# 定義 Gradio 接口
|
| 37 |
iface = gr.Interface(
|
| 38 |
fn=process_input,
|
| 39 |
-
inputs=
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
outputs=[
|
| 44 |
-
gr.Textbox(label="生成的文本"),
|
| 45 |
-
gr.Textbox(label="結果")
|
| 46 |
-
]
|
| 47 |
)
|
| 48 |
|
| 49 |
-
# 啟動 Gradio 應用
|
| 50 |
-
iface.launch()
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
|
|
|
| 14 |
import sys
|
| 15 |
import gradio as gr
|
| 16 |
|
| 17 |
+
# 設置 intents
|
| 18 |
+
intents = discord.Intents.default()
|
| 19 |
+
intents.message_content = True
|
| 20 |
+
intents.guilds = True
|
| 21 |
+
|
| 22 |
+
# 創建 Bot 實例
|
| 23 |
+
bot = commands.Bot(command_prefix='!>', intents=intents, help_command=None)
|
| 24 |
+
setup_bot(bot)
|
| 25 |
+
@bot.event
|
| 26 |
+
async def on_ready():
|
| 27 |
+
print(f'{bot.user} is now jamming')
|
| 28 |
+
asyncio.create_task(console_input())
|
| 29 |
+
|
| 30 |
+
@bot.command(name='help')
|
| 31 |
+
async def help(ctx):
|
| 32 |
+
help_message = (
|
| 33 |
+
"1. `clear` 刪除對話 (需告數刪除的數量)\n"
|
| 34 |
+
"2. `send_message` 角色交換按鈕 (@要移除的角色 @要添加的角色 一段文字)\n"
|
| 35 |
+
"3. `give_role_message` 給予角色按鈕 (@要給予的角色 一段文字)\n"
|
| 36 |
+
"4. `add_banned_link` 新增禁止連結 (網址)\n"
|
| 37 |
+
"5. `alink` 增加禁止連結 (網址或文字)\n"
|
| 38 |
+
"6. `dlink` 刪除禁止連結 (網址或文字)\n"
|
| 39 |
+
"7. `play` 撥放音樂 (網址)\n"
|
| 40 |
+
"8. `pause` 暫停撥放音樂 (字面上意思)\n"
|
| 41 |
+
"9. `clear_queue` 清理音樂清單 (字面上意思)\n"
|
| 42 |
+
"10. `stop` 終止音樂撥放 (字面上意思)\n"
|
| 43 |
+
"11. `resume` 繼續音樂撥放 (字面上意思)\n"
|
| 44 |
+
"12. `queue` 音樂撥放清單 (字面上意思)"
|
| 45 |
+
)
|
| 46 |
+
await ctx.send(help_message)
|
| 47 |
+
# 引入原有功能模組
|
| 48 |
+
bot.add_command(clear.clear)
|
| 49 |
+
bot.add_command(botsrole.send_message)
|
| 50 |
+
bot.add_command(botsrole.give_role_message)
|
| 51 |
+
bot.add_command(literl_priosn.add_banned_link)
|
| 52 |
+
bot.add_command(literl_priosn.remove_banned_link)
|
| 53 |
+
bot.add_command(dv.download)
|
| 54 |
+
|
| 55 |
+
#調用async def 所需要的方法如下:
|
| 56 |
+
@bot.event
|
| 57 |
+
async def on_message(message):
|
| 58 |
+
await handle_message(message)
|
| 59 |
+
#底下是確保指令能正常接收
|
| 60 |
+
await bot.process_commands(message)
|
| 61 |
+
async def fetch_last_message(server_id: int, channel_id: int):
|
| 62 |
+
"""獲取指定伺服器和頻道的最新消息"""
|
| 63 |
+
guild = bot.get_guild(server_id)
|
| 64 |
+
if guild is None:
|
| 65 |
+
print("找不到伺服器。")
|
| 66 |
+
return None
|
| 67 |
+
|
| 68 |
+
channel = guild.get_channel(channel_id)
|
| 69 |
+
if channel is None or not isinstance(channel, discord.TextChannel):
|
| 70 |
+
print("找不到文本頻道。")
|
| 71 |
+
return None
|
| 72 |
|
| 73 |
+
# 獲取最新消息
|
| 74 |
+
async for message in channel.history(limit=1):
|
| 75 |
+
return message.content
|
| 76 |
|
| 77 |
+
print("該頻道沒有消息。")
|
| 78 |
+
return None
|
| 79 |
+
# 加載 CMD 模組
|
| 80 |
+
async def console_input():
|
| 81 |
+
while True:
|
| 82 |
+
try:
|
| 83 |
+
server_id = 741530746040221728
|
| 84 |
+
channel_id = 1279810458844401714
|
| 85 |
+
|
| 86 |
+
# 獲取最後一條消息
|
| 87 |
+
last_message = await fetch_last_message(server_id, channel_id)
|
| 88 |
+
if last_message is None:
|
| 89 |
+
print("無法獲取消息。")
|
| 90 |
+
return
|
| 91 |
+
|
| 92 |
+
print("輸入密碼: ", end='', flush=True)
|
| 93 |
+
password = await asyncio.get_event_loop().run_in_executor(None, sys.stdin.readline)
|
| 94 |
+
password = password.strip().lower()
|
| 95 |
|
| 96 |
+
if password == last_message.strip().lower():
|
| 97 |
+
print("list:列出所有伺服器\nserverrole:身分組控制\nclear:刪除留言\nserverinfo:管理禁詞\nserverlist:發送訊息")
|
| 98 |
+
command = await asyncio.get_event_loop().run_in_executor(None, input, "輸入指令: ")
|
| 99 |
+
command = command.strip().lower()
|
| 100 |
+
|
| 101 |
+
if command == 'list':
|
| 102 |
+
print("列出所有伺服器:")
|
| 103 |
+
for idx, guild in enumerate(bot.guilds):
|
| 104 |
+
print(f"{idx + 1}. {guild.name} (ID: {guild.id})")
|
| 105 |
+
|
| 106 |
+
elif command == 'serverrole':
|
| 107 |
+
print("選擇伺服器:")
|
| 108 |
+
for idx, guild in enumerate(bot.guilds):
|
| 109 |
+
print(f"{idx + 1}. {guild.name} (ID: {guild.id})")
|
| 110 |
+
guild_idx = int(input("請輸入伺服器編號: ")) - 1
|
| 111 |
+
guild = bot.guilds[guild_idx]
|
| 112 |
+
|
| 113 |
+
print(f"選擇的伺服器: {guild.name}")
|
| 114 |
+
print("選擇頻道:")
|
| 115 |
+
for idx, channel in enumerate(guild.text_channels):
|
| 116 |
+
print(f"{idx + 1}. {channel.name} (ID: {channel.id})")
|
| 117 |
+
channel_idx = int(input("請輸入頻道編號: ")) - 1
|
| 118 |
+
channel = guild.text_channels[channel_idx]
|
| 119 |
+
|
| 120 |
+
print(f"選擇的頻道: {channel.name}")
|
| 121 |
+
print("選擇功能:")
|
| 122 |
+
print("1. 發送訊息 (包括交換角色和給予角色)")
|
| 123 |
+
print("2. 查詢角色")
|
| 124 |
+
print("exit. 退出")
|
| 125 |
+
function = input("請輸入功能編號: ").strip()
|
| 126 |
+
|
| 127 |
+
if function == '1':
|
| 128 |
+
message_content = input("請輸入訊息內容: ").strip()
|
| 129 |
+
print("選擇功能:")
|
| 130 |
+
print("1. 交換角色")
|
| 131 |
+
print("2. 給予角色")
|
| 132 |
+
action = input("請輸入功能編號: ").strip()
|
| 133 |
+
|
| 134 |
+
if action == '1':
|
| 135 |
+
print("選擇要移除的角色:")
|
| 136 |
+
for idx, role in enumerate(guild.roles):
|
| 137 |
+
print(f"{idx + 1}. {role.name} (ID: {role.id})")
|
| 138 |
+
remove_role_idx = int(input("請輸入移除角色編號: ")) - 1
|
| 139 |
+
remove_role = guild.roles[remove_role_idx]
|
| 140 |
+
|
| 141 |
+
print("選擇要添加的角色:")
|
| 142 |
+
for idx, role in enumerate(guild.roles):
|
| 143 |
+
print(f"{idx + 1}. {role.name} (ID: {role.id})")
|
| 144 |
+
add_role_idx = int(input("請輸入添加角色編號: ")) - 1
|
| 145 |
+
add_role = guild.roles[add_role_idx]
|
| 146 |
+
|
| 147 |
+
# 發送訊息並附加交換角色按鈕
|
| 148 |
+
view = botsrole.RoleSwapButton(remove_role.id, add_role.id)
|
| 149 |
+
await channel.send(message_content, view=view)
|
| 150 |
+
print("訊息和交換角色按鈕已發送。")
|
| 151 |
+
continue
|
| 152 |
+
|
| 153 |
+
elif action == '2':
|
| 154 |
+
print("選擇角色:")
|
| 155 |
+
for idx, role in enumerate(guild.roles):
|
| 156 |
+
print(f"{idx + 1}. {role.name} (ID: {role.id})")
|
| 157 |
+
role_idx = int(input("請輸入角色編號: ")) - 1
|
| 158 |
+
role = guild.roles[role_idx]
|
| 159 |
+
# 發送訊息並附加給予角色按鈕
|
| 160 |
+
view = botsrole.GiveRoleButton(role.id)
|
| 161 |
+
await channel.send(message_content, view=view)
|
| 162 |
+
print("訊息和給予角色按鈕已發送。")
|
| 163 |
+
continue
|
| 164 |
+
|
| 165 |
+
elif command == '2':
|
| 166 |
+
# 查詢角色
|
| 167 |
+
for role in guild.roles:
|
| 168 |
+
print(f"{role.name} (ID: {role.id})")
|
| 169 |
+
|
| 170 |
+
elif command == 'exit':
|
| 171 |
+
continue
|
| 172 |
+
else:
|
| 173 |
+
print("無效的功能編號。")
|
| 174 |
+
|
| 175 |
+
if command == 'clear':
|
| 176 |
+
print("選擇伺服器:")
|
| 177 |
+
for idx, guild in enumerate(bot.guilds):
|
| 178 |
+
print(f"{idx + 1}. {guild.name} (ID: {guild.id})")
|
| 179 |
+
guild_idx = int(input("請輸入伺服器編號: ")) - 1
|
| 180 |
+
guild = bot.guilds[guild_idx]
|
| 181 |
+
print(f"選擇的伺服器: {guild.name}")
|
| 182 |
+
|
| 183 |
+
print("選擇頻道:")
|
| 184 |
+
for idx, channel in enumerate(guild.text_channels):
|
| 185 |
+
print(f"{idx + 1}. {channel.name} (ID: {channel.id})")
|
| 186 |
+
channel_idx = int(input("請輸入頻道編號: ")) - 1
|
| 187 |
+
channel = guild.text_channels[channel_idx]
|
| 188 |
+
|
| 189 |
+
print("1. 正常刪除")
|
| 190 |
+
print("2. 偷偷刪除")
|
| 191 |
+
print("exit. 退出")
|
| 192 |
+
choose = input("請輸入功能").strip()
|
| 193 |
+
if choose == '1':
|
| 194 |
+
amount = int(input("刪除訊息數量: "))
|
| 195 |
+
# 獲取頻道對應的訊息上下文
|
| 196 |
+
async for message in channel.history(limit=amount + 1):
|
| 197 |
+
await message.delete()
|
| 198 |
+
await channel.send(f'已刪除 {amount} 條消息。', delete_after=5)
|
| 199 |
+
print(f"已刪除 {amount} 條消息")
|
| 200 |
+
|
| 201 |
+
elif choose == "2":
|
| 202 |
+
amount = int(input("刪除訊息數量: "))
|
| 203 |
+
# 獲取頻道對應的訊息上下文
|
| 204 |
+
async for message in channel.history(limit=amount + 1):
|
| 205 |
+
await message.delete()
|
| 206 |
+
print(f"已刪除 {amount} 條消息")
|
| 207 |
+
|
| 208 |
+
elif command == 'exit':
|
| 209 |
+
continue
|
| 210 |
+
|
| 211 |
+
else:
|
| 212 |
+
print("錯誤選項")
|
| 213 |
+
continue
|
| 214 |
+
|
| 215 |
+
elif command == 'serverinfo':
|
| 216 |
+
print("\n已加入的伺服器:")
|
| 217 |
+
for index, guild in enumerate(bot.guilds):
|
| 218 |
+
print(f"{index}: 伺服器名稱: {guild.name}, 伺服器 ID: {guild.id}")
|
| 219 |
+
try:
|
| 220 |
+
guild_index = int(await asyncio.get_event_loop().run_in_executor(None, input, "選擇伺服器 (輸入數字): "))
|
| 221 |
+
if 0 <= guild_index < len(bot.guilds):
|
| 222 |
+
guild = bot.guilds[guild_index]
|
| 223 |
+
banned_links = literl_priosn.load_banned_links()
|
| 224 |
+
guild_id = str(guild.id)
|
| 225 |
+
if guild_id not in banned_links:
|
| 226 |
+
banned_links[guild_id] = [] # 確保 banned_links[guild_id] 是一個列表
|
| 227 |
+
|
| 228 |
+
print(f"\n伺服器 {guild.name} 的禁止連結:")
|
| 229 |
+
if banned_links[guild_id]:
|
| 230 |
+
for link in banned_links[guild_id]:
|
| 231 |
+
print(link)
|
| 232 |
+
else:
|
| 233 |
+
print(f"伺服器 {guild.name} 沒有禁止連結。")
|
| 234 |
+
|
| 235 |
+
# 在選擇伺服器後,添加或刪除禁止連結
|
| 236 |
+
while True:
|
| 237 |
+
action = await asyncio.get_event_loop().run_in_executor(None, input, "輸入操作 (添加: 'add', 刪除: 'remove', 結束: 'exit'): ")
|
| 238 |
+
action = action.strip().lower()
|
| 239 |
+
|
| 240 |
+
if action == 'add':
|
| 241 |
+
link = await asyncio.get_event_loop().run_in_executor(None, input, "輸入要添加的禁止連結: ")
|
| 242 |
+
link = link.strip()
|
| 243 |
+
if link:
|
| 244 |
+
if link not in banned_links[guild_id]:
|
| 245 |
+
banned_links[guild_id].append(link)
|
| 246 |
+
literl_priosn.save_banned_links(banned_links) # 確保保存的是更新後的 banned_links
|
| 247 |
+
print(f'已添加禁止連結: {link} 到伺服器 {guild.name}')
|
| 248 |
+
else:
|
| 249 |
+
print(f'這個連結已經被禁止了。')
|
| 250 |
+
elif action == 'remove':
|
| 251 |
+
link = await asyncio.get_event_loop().run_in_executor(None, input, "輸入要刪除的禁止連結: ")
|
| 252 |
+
link = link.strip()
|
| 253 |
+
if link:
|
| 254 |
+
if link in banned_links[guild_id]:
|
| 255 |
+
banned_links[guild_id].remove(link)
|
| 256 |
+
literl_priosn.save_banned_links(banned_links) # 確保保存的是更新後的 banned_links
|
| 257 |
+
print(f'已移除禁止連結: {link} 從伺服器 {guild.name}')
|
| 258 |
+
else:
|
| 259 |
+
print(f'這個連結不存在於禁止列表中。')
|
| 260 |
+
elif action == 'exit':
|
| 261 |
+
break
|
| 262 |
+
else:
|
| 263 |
+
print("不支援的操作。")
|
| 264 |
+
else:
|
| 265 |
+
print("請輸入有效的數字。")
|
| 266 |
+
except ValueError:
|
| 267 |
+
print("請輸入有效的數字。")
|
| 268 |
+
|
| 269 |
+
elif command == 'serverlist':
|
| 270 |
+
print("\n已加入的伺服器:")
|
| 271 |
+
for index, guild in enumerate(bot.guilds):
|
| 272 |
+
print(f"{index}: 伺服器名稱: {guild.name}, 伺服器 ID: {guild.id}")
|
| 273 |
+
try:
|
| 274 |
+
guild_index = int(await asyncio.get_event_loop().run_in_executor(None, input, "選擇伺服器 (輸入數字): "))
|
| 275 |
+
if 0 <= guild_index < len(bot.guilds):
|
| 276 |
+
guild = bot.guilds[guild_index]
|
| 277 |
+
print(f"\n伺服器 {guild.name} 的頻道:")
|
| 278 |
+
for index, channel in enumerate(guild.channels):
|
| 279 |
+
print(f"{index}: 頻道名稱: {channel.name}, 頻道 ID: {channel.id}")
|
| 280 |
+
|
| 281 |
+
# 選擇頻道後可以執行其他操作,例如發送訊息
|
| 282 |
+
while True:
|
| 283 |
+
action = await asyncio.get_event_loop().run_in_executor(None, input, "輸入操作 (發送訊息: 'send', 結束: 'exit'): ")
|
| 284 |
+
action = action.strip().lower()
|
| 285 |
+
if action == 'send':
|
| 286 |
+
try:
|
| 287 |
+
channel_index = int(await asyncio.get_event_loop().run_in_executor(None, input, "選擇頻道 (輸入數字): "))
|
| 288 |
+
if 0 <= channel_index < len(guild.channels):
|
| 289 |
+
channel = guild.channels[channel_index]
|
| 290 |
+
if isinstance(channel, discord.TextChannel):
|
| 291 |
+
message = await asyncio.get_event_loop().run_in_executor(None, input, "輸入要發送的訊息: ")
|
| 292 |
+
await channel.send(message)
|
| 293 |
+
print(f"訊息已發送到頻道 {channel.name}。")
|
| 294 |
+
else:
|
| 295 |
+
print("選擇的頻道不是文字頻道。")
|
| 296 |
+
else:
|
| 297 |
+
print("無效的頻道選擇。")
|
| 298 |
+
except ValueError:
|
| 299 |
+
print("請輸入有效的數字。")
|
| 300 |
+
elif action == 'exit':
|
| 301 |
+
break
|
| 302 |
+
else:
|
| 303 |
+
print("不支援的操作。")
|
| 304 |
+
else:
|
| 305 |
+
print("無效的伺服器選擇。")
|
| 306 |
+
except ValueError:
|
| 307 |
+
print("請輸入有效的數字。")
|
| 308 |
+
|
| 309 |
+
else:
|
| 310 |
+
print("錯誤的指令")
|
| 311 |
+
else:
|
| 312 |
+
print("密碼錯誤")
|
| 313 |
+
except Exception as e:
|
| 314 |
+
print(f"發生錯誤: {e}")
|
| 315 |
+
|
| 316 |
+
# 模擬的函數,這裡你可以根據實際需求進行修改
|
| 317 |
+
CORRECT_PASSWORD = "your_secret_password"
|
| 318 |
+
|
| 319 |
+
async def validate_password(input_text):
|
| 320 |
+
await asyncio.sleep(1) # 模擬延遲
|
| 321 |
+
if input_text.strip() == CORRECT_PASSWORD:
|
| 322 |
+
return "密碼驗證成功!"
|
| 323 |
else:
|
| 324 |
+
return "密碼錯誤!"
|
| 325 |
+
|
| 326 |
+
def process_input(input_text):
|
| 327 |
+
loop = asyncio.new_event_loop()
|
| 328 |
+
asyncio.set_event_loop(loop)
|
| 329 |
+
result = loop.run_until_complete(validate_password(input_text))
|
| 330 |
+
return result
|
| 331 |
|
| 332 |
# 定義 Gradio 接口
|
| 333 |
iface = gr.Interface(
|
| 334 |
fn=process_input,
|
| 335 |
+
inputs=gr.Textbox(label="輸入密碼", placeholder="在此輸入密碼...", type="text"),
|
| 336 |
+
outputs=gr.Textbox(label="結果"),
|
| 337 |
+
title="密碼驗證",
|
| 338 |
+
description="這是一個用於驗證密碼的 Gradio 應用。請輸入密碼來進行驗證。"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
)
|
| 340 |
|
|
|
|
|
|
|
| 341 |
|
| 342 |
+
if __name__ == "__main__":
|
| 343 |
+
TOKEN = os.getenv('DISCORD_TOKEN')
|
| 344 |
+
if TOKEN is None:
|
| 345 |
+
raise ValueError("DISCORD_TOKEN is not set")
|
| 346 |
+
bot.run(TOKEN)
|
| 347 |
+
# 啟動 Gradio 應用
|
| 348 |
+
iface.launch()
|
| 349 |
+
|
| 350 |
|