import json import discord import os import psycopg2 class Bot(discord.Client): async def on_ready(self): print("ログイン成功") async def on_message(self, message): if message.author.bot: return if message.content == "/hello": await message.channel.send("こんにちは!!!!") if message.content == "/password": await message.channel.send("gjhioragiopwjhgiopweap") class Cert(): def __init__(self): self.db = psycopg2.connect("host=localhost dbname=dislocker user=suti7 password=testing") def register(self, username, userid): cursor = self.db.cursor() insert_sql = "INSERT INTO user_list (discord_username, discord_userid) VALUES (%s, %s);" cursor.execute(insert_sql, (username, userid)) self.db.commit() def get_username(self, username, password): cursor = self.db.cursor() get_sql = "SELECT * FROM web_auth WHERE username = %s AND password = %s " cursor.execute(get_sql, (username, password)) result = cursor.fetchall() print(result) if result == []: return 1 elif result[0][1] == username and result[0][2] == password: return 0 class Web(flask.Flask): async def temp(self): print("") cert = Cert() print(cert.get_username("suti7", "0126")) bot_config_path = "./config/bot.json" if not os.path.isfile(bot_config_path): bot_config = { "token": "" } with open(bot_config_path, "w") as w: json.dump(bot_config, w, indent=4) elif os.path.isfile(bot_config_path): with open("./config/bot.json", "r") as r: bot_config = json.load(r) intents = discord.Intents.default() intents.message_content = True bot = Bot(intents=intents) bot.run(bot_config["token"])