Changed how urls are handled
parent
ab61beed29
commit
79a5efa984
|
@ -14,13 +14,13 @@ def setup_logging():
|
||||||
bot_info_logger.addHandler(console)
|
bot_info_logger.addHandler(console)
|
||||||
|
|
||||||
|
|
||||||
def start_bot(discord_token, geoffrey_api_token, geoffrey_base_url):
|
def start_bot(discord_token, geoffrey_app_url, geoffrey_api_url, geoffrey_api_token):
|
||||||
setup_logging()
|
setup_logging()
|
||||||
loop = None
|
loop = None
|
||||||
bot = None
|
bot = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bot = GeoffreyBot(geoffrey_base_url, geoffrey_api_token)
|
bot = GeoffreyBot(geoffrey_app_url, geoffrey_api_url, geoffrey_api_token)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.run_until_complete(bot.start(discord_token))
|
loop.run_until_complete(bot.start(discord_token))
|
||||||
|
|
|
@ -26,20 +26,21 @@ bad_error_message = 'OOPSIE WOOPSIE!! Uwu We made a fucky wucky!! A wittle fucko
|
||||||
|
|
||||||
|
|
||||||
class GeoffreyBot(commands.Bot):
|
class GeoffreyBot(commands.Bot):
|
||||||
def __init__(self, base_url, api_token):
|
def __init__(self, geoffrey_app_url, geoffrey_api_url, geoffrey_api_token):
|
||||||
self.base_url = base_url
|
self.api_url = geoffrey_api_url
|
||||||
self.api_token = api_token
|
self.geoffrey_app_url = geoffrey_app_url
|
||||||
|
self.api_token = geoffrey_api_token
|
||||||
|
|
||||||
settings_url = base_url + 'api/settings/'
|
self.settings_url = self.api_url + 'settings/'
|
||||||
command_list_url = base_url + 'api/command/commands'
|
self.command_list_url = self.api_url + 'command/commands'
|
||||||
|
|
||||||
logger.info("Connecting to the Geoffrey API... ")
|
logger.info("Connecting to the Geoffrey API... ")
|
||||||
|
|
||||||
fail_count = 0
|
fail_count = 0
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
setting = requests.get(url=settings_url, params={"api": self.api_token}).json()
|
setting = requests.get(url=self.settings_url, params={"api": self.api_token}).json()
|
||||||
self.command_list = requests.get(url=command_list_url, params={"api": self.api_token}).json()
|
self.command_list = requests.get(url=self.command_list_url, params={"api": self.api_token}).json()
|
||||||
break
|
break
|
||||||
except Exception:
|
except Exception:
|
||||||
if fail_count > 20:
|
if fail_count > 20:
|
||||||
|
|
|
@ -7,7 +7,8 @@ from GeoffreyBot.util import run_command, HandledError
|
||||||
class GeoffreyCommands(commands.Cog):
|
class GeoffreyCommands(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.base_url = bot.base_url
|
self.api_url = bot.api_url
|
||||||
|
self.geoffrey_app_url = bot.geoffrey_app_url
|
||||||
self.api_token = bot.api_token
|
self.api_token = bot.api_token
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
|
@ -24,7 +25,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
name = get_name(args)
|
name = get_name(args)
|
||||||
|
|
||||||
attraction = await run_command(ctx, self.base_url, self.api_token, "POST", "add_attraction", x_pos=x_pos,
|
attraction = await run_command(ctx, self.api_url, self.api_token, "POST", "add_attraction", x_pos=x_pos,
|
||||||
z_pos=z_pos, name=name, discord_uuid=ctx.message.author.id, errors=errors)
|
z_pos=z_pos, name=name, discord_uuid=ctx.message.author.id, errors=errors)
|
||||||
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
|
@ -45,7 +46,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
name = get_name(args)
|
name = get_name(args)
|
||||||
|
|
||||||
base = await run_command(ctx, self.base_url, self.api_token, "POST", "add_base", x_pos=x_pos, z_pos=z_pos,
|
base = await run_command(ctx, self.api_url, self.api_token, "POST", "add_base", x_pos=x_pos, z_pos=z_pos,
|
||||||
name=name,
|
name=name,
|
||||||
discord_uuid=ctx.message.author.id, errors=errors)
|
discord_uuid=ctx.message.author.id, errors=errors)
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
name = get_name(args)
|
name = get_name(args)
|
||||||
|
|
||||||
farm = await run_command(ctx, self.base_url, self.api_token, "POST", "add_farm", x_pos=x_pos, z_pos=z_pos,
|
farm = await run_command(ctx, self.api_url, self.api_token, "POST", "add_farm", x_pos=x_pos, z_pos=z_pos,
|
||||||
name=name,
|
name=name,
|
||||||
discord_uuid=ctx.message.author.id, errors=errors)
|
discord_uuid=ctx.message.author.id, errors=errors)
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
shop_name = get_name(args)
|
shop_name = get_name(args)
|
||||||
|
|
||||||
item = await run_command(ctx, self.base_url, self.api_token, "POST", "add_item",
|
item = await run_command(ctx, self.api_url, self.api_token, "POST", "add_item",
|
||||||
item_name=item_name,
|
item_name=item_name,
|
||||||
quantity=quantity,
|
quantity=quantity,
|
||||||
diamond_price=diamond_price,
|
diamond_price=diamond_price,
|
||||||
|
@ -117,9 +118,9 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
name = get_name(args)
|
name = get_name(args)
|
||||||
|
|
||||||
market = await run_command(ctx, self.base_url, self.api_token, "POST", "add_market", x_pos=x_pos, z_pos=z_pos,
|
market = await run_command(ctx, self.api_url, self.api_token, "POST", "add_market", x_pos=x_pos, z_pos=z_pos,
|
||||||
name=name,
|
name=name,
|
||||||
discord_uuid=ctx.message.author.id, errors=errors)
|
discord_uuid=ctx.message.author.id, errors=errors)
|
||||||
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
'{}, your market has been added to the database: \n{}'.format(ctx.message.author.mention,
|
'{}, your market has been added to the database: \n{}'.format(ctx.message.author.mention,
|
||||||
|
@ -139,7 +140,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
location_name = get_name(args)
|
location_name = get_name(args)
|
||||||
|
|
||||||
location = await run_command(ctx, self.base_url, self.api_token, "POST", "add_owner", errors=errors,
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "add_owner", errors=errors,
|
||||||
new_owner_name=new_owner_name,
|
new_owner_name=new_owner_name,
|
||||||
location_name=location_name, discord_uuid=ctx.message.author.id)
|
location_name=location_name, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
@ -159,7 +160,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
}
|
}
|
||||||
|
|
||||||
town_name = get_name(args)
|
town_name = get_name(args)
|
||||||
location = await run_command(ctx, self.base_url, self.api_token, "POST", "add_resident", errors=errors,
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "add_resident", errors=errors,
|
||||||
new_resident_name=new_resident_name,
|
new_resident_name=new_resident_name,
|
||||||
town_name=town_name, discord_uuid=ctx.message.author.id)
|
town_name=town_name, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
@ -182,7 +183,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
farm_name = get_name(args)
|
farm_name = get_name(args)
|
||||||
|
|
||||||
resource = await run_command(ctx, self.base_url, self.api_token, "POST", "add_resource", errors=errors,
|
resource = await run_command(ctx, self.api_url, self.api_token, "POST", "add_resource", errors=errors,
|
||||||
resource_name=resource_name,
|
resource_name=resource_name,
|
||||||
farm_name=farm_name,
|
farm_name=farm_name,
|
||||||
discord_uuid=ctx.message.author.id)
|
discord_uuid=ctx.message.author.id)
|
||||||
|
@ -202,7 +203,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
name = get_name(args)
|
name = get_name(args)
|
||||||
|
|
||||||
shop = await run_command(ctx, self.base_url, self.api_token, "POST", "add_shop", errors=errors, x_pos=x_pos,
|
shop = await run_command(ctx, self.api_url, self.api_token, "POST", "add_shop", errors=errors, x_pos=x_pos,
|
||||||
z_pos=z_pos, name=name, discord_uuid=ctx.message.author.id)
|
z_pos=z_pos, name=name, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
await ctx.send('{}, your shop has been added to the database: \n{}'.format(ctx.message.author.mention,
|
await ctx.send('{}, your shop has been added to the database: \n{}'.format(ctx.message.author.mention,
|
||||||
|
@ -220,7 +221,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
name = get_name(args)
|
name = get_name(args)
|
||||||
|
|
||||||
town = await run_command(ctx, self.base_url, self.api_token, "POST", "add_town", errors=errors, x_pos=x_pos,
|
town = await run_command(ctx, self.api_url, self.api_token, "POST", "add_town", errors=errors, x_pos=x_pos,
|
||||||
z_pos=z_pos, name=name,
|
z_pos=z_pos, name=name,
|
||||||
discord_uuid=ctx.message.author.id)
|
discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
@ -241,7 +242,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(name)
|
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
tunnel = await run_command(ctx, self.base_url, self.api_token, "POST", "add_tunnel", errors=errors,
|
tunnel = await run_command(ctx, self.api_url, self.api_token, "POST", "add_tunnel", errors=errors,
|
||||||
tunnel_direction=tunnel_direction,
|
tunnel_direction=tunnel_direction,
|
||||||
tunnel_number=tunnel_number, location_name=name, discord_uuid=ctx.message.author.id)
|
tunnel_number=tunnel_number, location_name=name, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
@ -258,7 +259,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(name)
|
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
location = await run_command(ctx, self.base_url, self.api_token, "POST", "delete", errors=errors, name=name,
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "delete", errors=errors, name=name,
|
||||||
discord_uuid=ctx.message.author.id)
|
discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
await ctx.send("{}, **{}** has been deleted from Geoffrey, good riddance.".format(ctx.message.author.mention
|
await ctx.send("{}, **{}** has been deleted from Geoffrey, good riddance.".format(ctx.message.author.mention
|
||||||
|
@ -279,7 +280,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"ItemNotFound": "your shop does not sell **{}**. Try again buddy boy.".format(item_name)
|
"ItemNotFound": "your shop does not sell **{}**. Try again buddy boy.".format(item_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
shop = await run_command(ctx, self.base_url, self.api_token, "POST", "delete_item", errors=errors,
|
shop = await run_command(ctx, self.api_url, self.api_token, "POST", "delete_item", errors=errors,
|
||||||
item=item_name,
|
item=item_name,
|
||||||
shop_name=shop_name, discord_uuid=ctx.message.author.id)
|
shop_name=shop_name, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
@ -301,7 +302,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"ItemNotFound": "your farm does not produce **{}**. Try again buddy boy.".format(resource_name)
|
"ItemNotFound": "your farm does not produce **{}**. Try again buddy boy.".format(resource_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
farm = await run_command(ctx, self.base_url, self.api_token, "POST", "delete_resource", errors=errors,
|
farm = await run_command(ctx, self.api_url, self.api_token, "POST", "delete_resource", errors=errors,
|
||||||
resource=resource_name,
|
resource=resource_name,
|
||||||
farm_name=farm_name, discord_uuid=ctx.message.author.id)
|
farm_name=farm_name, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
@ -321,7 +322,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
old_name)
|
old_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
location = await run_command(ctx, self.base_url, self.api_token, "POST", "edit_name", errors=errors,
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "edit_name", errors=errors,
|
||||||
loc_name=old_name,
|
loc_name=old_name,
|
||||||
new_name=new_name, discord_uuid=ctx.message.author.id)
|
new_name=new_name, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
@ -340,7 +341,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(
|
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(
|
||||||
loc_name)
|
loc_name)
|
||||||
}
|
}
|
||||||
location = await run_command(ctx, self.base_url, self.api_token, "POST", "edit_pos", errors=errors, x=new_x,
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "edit_pos", errors=errors, x=new_x,
|
||||||
z=new_z,
|
z=new_z,
|
||||||
loc_name=loc_name, discord_uuid=ctx.message.author.id)
|
loc_name=loc_name, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
@ -361,9 +362,9 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"InvalidTunnelError": "{} is not a valid tunnel direction ya gub".format(new_tunnel_direction)
|
"InvalidTunnelError": "{} is not a valid tunnel direction ya gub".format(new_tunnel_direction)
|
||||||
}
|
}
|
||||||
|
|
||||||
location = await run_command(ctx, self.base_url, self.api_token, "POST", "edit_tunnel", errors=errors,
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "edit_tunnel", errors=errors,
|
||||||
tunnel_direction=new_tunnel_direction, tunnel_number=new_tunnel_number,
|
tunnel_direction=new_tunnel_direction, tunnel_number=new_tunnel_number,
|
||||||
loc_name=loc_name, discord_uuid=ctx.message.author.id)
|
loc_name=loc_name, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
await ctx.send("{}, **{}**'s tunnel been moved to **{}**".format(ctx.message.author.mention,
|
await ctx.send("{}, **{}**'s tunnel been moved to **{}**".format(ctx.message.author.mention,
|
||||||
location["name"],
|
location["name"],
|
||||||
|
@ -385,7 +386,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
else:
|
else:
|
||||||
radius = 200
|
radius = 200
|
||||||
|
|
||||||
locations = await run_command(ctx, self.base_url, self.api_token, "GET", "find_around", errors=errors,
|
locations = await run_command(ctx, self.api_url, self.api_token, "GET", "find_around", errors=errors,
|
||||||
x_pos=x_pos, z_pos=z_pos, radius=radius)
|
x_pos=x_pos, z_pos=z_pos, radius=radius)
|
||||||
|
|
||||||
message = ["{}, the following locations are within **{}** blocks of (x={}, z={}):".format(
|
message = ["{}, the following locations are within **{}** blocks of (x={}, z={}):".format(
|
||||||
|
@ -407,7 +408,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
errors = {
|
errors = {
|
||||||
"ResourceNotFoundError": "there are no farms that match **{}**.".format(search)
|
"ResourceNotFoundError": "there are no farms that match **{}**.".format(search)
|
||||||
}
|
}
|
||||||
locations = await run_command(ctx, self.base_url, self.api_token, "GET", "find_farm", errors=errors,
|
locations = await run_command(ctx, self.api_url, self.api_token, "GET", "find_farm", errors=errors,
|
||||||
resource_name=search)
|
resource_name=search)
|
||||||
|
|
||||||
message = ["{}, the following farms produce **{}**:".format(ctx.message.author.mention, search)]
|
message = ["{}, the following farms produce **{}**:".format(ctx.message.author.mention, search)]
|
||||||
|
@ -428,7 +429,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
errors = {
|
errors = {
|
||||||
"LocationLookUpError": "there are no locations that match **{}**.".format(search)
|
"LocationLookUpError": "there are no locations that match **{}**.".format(search)
|
||||||
}
|
}
|
||||||
locations = await run_command(ctx, self.base_url, self.api_token, "GET", "find_location", errors=errors,
|
locations = await run_command(ctx, self.api_url, self.api_token, "GET", "find_location", errors=errors,
|
||||||
search=search)
|
search=search)
|
||||||
|
|
||||||
message = ["{}, the following locations match **{}**:".format(ctx.message.author.mention, search)]
|
message = ["{}, the following locations match **{}**:".format(ctx.message.author.mention, search)]
|
||||||
|
@ -465,21 +466,21 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"LocationLookUpError": "there are no locations that match **{}**.".format(location_name)
|
"LocationLookUpError": "there are no locations that match **{}**.".format(location_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
location = await run_command(ctx, self.base_url, self.api_token, "GET", "info", location_name=location_name,
|
location = await run_command(ctx, self.api_url, self.api_token, "GET", "info", location_name=location_name,
|
||||||
errors=errors)
|
errors=errors)
|
||||||
|
|
||||||
message = "{}, info on {}:\n".format(ctx.message.author.mention, location["name"])
|
message = "{}, info on {}:\n".format(ctx.message.author.mention, location["name"])
|
||||||
|
|
||||||
if location["type"] == "Shop":
|
if location["type"] == "Shop":
|
||||||
info_list = formatted_shop(location, self.base_url)
|
info_list = formatted_shop(location, self.geoffrey_app_url)
|
||||||
elif location["type"] == "Town":
|
elif location["type"] == "Town":
|
||||||
info_list = formatted_town(location, self.base_url)
|
info_list = formatted_town(location, self.geoffrey_app_url)
|
||||||
elif location["type"] == "PublicFarm":
|
elif location["type"] == "PublicFarm":
|
||||||
info_list = formatted_farm(location, self.base_url)
|
info_list = formatted_farm(location, self.geoffrey_app_url)
|
||||||
elif location["type"] == "Market":
|
elif location["type"] == "Market":
|
||||||
info_list = formatted_market(location, self.base_url)
|
info_list = formatted_market(location, self.geoffrey_app_url)
|
||||||
else:
|
else:
|
||||||
info_list = formatted_location_info(location, self.base_url)
|
info_list = formatted_location_info(location, self.geoffrey_app_url)
|
||||||
|
|
||||||
await ctx.send(message)
|
await ctx.send(message)
|
||||||
await self.bot.send_list(ctx, info_list)
|
await self.bot.send_list(ctx, info_list)
|
||||||
|
@ -490,7 +491,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
{}me
|
{}me
|
||||||
"""
|
"""
|
||||||
|
|
||||||
locations = await run_command(ctx, self.base_url, self.api_token, "GET", "me",
|
locations = await run_command(ctx, self.api_url, self.api_token, "GET", "me",
|
||||||
discord_uuid=ctx.message.author.id)
|
discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
message = ["{}, you have the following locations:".format(ctx.message.author.mention)]
|
message = ["{}, you have the following locations:".format(ctx.message.author.mention)]
|
||||||
|
@ -509,7 +510,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"PlayerInDBError": "you are already registered with Geoffrey you ding dong."
|
"PlayerInDBError": "you are already registered with Geoffrey you ding dong."
|
||||||
}
|
}
|
||||||
|
|
||||||
await run_command(ctx, self.base_url, self.api_token, "POST", "register", errors=errors,
|
await run_command(ctx, self.api_url, self.api_token, "POST", "register", errors=errors,
|
||||||
player_name=ctx.message.author.display_name,
|
player_name=ctx.message.author.display_name,
|
||||||
discord_uuid=ctx.message.author.id)
|
discord_uuid=ctx.message.author.id)
|
||||||
await ctx.send("{}, you have been added to the database. Do {}help to see what this bot can do.".format(
|
await ctx.send("{}, you have been added to the database. Do {}help to see what this bot can do.".format(
|
||||||
|
@ -530,7 +531,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"LocationLookUpError": "you do not have a town called **{}** you ding dong goober.".format(town_name)
|
"LocationLookUpError": "you do not have a town called **{}** you ding dong goober.".format(town_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
location = await run_command(ctx, self.base_url, self.api_token, "POST", "remove_resident", errors=errors,
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "remove_resident", errors=errors,
|
||||||
resident_name=resident_name,
|
resident_name=resident_name,
|
||||||
town_name=town_name, discord_uuid=ctx.message.author.id)
|
town_name=town_name, discord_uuid=ctx.message.author.id)
|
||||||
|
|
||||||
|
@ -549,12 +550,12 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"ItemNotFound": "no shop was found selling {}".format(item)
|
"ItemNotFound": "no shop was found selling {}".format(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
results = await run_command(ctx, self.base_url, self.api_token, "GET", "selling", errors=errors, item_name=item)
|
results = await run_command(ctx, self.api_url, self.api_token, "GET", "selling", errors=errors, item_name=item)
|
||||||
|
|
||||||
message = ["{} The following shop(s) sell **{}**:".format(ctx.message.author.mention, item)]
|
message = ["{} The following shop(s) sell **{}**:".format(ctx.message.author.mention, item)]
|
||||||
|
|
||||||
for shop in results:
|
for shop in results:
|
||||||
for line in formatted_shop(shop, base_url=self.base_url):
|
for line in formatted_shop(shop, base_url=self.geoffrey_app_url):
|
||||||
message.append(line)
|
message.append(line)
|
||||||
|
|
||||||
message.append('')
|
message.append('')
|
||||||
|
@ -573,13 +574,13 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"ItemNotFound": "no shop was found selling {}".format(item)
|
"ItemNotFound": "no shop was found selling {}".format(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
results = await run_command(ctx, self.base_url, self.api_token, "GET", "selling_price", errors=errors,
|
results = await run_command(ctx, self.api_url, self.api_token, "GET", "selling_price", errors=errors,
|
||||||
item_name=item)
|
item_name=item)
|
||||||
|
|
||||||
message = ["{} The following shop(s) sell **{}**:".format(ctx.message.author.mention, item)]
|
message = ["{} The following shop(s) sell **{}**:".format(ctx.message.author.mention, item)]
|
||||||
|
|
||||||
for shop in results:
|
for shop in results:
|
||||||
for line in formatted_shop(shop, base_url=self.base_url):
|
for line in formatted_shop(shop, base_url=self.geoffrey_app_url):
|
||||||
message.append(line)
|
message.append(line)
|
||||||
|
|
||||||
message.append('')
|
message.append('')
|
||||||
|
@ -601,7 +602,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"EntryNameNotUniqueError": "you have more than one location. Please specify a name, dingus."
|
"EntryNameNotUniqueError": "you have more than one location. Please specify a name, dingus."
|
||||||
}
|
}
|
||||||
|
|
||||||
item = await run_command(ctx, self.base_url, self.api_token, "POST", "restock", errors=errors,
|
item = await run_command(ctx, self.api_url, self.api_token, "POST", "restock", errors=errors,
|
||||||
item_name=item_name,
|
item_name=item_name,
|
||||||
shop_name=shop_name, discord_uuid=ctx.message.author.id)
|
shop_name=shop_name, discord_uuid=ctx.message.author.id)
|
||||||
await ctx.send('{}, **{}** has been restocked at **{}**'.format(ctx.message.author.mention, item_name,
|
await ctx.send('{}, **{}** has been restocked at **{}**'.format(ctx.message.author.mention, item_name,
|
||||||
|
@ -618,7 +619,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
errors = {
|
errors = {
|
||||||
"LocationLookUpError": "**{}** has no tunnels in the database.".format(player_name)
|
"LocationLookUpError": "**{}** has no tunnels in the database.".format(player_name)
|
||||||
}
|
}
|
||||||
tunnels = await run_command(ctx, self.base_url, self.api_token, "GET", "tunnel", errors=errors,
|
tunnels = await run_command(ctx, self.api_url, self.api_token, "GET", "tunnel", errors=errors,
|
||||||
player_name=player_name)
|
player_name=player_name)
|
||||||
|
|
||||||
message = ["{}, **{}** has the following tunnels:".format(ctx.message.author.mention, player_name)]
|
message = ["{}, **{}** has the following tunnels:".format(ctx.message.author.mention, player_name)]
|
||||||
|
|
|
@ -87,6 +87,7 @@ def formatted_location_info(location, base_url):
|
||||||
info = []
|
info = []
|
||||||
|
|
||||||
info.append(formatted_location(location))
|
info.append(formatted_location(location))
|
||||||
|
|
||||||
info.append(get_full_link(base_url, location["link"]))
|
info.append(get_full_link(base_url, location["link"]))
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
|
@ -6,7 +6,7 @@ from GeoffreyBot.util import run_command, HandledError
|
||||||
class GeoffreyModCommands(commands.Cog):
|
class GeoffreyModCommands(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.base_url = bot.base_url
|
self.api_url = bot.api_url
|
||||||
self.api_token = bot.api_token
|
self.api_token = bot.api_token
|
||||||
|
|
||||||
# Check if the user has permission to use mod commands
|
# Check if the user has permission to use mod commands
|
||||||
|
@ -35,7 +35,7 @@ class GeoffreyModCommands(commands.Cog):
|
||||||
"LocationLookUpError": "That user does not have a location by the name **{}**.".format(name)
|
"LocationLookUpError": "That user does not have a location by the name **{}**.".format(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
location = await run_command(ctx, self.base_url, self.api_token, "POST", "delete", errors=errors, name=name,
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "delete", errors=errors, name=name,
|
||||||
discord_uuid=discord_uuid)
|
discord_uuid=discord_uuid)
|
||||||
|
|
||||||
await ctx.send("{}, **{}** has been deleted from Geoffrey".format(ctx.message.author.mention, location))
|
await ctx.send("{}, **{}** has been deleted from Geoffrey".format(ctx.message.author.mention, location))
|
||||||
|
@ -54,7 +54,7 @@ class GeoffreyModCommands(commands.Cog):
|
||||||
"EntryNameNotUniqueError": "Please specify the location name".format(item_name)
|
"EntryNameNotUniqueError": "Please specify the location name".format(item_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
shop = await run_command(ctx, self.base_url, self.api_token, "POST", "delete_item", errors=errors,
|
shop = await run_command(ctx, self.api_url, self.api_token, "POST", "delete_item", errors=errors,
|
||||||
item=item_name,
|
item=item_name,
|
||||||
shop_name=shop_name, discord_uuid=discord_uuid)
|
shop_name=shop_name, discord_uuid=discord_uuid)
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class GeoffreyModCommands(commands.Cog):
|
||||||
old_name)
|
old_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
location = await run_command(ctx, self.base_url, self.api_token, "POST", "edit_name", errors=errors,
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "edit_name", errors=errors,
|
||||||
loc_name=old_name,
|
loc_name=old_name,
|
||||||
new_name=new_name, discord_uuid=discord_uuid)
|
new_name=new_name, discord_uuid=discord_uuid)
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ class GeoffreyModCommands(commands.Cog):
|
||||||
"LocationLookUpError": "Town not found.".format(town_name)
|
"LocationLookUpError": "Town not found.".format(town_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
location = await run_command(ctx, self.base_url, self.api_token, "POST", "remove_resident", errors=errors,
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "remove_resident", errors=errors,
|
||||||
resident_name=resident_name,
|
resident_name=resident_name,
|
||||||
town_name=town_name, discord_uuid=discord_uuid)
|
town_name=town_name, discord_uuid=discord_uuid)
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class CommandError:
|
||||||
|
|
||||||
|
|
||||||
async def run_command(ctx, base_url, api_token, request_type, command, errors=None, **kwargs):
|
async def run_command(ctx, base_url, api_token, request_type, command, errors=None, **kwargs):
|
||||||
URL = base_url + '/GeoffreyApp/api/command/{}/'
|
URL = base_url + 'command/{}/'
|
||||||
|
|
||||||
kwargs["api"] = api_token
|
kwargs["api"] = api_token
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue