我有一個簡單的pythonwebhook sender for Discord,有3個url輸入。我想弄清楚如何使on選項使用1、2或所有3個輸入。有可能嗎?我不是最有經(jīng)驗的人,所以請回答一些細節(jié)。
from discord_webhook import DiscordWebhook
print('paste webhook 1')
url1 = input()
print('paste webhook 2')
url2 = input()
print('paste webhook 3')
url3 = input()
print('what do you want them to say?')
content = input()
print('sending...')
while True:
webhook_urls = [url1, url2, url3]
webhook = DiscordWebhook(url=webhook_urls, content=content)
response = webhook.execute()
我假設你一開始會問他們要輸入多少個webhook
因此,基本上,只要程序運行,用戶就會被要求提供所需的webhooks的數(shù)量,然后根據(jù)輸入(共3個),他們會被要求提供webhooks,這些webhooks會被添加到之前啟動的webhook_urls列表中。
之后,用戶被要求提供內(nèi)容,while循環(huán)啟動,使用函數(shù)輸出和先前啟動的列表正常執(zhí)行代碼;webhook_urls。
希望我能幫上忙。