ワンタイムパスワード用にマージ予定
This commit is contained in:
parent
ace0af03d6
commit
22bc5fe240
4 changed files with 42 additions and 10 deletions
16
temp/password.py
Normal file
16
temp/password.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
# パスワードをファイルから読み込む
|
||||||
|
|
||||||
|
with open('password.txt', 'r') as f:
|
||||||
|
secret = f.read()
|
||||||
|
|
||||||
|
check=int(input("password :"))
|
||||||
|
|
||||||
|
if check==int(secret):
|
||||||
|
print("ok")
|
||||||
|
secret=0
|
||||||
|
with open('password.txt', 'w') as file:
|
||||||
|
file.write('')
|
||||||
|
else:
|
||||||
|
print("out")
|
0
temp/password.txt
Normal file
0
temp/password.txt
Normal file
9
temp/powershell.py
Normal file
9
temp/powershell.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
# PowerShellコマンドを実行する関数
|
||||||
|
def run_powershell_command(command):
|
||||||
|
# PowerShellコマンドを実行
|
||||||
|
os.system(f"powershell -Command {command}")
|
||||||
|
|
||||||
|
# 例としてGet-Dateコマンドを実行して現在の日時を取得
|
||||||
|
run_powershell_command("Get-Date")
|
|
@ -1,11 +1,14 @@
|
||||||
# インストールした discord.py を読み込む
|
|
||||||
import discord
|
|
||||||
import secrets
|
|
||||||
import string
|
|
||||||
|
|
||||||
|
import discord
|
||||||
|
import string
|
||||||
|
import random
|
||||||
|
|
||||||
|
# Intentsの設定
|
||||||
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
# 接続に必要なオブジェクトを生成
|
# 接続に必要なオブジェクトを生成
|
||||||
client = discord.Client()
|
client = discord.Client(intents=intents)
|
||||||
|
|
||||||
# 起動時に動作する処理
|
# 起動時に動作する処理
|
||||||
@client.event
|
@client.event
|
||||||
|
@ -20,14 +23,18 @@ async def on_message(message):
|
||||||
if message.author.bot:
|
if message.author.bot:
|
||||||
return
|
return
|
||||||
# 「/neko」と発言したら「にゃーん」が返る処理
|
# 「/neko」と発言したら「にゃーん」が返る処理
|
||||||
if message.content == '/neko':
|
if message.content == "/neko":
|
||||||
await message.channel.send('にゃーん')
|
await message.channel.send('にゃーん')
|
||||||
|
|
||||||
if message.content == '/password':
|
if message.content == '/password':
|
||||||
await message.channel.send(get_random_password_string(4))
|
secret=password_generator_n(4)
|
||||||
def get_random_password_string(length):
|
await message.channel.send(str(secret))
|
||||||
pass_chars = string.ascii_letters + string.digits
|
with open('password.txt', 'a') as file:
|
||||||
password = ''.join(secrets.choice(pass_chars) for x in range(length))
|
file.write(secret)
|
||||||
|
|
||||||
|
def password_generator_n(length):
|
||||||
|
numbers = string.digits # (1)
|
||||||
|
password = ''.join(random.choice(numbers) for _ in range(length)) # (2)
|
||||||
return password
|
return password
|
||||||
|
|
||||||
# Botの起動とDiscordサーバーへの接続
|
# Botの起動とDiscordサーバーへの接続
|
Loading…
Reference in a new issue