Merge branch 'master' into format_scrubber
commit
3946d29c2a
|
@ -88,6 +88,14 @@ class GeoffreyBot(commands.Bot):
|
||||||
elif hasattr(error, "original") and isinstance(error.original, request_exception.ConnectionError):
|
elif hasattr(error, "original") and isinstance(error.original, request_exception.ConnectionError):
|
||||||
error_str = "Unable to connect to the database. Hopefully someone is working on this..."
|
error_str = "Unable to connect to the database. Hopefully someone is working on this..."
|
||||||
await self.send_error_message("Can't connect to the GeoffreyAPI, is it offline?")
|
await self.send_error_message("Can't connect to the GeoffreyAPI, is it offline?")
|
||||||
|
elif hasattr(error, "original"):
|
||||||
|
e = error.original.args[0]
|
||||||
|
|
||||||
|
if e == "TypeError":
|
||||||
|
error_str = "Well bud, you got this far. Good job! But you still h*cked up the syntax:"
|
||||||
|
|
||||||
|
for line in self.help_dict[ctx.command.name]:
|
||||||
|
error_str += line
|
||||||
|
|
||||||
if error_str is '':
|
if error_str is '':
|
||||||
await self.send_error_message(
|
await self.send_error_message(
|
||||||
|
@ -129,17 +137,14 @@ class GeoffreyBot(commands.Bot):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def send_list(ctx, send_list):
|
async def send_list(ctx, send_list):
|
||||||
size = 0
|
|
||||||
msg = ""
|
msg = ""
|
||||||
|
|
||||||
for s in send_list:
|
for s in send_list:
|
||||||
if (size + len(s)) > 2000:
|
if (len(msg) + len(s)) > 2000:
|
||||||
await ctx.send(msg)
|
await ctx.send(msg)
|
||||||
msg = s
|
msg = s
|
||||||
size = len(s)
|
|
||||||
else:
|
else:
|
||||||
msg = msg + '\n' + s
|
msg = msg + '\n' + s
|
||||||
size = size + len(s)
|
|
||||||
|
|
||||||
if len(msg) > 0:
|
if len(msg) > 0:
|
||||||
await ctx.send(msg)
|
await ctx.send(msg)
|
||||||
|
|
|
@ -179,13 +179,11 @@ class GeoffreyCommands(commands.Cog):
|
||||||
async def add_owner(self, ctx, new_owner_name, *args):
|
async def add_owner(self, ctx, new_owner_name, *args):
|
||||||
"""
|
"""
|
||||||
{}add_owner <New Owner's Name> <Location Name>
|
{}add_owner <New Owner's Name> <Location Name>
|
||||||
WARNING: The new owner had just as much power as you to edit or delete this location.
|
WARNING: The new owner has just as much power as you to edit or delete this location.
|
||||||
"""
|
"""
|
||||||
errors = {
|
errors = {
|
||||||
"OwnerNotFoundError": "ain't no one in this darn database named **{}** you goob".format(
|
"OwnerNotFoundError": "ain't no one in this darn database named **{}** you goob".format(new_owner_name),
|
||||||
ctx.message.author.mention, new_owner_name),
|
"IsOwnerError": "**{}** is already an owner, stop having amosia.".format(new_owner_name),
|
||||||
"IsOwnerError": "**{}** is already an owner, stop having amosia.".format(
|
|
||||||
ctx.message.author.mention, new_owner_name),
|
|
||||||
"LocationLookUpError": "you do not have a location by that name you ding dong goober."
|
"LocationLookUpError": "you do not have a location by that name you ding dong goober."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +205,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
"ResidentNotFoundError": "ain't no one in this darn database named **{}** you goob".format(
|
"ResidentNotFoundError": "ain't no one in this darn database named **{}** you goob".format(
|
||||||
new_resident_name),
|
new_resident_name),
|
||||||
"IsResidentError": "**{}** is already a resident, stop having amosia.".format(new_resident_name),
|
"IsResidentError": "**{}** is already a resident, stop having amosia.".format(new_resident_name),
|
||||||
"LocationLookupError": "you do not have a town by that name you ding dong goober."
|
"LocationLookUpError": "you do not have a town by that name you ding dong goober."
|
||||||
}
|
}
|
||||||
|
|
||||||
town_name = get_name(args)
|
town_name = get_name(args)
|
||||||
|
@ -263,7 +261,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def add_town(self, ctx, x_pos: int, z_pos: int, *args):
|
async def add_town(self, ctx, x_pos: int, z_pos: int, *args):
|
||||||
"""
|
"""
|
||||||
{}add_town <X Coordinate> <Z Coordinate> <Shop Name>
|
{}add_town <X Coordinate> <Z Coordinate> <Town Name>
|
||||||
The Town Name parameter is optional if this is your first town
|
The Town Name parameter is optional if this is your first town
|
||||||
"""
|
"""
|
||||||
errors = {
|
errors = {
|
||||||
|
@ -283,15 +281,15 @@ class GeoffreyCommands(commands.Cog):
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def add_tunnel(self, ctx, tunnel_direction, tunnel_number: int, *args):
|
async def add_tunnel(self, ctx, tunnel_direction, tunnel_number: int, *args):
|
||||||
"""
|
"""
|
||||||
{}add_tunnel <Tunnel Direction> <Tunnel Number> <Location Name>
|
{}add_tunnel <Tunnel Direction> <X/Z Tunnel Number> <Location Name>
|
||||||
The Name parameter is optional if you only have one location
|
The Name parameter is optional if you only have one location
|
||||||
"""
|
"""
|
||||||
errors = {
|
|
||||||
"InvalidTunnelError": "{} is not a valid tunnel direction ya gub".format(tunnel_direction),
|
|
||||||
"LocationLookUpError": "you do not have a location by the name you ding dong goober."
|
|
||||||
}
|
|
||||||
|
|
||||||
name = get_name(args)
|
name = get_name(args)
|
||||||
|
errors = {
|
||||||
|
"InvalidTunnelError": "{} is not a valid tunnel direction ya gub".format(tunnel_direction),
|
||||||
|
"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.base_url, self.api_token, "POST", "add_tunnel", errors=errors,
|
||||||
tunnel_direction=tunnel_direction,
|
tunnel_direction=tunnel_direction,
|
||||||
|
@ -353,7 +351,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_item", errors=errors,
|
farm = await run_command(ctx, self.base_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)
|
||||||
|
|
||||||
|
@ -369,7 +367,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
errors = {
|
errors = {
|
||||||
"EntryNameNotUniqueError": "a location is already called **{}** you ding dong goober".format(old_name),
|
"EntryNameNotUniqueError": "a location is already called **{}** you ding dong goober".format(old_name),
|
||||||
"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(
|
||||||
old_name)
|
old_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +381,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
@commands.command(pass_conext=True)
|
@commands.command(pass_conext=True)
|
||||||
async def edit_pos(self, ctx, new_x: int, new_z: int, *args):
|
async def edit_pos(self, ctx, new_x: int, new_z: int, *args):
|
||||||
"""
|
"""
|
||||||
{}edit_post <New X Coordinate> <New Z Coordinate> <Location Name>
|
{}edit_pos <New X Coordinate> <New Z Coordinate> <Location Name>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
loc_name = get_name(args)
|
loc_name = get_name(args)
|
||||||
|
@ -409,11 +407,11 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
errors = {
|
errors = {
|
||||||
"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),
|
||||||
"InvalidLookUpError": "{} 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 = run_command(ctx, self.base_url, self.api_token, "POST", "edit_tunnel", errors=errors,
|
location = await run_command(ctx, self.base_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)
|
||||||
|
|
||||||
|
@ -438,7 +436,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
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.base_url, self.api_token, "GET", "find_around", errors=errors,
|
||||||
x_pos=x_pos, z_pos=z_pos)
|
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(
|
||||||
ctx.message.author.mention, radius, x_pos, z_pos)]
|
ctx.message.author.mention, radius, x_pos, z_pos)]
|
||||||
|
@ -448,6 +446,27 @@ class GeoffreyCommands(commands.Cog):
|
||||||
|
|
||||||
await self.bot.send_list(ctx, message)
|
await self.bot.send_list(ctx, message)
|
||||||
|
|
||||||
|
@commands.command(pass_context=True)
|
||||||
|
async def find_farm(self, ctx, *args):
|
||||||
|
"""
|
||||||
|
{}find_farm <Resource>
|
||||||
|
"""
|
||||||
|
|
||||||
|
search = get_name(args)
|
||||||
|
|
||||||
|
errors = {
|
||||||
|
"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,
|
||||||
|
resource_name=search)
|
||||||
|
|
||||||
|
message = ["{}, the following farms produce **{}**:".format(ctx.message.author.mention, search)]
|
||||||
|
|
||||||
|
for location in locations:
|
||||||
|
message.append(formatted_location(location))
|
||||||
|
|
||||||
|
await self.bot.send_list(ctx, message)
|
||||||
|
|
||||||
@commands.command(pass_context=True, aliases=["find"])
|
@commands.command(pass_context=True, aliases=["find"])
|
||||||
async def find_location(self, ctx, *args):
|
async def find_location(self, ctx, *args):
|
||||||
"""
|
"""
|
||||||
|
@ -537,15 +556,15 @@ class GeoffreyCommands(commands.Cog):
|
||||||
{}register
|
{}register
|
||||||
"""
|
"""
|
||||||
errors = {
|
errors = {
|
||||||
"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.base_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.",
|
await ctx.send("{}, you have been added to the database. Do {}help to see what this bot can do.".format(
|
||||||
ctx.message.author.mention,
|
ctx.message.author.mention,
|
||||||
self.bot.prefix)
|
self.bot.prefix))
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def remove_resident(self, ctx, resident_name, *args):
|
async def remove_resident(self, ctx, resident_name, *args):
|
||||||
|
@ -557,7 +576,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
town_name = get_name(args)
|
town_name = get_name(args)
|
||||||
|
|
||||||
errors = {
|
errors = {
|
||||||
"ResidentNotFoundError": "ain't no one your town named {} you goob".format(resident_name),
|
"ResidentNotFoundError": "ain't no one in your town named {} you goob".format(resident_name),
|
||||||
"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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,7 +614,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def selling_price(self, ctx, *args):
|
async def selling_price(self, ctx, *args):
|
||||||
"""
|
"""
|
||||||
{}selling_rpice <Item Name>
|
{}selling_price <Item Name>
|
||||||
Sorts by best price
|
Sorts by best price
|
||||||
"""
|
"""
|
||||||
item = get_name(args)
|
item = get_name(args)
|
||||||
|
|
Loading…
Reference in New Issue