Skip to content

Commit

Permalink
adds cost feature (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperNovaa41 authored May 3, 2023
1 parent 9998451 commit 3827a13
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions gbp/gbp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, bot):
async def get_latest_gbp(self):
response = requests.get(
url="https://raw.githubusercontent.com/tgstation/tgstation/gbp-balances/.github/gbp-balances.toml"
)
)
content = response.text

raw_lines = []
Expand All @@ -43,11 +43,11 @@ async def get_latest_gbp(self):
if segments[-1][-1:] == '\n':
segments[-1] = segments[-1][:-1]
pairs.append([int(segments[2]), segments[-1]])
for n in range(len(pairs)-1, 0, -1):
for n in range(len(pairs) - 1, 0, -1):
for i in range(n):
if pairs[i][0] < pairs[i + 1][0]:
pairs[i][1], pairs[i+1][1] = pairs[i+1][1], pairs[i][1]
pairs[i][0], pairs[i+1][0] = pairs[i+1][0], pairs[i][0]
pairs[i][1], pairs[i + 1][1] = pairs[i + 1][1], pairs[i][1]
pairs[i][0], pairs[i + 1][0] = pairs[i + 1][0], pairs[i][0]

final_dict = {}
i = 1
Expand Down Expand Up @@ -130,3 +130,23 @@ async def totalgbp(self, ctx):
total_neg_gbp += abs(current_gbp)
await ctx.send(f"```There is {total_pos_gbp} positive GBP, and {total_neg_gbp} negative GBP in circulation.```")

@commands.command()
async def costs(self, ctx):
response = requests.get(
url="https://raw.githubusercontent.com/tgstation/tgstation/master/.github/gbp.toml"
)
content = response.text

raw_lines = []
line = ""
for char in content:
line += char
if char == '\n':
raw_lines.append(line)
line = ""
lines = raw_lines[4:]
msg = ""
for line in lines:
msg += line + "\n"
await ctx.send(f"```{msg}```")

0 comments on commit 3827a13

Please sign in to comment.