Skip to content

Commit 2fa8119

Browse files
authored
Merge pull request #144 from PyBotDevs/release-IsoBank-beta
Release IsoBank registration to all users
2 parents b3f7be1 + 0eed6f1 commit 2fa8119

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

framework/isobank/authorize.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ def __init__(self, db_path:str, account_db:str):
1717
user_data = json.load(f)
1818

1919
def save(self):
20-
with open(self.db_path, 'w+') as f: json.dump(accounts, indent=4)
21-
with open(self.db_path, 'w+') as f: json.dump(user_data, indent=4)
20+
with open(self.db_path, 'w+') as f: json.dump(accounts, f, indent=4)
21+
with open(self.account_db, 'w+') as f: json.dump(user_data, f, indent=4)
2222

2323
def register(self, discord_id:int, auth_id:int):
2424
if disabled: return "[!] IsoBank is currently disabled."
2525
if discord_id in accounts: return "[!] That user is already registered!"
2626
user_count = len(accounts.keys())
2727
new_id = user_count + 1
28-
if not auth_id.isdigit(): return "\"auth_id\" is not an integer."
29-
if len(auth_id) != 6: return "\"auth_id\" must be passed as a 6-digit number."
28+
if not str(auth_id).isdigit(): return "\"auth_id\" is not an integer."
29+
if len(str(auth_id)) != 6: return "\"auth_id\" must be passed as a 6-digit number."
3030
accounts[str(new_id)] = {"discord_ids": [discord_id], "auth_id": auth_id}
3131
user_data[str(new_id)] = {"deposited": 0}
3232
self.save()
@@ -37,5 +37,7 @@ def authorize(self, discord_id:int, account_id:int, auth_id:int):
3737
if disabled: return "[!] IsoBank is currently disabled."
3838
wacc = accounts[str(account_id)]
3939
if wacc["auth_id"] != auth_id: return "Incorrect auth ID"
40-
if discord_id not in wacc["discord_ids"]: wacc["discord_ids"].append(discord_id)
40+
if discord_id not in wacc["discord_ids"]:
41+
wacc["discord_ids"].append(discord_id)
42+
self.save()
4143
return wacc

main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class plugins:
6363

6464
colors = framework.isobot.colors.Colors()
6565
currency_unused = framework.isobot.currency.CurrencyAPI(f'{wdir}/database/currency.json') # Initialize part of the framework (Currency)
66-
isobank = framework.isobank.manager.IsoBankManager(f"{wdir}/database/isobank/accounts.json", f"{wdir}/database/isobank/auth.json")
66+
# isobank = framework.isobank.manager.IsoBankManager(f"{wdir}/database/isobank/accounts.json", f"{wdir}/database/isobank/auth.json")
6767
isobankauth = framework.isobank.authorize.IsobankAuth(f"{wdir}/database/isobank/auth.json", f"{wdir}/database/isobank/accounts.json")
6868

6969
#Events
@@ -993,6 +993,17 @@ async def repo(ctx:SlashContext):
993993
localembed = discord.Embed(title="Source-code Repositories", description="See and contribute to **isobot lazer's [GitHub repository](https://github.com/PyBotDevs/isobot-lazer)**\nSee our **[GitHub organization](https://github.com/PyBotDevs)**", color=discord.Color.random())
994994
await ctx.send(embed=localembed)
995995

996+
@slash.slash(
997+
name="isobank_register",
998+
description="Registers a new IsoBank account with your Discord ID",
999+
options=[
1000+
create_option(name="pin", description="Your new account's authentication ID. Must be a 6-digit integer.", option_type=4, required=True)
1001+
]
1002+
)
1003+
async def isobank_register(ctx:SlashContext, pin:int):
1004+
isobankauth.register(ctx.author.id, pin)
1005+
await ctx.reply("Congratulations! Your new IsoBank account has been registered.", hidden=True)
1006+
9961007
# Initialization
9971008
utils.ping.host()
9981009
client.run(api.auth.get_token())

0 commit comments

Comments
 (0)