Added ipoint balance checking and fixed a bug

This commit is contained in:
2026-04-22 19:06:52 +03:00
parent 1c48c46eb2
commit e037f7bd00
+33 -1
View File
@@ -50,6 +50,16 @@ setting_tokens = {
"check_self": 2 "check_self": 2
} }
def get_user_data(user_id: int):
ipoints = 0
bank = 0
if str(user_id) in db["users"].keys():
if "balance" in db["users"][str(user_id)].keys():
ipoints = db["users"][str(user_id)]["balance"]
if "bank" in db["users"][str(user_id)]:
bank = db["users"][str(user_id)]["bank"]
return ipoints, bank
def tokenize(multimod: str): def tokenize(multimod: str):
tokenized = {} tokenized = {}
regex_output = re.findall(r"^\s*(.+?)\s*{\s*(.+)\s*}\s*$", multimod) regex_output = re.findall(r"^\s*(.+?)\s*{\s*(.+)\s*}\s*$", multimod)
@@ -80,7 +90,8 @@ def tokenize(multimod: str):
raise TokenError("action contains unclosed quotes") raise TokenError("action contains unclosed quotes")
tokenized["action"] = re.split(r";\s*", tokenized["action"]) tokenized["action"] = re.split(r";\s*", tokenized["action"])
for i, action in enumerate(tokenized["action"]): for i, action in enumerate(tokenized["action"]):
tokenized["action"][i] = re.findall(r"\"[^\"]*\"|'[^\"]*'|[^\s\"]+", action) tokenized["action"][i] = re.findall(r"\"[^\"]*\"|'[^']*'|[^\s\"]+", action)
for i2, action_token in enumerate(tokenized["action"][i]): for i2, action_token in enumerate(tokenized["action"][i]):
tokenized["action"][i][i2] = action_token.strip("\"").strip("'") tokenized["action"][i][i2] = action_token.strip("\"").strip("'")
@@ -173,6 +184,27 @@ async def export(interaction: nextcord.Interaction):
async def import_(interaction: nextcord.Interaction, file: nextcord.Attachment): async def import_(interaction: nextcord.Interaction, file: nextcord.Attachment):
await interaction.send("Maybe in 2027") await interaction.send("Maybe in 2027")
@bot.slash_command()
async def ipoints(interaction: nextcord.Interaction):
pass
@ipoints.subcommand(description="View your internet point balance")
async def balance(interaction: nextcord.Interaction, user: nextcord.User = None):
await interaction.response.defer()
if not user:
user = interaction.user
user_name = "You"
else:
user_name = user.name
ipoints, bank = get_user_data(user.id)
if bank < 0:
await interaction.send(f"You have **{ipoints}** internet points and **{-bank}** loaned from the bank.")
await interaction.send(f"You have **{ipoints}** internet points and **{bank}** deposited to the bank.")
@ipoints.subcommand(description="Transfer internet points to someone else")
async def transfer(interaction: nextcord.Interaction, user: nextcord.User, reason: str = "no reason"):
print("poopen sharden farden")
@bot.event @bot.event
async def on_message(message: nextcord.Message): async def on_message(message: nextcord.Message):
if message.author != bot.user: if message.author != bot.user: