A different approach to 'Currency and Economy'

If you are interested this is the code thus far.

import MuckletBot
import json
import time

CHECK_BALANCE_COMMANDS = ["check", "balance", "inquire"]
SEND_COMMANDS = ["send", "pay", "give"]

MAX_IN_CIRCULATION = 1_000_000

HELP_TEXT = """
Hello, I am the currency bot. I can help you send money to other characters and check your balance.

To check your balance, type `balance` or `check`.
Note that you start with 1000 coins.

To send money to another character, type `send` or `pay` followed by the amount of money you want to send and the **full name** of the character you want to send it to.

Please note that you must message me the command.

Examples:
`message Banker = balance` - check your balance.
`message Banker = send 1000 Ico Twilight` - send 1000 coins to the character Ico Twilight.
`message Banker = pay 1000 Ico Twilight` - send 1000 coins to the character Ico Twilight.
`message Banker = check` - check your balance.

If you have any questions, please contact the owner of the bot.

Thank you for using the currency bot.

- The currency bot
"""


class Logger:

	def __init__(self, logfile="logs.txt", indent=6, wrapping=" "):
		self.logfile = logfile
		self.indent = indent
		self.wrapping = wrapping
		self.i = 0

	def __call__(self, *messages, title=""):
		self.log(*messages, title=title)

	def log(self, *messages, title=""):
		string = self.wrapping * 5 + " " + title + " " + self.wrapping * 5 + "\n"
		for message in messages:
			self.i += 1
			string += str(self.i) + ":" + " " * self.indent + str(message) + "\n"
		string += self.wrapping * 6 + self.wrapping * len(
		 title) + self.wrapping * 6 + "\n"

		if self.logfile is not None:
			with open(self.logfile, "a") as f:
				f.write(string)
		print(string)


logger = Logger()


class STORAGE:

	def __init__(self, init):
		with open(init, "r") as f:
			storage = json.load(f)
		self.storage = storage
		self.password = "This isn't the password"

	def add(self, character):
		if character.id not in self.storage:
			total = self.getTotal()
			give = max((MAX_IN_CIRCULATION - total) // 1000, 0)
			self.set(character, give)
			logger.log(
			 f"Added [{character.name}] to the storage with [{give}] Sinder Bucks.",
			 title="STORAGE")
			self.save()
		else:
			return

	def get(self, character):
		self.add(character)
		return self.storage[character.id]["balance"]

	def set(self, character, value):
		self.storage[character.id] = {"balance": value}
		self.save()

	def transfer(self, amount, sender, receiver):
		self.add(sender)
		self.add(receiver)
		self.storage[sender.id]["balance"] -= amount
		self.storage[receiver.id]["balance"] += amount
		logger.log(
		 f"Transferred [{amount}] Sinder Bucks from [{sender.name}] to [{receiver.name}].",
		 title="STORAGE")
		self.save()

	def getTotal(self):
		total = 0
		for key, value in self.storage.items():
			print(key, value)
			total += value["balance"]
		return total

	def save(self):
		with open("storage.json", "w") as f:
			json.dump(self.storage, f)

	def setPassword(self, password):
		self.password = password


storage = STORAGE("storage.json")


# the function that gets called when a message is recieved
def OnMessage(bot, message):
	# if the message type is either a say, pose, whisper, address or a message
	if message.get("type") in ["message"]:
		# if the recieved message is not from ourself
		if message.get("sender").id != bot.CID:
			command = message.get("message").strip().split(" ")
			if len(command) == 0:
				return
			if command[0] in CHECK_BALANCE_COMMANDS:
				message.get("sender").message(
				 f"You have {storage.get(message.get('sender'))} Sinder Bucks.")
			elif command[0] in SEND_COMMANDS:
				if len(command) < 4:
					message.get("sender").message(
					 "You need to specify the amount and then the recievers full name.")
					return
				if command[1].isnumeric() and int(command[1]) > 0 and int(
				  command[1]) == float(command[1]):
					if storage.get(message.get("sender")) >= int(command[1]):
						# get the reciever
						reciever = bot.getCharID(" ".join(command[2:]))
						if reciever is None:
							message.get("sender").message(
							 "The reciever could not be found, please make sure you use the full name."
							)
							return
						reciever = MuckletBot.Character(bot, " ".join(command[2:]), reciever)
						storage.transfer(int(command[1]), message.get("sender"), reciever)
						message.get("sender").message(
						 f"You sent {command[1]} Sinder Bucks to {reciever.name}.")
						reciever.message(
						 f"You recieved {command[1]} Sinder Bucks from {message.get('sender').name}."
						)
					else:
						message.get("sender").message(
						 f"You only have {storage.get(message.get('sender'))} Sinder Bucks.")
						return
				else:
					message.get("sender").message(
					 "The amount must be a positive integer with no decimals or letters.")
					return
			elif command[0] == "help":
				message.get("sender").message(HELP_TEXT)
			elif command[0] == "total":
				if len(command) < 2:
					message.get("sender").message(f"Please provide a password.")
					return
				if " ".join(command[1:]) == storage.password:
					message.get("sender").message(
					 f"The total amount of Sinder Bucks in circulation is {storage.getTotal()}."
					)
				else:
					message.get("sender").message(f"Invalid password.")

			elif command[0] == "set":
				if len(command) < 5:
					message.get("sender").message(
					 f"Please provide a charactername, amount and password.")
					return
				if " ".join(command[4:]) == storage.password:
					if command[3].isnumeric() and int(command[3]) > 0 and int(
					  command[3]) == float(command[3]):
						# get the reciever
						reciever = bot.getCharID(" ".join(command[1:3]))
						if reciever is None:
							message.get("sender").message(
							 f"The reciever could not be found, please make sure you use the full name."
							)
							return
						reciever = MuckletBot.Character(bot, " ".join(command[1:3]), reciever)
						storage.set(reciever, int(command[3]))
						message.get("sender").message(
						 f"You set {reciever.name}'s balance to {command[3]} Sinder Bucks.")
					else:
						message.get("sender").message(
						 "The amount must be a positive integer with no decimals or letters.")
						return
				else:
					message.get("sender").message(f"Invalid password.")

			elif command[0] == "get":
				if len(command) < 4:
					message.get("sender").message(
					 f"Please provide a charactername and password.")
					return
				if " ".join(command[3:]) == storage.password:
					# get the reciever
					reciever = bot.getCharID(" ".join(command[1:3]))
					if reciever is None:
						message.get("sender").message(
						 f"The reciever could not be found, please make sure you use the full name."
						)
						return
					reciever = MuckletBot.Character(bot, " ".join(command[1:3]), reciever)
					message.get("sender").message(
					 f"{reciever.name} has {storage.get(reciever)} Sinder Bucks.")
				else:
					message.get("sender").message(f"Invalid password.")
			elif command[0] == "report":
				if len(command) < 2:
					message.get("sender").message(f"Please provide a report")
					return
				# add the report to the report file
				with open("reports.txt", "a") as f:
					f.write(f"{message.get('sender').name}: {' '.join(command[1:])}\n")
				message.get("sender").message(f"Your report has been submitted.")
			elif command[0] == "suggest":
				if len(command) < 2:
					message.get("sender").message(f"Please provide a suggestion")
					return
				# add the report to the features file
				with open("features.txt", "a") as f:
					f.write(f"{message.get('sender').name}: {' '.join(command[1:])}\n")
				message.get("sender").message(f"Your suggestion has been submitted.")

			else:
				message.get("sender").message(
				 f"Invalid command, please use `help` for a list of commands.")


# the function that gets called in a seperate thread when the bot is fully booted
def OnOpen(bot):
	method = "call." + bot.RID + ".getChar"
	result = bot.request(bot.ws,
	                     method,
	                     params={"charID": "cevi2oe9gbrtr77qto90"})
	bot.Logger(result, title="RECIEVED RESULT")
	while (1):
		bot.say("1")
		bot.ping()
		time.sleep(120)


def OnError(bot, error):
	# any errors that occur without an atached promise will be sent here
	return
	bot.Logger(str(error), title="RECIEVED ERROR WITHOUT PROMISE")


if __name__ == "__main__":
	# create a new bot
	bot = MuckletBot.Bot(TOKEN="The Bots Token",
	                     VERBOSE=True,
	                     HOST='wss://api.wolfery.com',
	                     ORIGIN='https://wolfery.com')
	# set the onMessage event handler
	bot.onMessage = OnMessage
	# set the onStart event handler
	bot.onOpen = OnOpen
	# set the onError event handler
	bot.onError = OnError
	# start the bot
	bot.run_forever()
	# note if you want to run 1 < bots in the same script, you need to use run() instead of run_forever()

Excuse it’s messiness