更新时间:2023-12-04 11:26:46
您可以为此使用常规的txt文件.看到新的ID后,请附加它们.启动机器人时,请将所有ID加载到set
中以防止重复
You could just use a regular txt file for this. Append new ids when you see them. When you start your bot, load all the ids into a set
to prevent duplicates
ids = set()
@bot.event
async def on_ready():
with open("ids.txt") as f:
for id in f:
ids.add(id.strip())
@bot.command(pass_context=True)
async def register(ctx):
id = ctx.message.author.id
if id not in ids:
ids.add(id)
with open("ids.txt", "a") as f:
print(id, file=f)
await bot.say("ID {} added".format(id))