Bunch of polishing, looks good for release. Version number now 1.0.0.

doc_update
Joey Hines 2018-09-13 11:25:40 -05:00
parent 2c118906dd
commit 81ed6f9032
12 changed files with 62 additions and 48 deletions

View File

@ -71,5 +71,9 @@ class NotOnServerError(DataBaseError):
"""You need to run this command on 24CC"""
class NoLocationsInDatabase(DataBaseError):
"""This player has no locations in the database"""
class FuckyWucky:
"""You made one."""

View File

@ -134,6 +134,8 @@ class Commands:
if shop_name is None:
if len(shop_list) == 1:
shop_name = shop_list[0].name
elif len(shop_list) == 0:
raise NoLocationsInDatabase
else:
raise LocationInitError
@ -301,7 +303,10 @@ class Commands:
shop = shop_list[0]
else:
shop = self.interface.find_location_by_name_and_owner(session, player, shop_name, loc_type=Shop)[0]
try:
shop = self.interface.find_location_by_name_and_owner(session, player, shop_name, loc_type=Shop)[0]
except IndexError:
raise LocationLookUpError
expr = (ItemListing.name == item) & (ItemListing.shop == shop)
self.interface.database.delete_entry(session, ItemListing, expr)
@ -329,7 +334,7 @@ class Commands:
return loc_str
def update_mc_uuid(self, mc_uuid, discord_uuid):
def update_mc_uuid(self, discord_uuid, mc_uuid):
session = self.interface.database.Session()
try:

View File

@ -1,2 +1 @@
__version__ = '1.0dev'
__version__ = '1.0.0'

View File

@ -23,7 +23,9 @@ At some point, she was to become an airhorn bot. Now, they know where your stuff
Please respect Geoffrey, the bot is very sensitive.
If have a suggestion or if something is borked, you can PM my ding dong of a creator ZeroHD.
All commands must be prefaced with '?'
If have a suggestion or if something is borked, you can PM my ding dong of a creator BirbHD.
*You must use ?register before adding things to Geoffrey*

View File

@ -18,7 +18,7 @@ class Add_Commands:
@commands.cooldown(5, 60, commands.BucketType.user)
async def register(self, ctx):
"""
Registers your Discord and Minecraft account with the the database.
Registers your Discord and Minecraft account with the the database
You must do this before adding entries to the database.
"""
@ -35,7 +35,7 @@ class Add_Commands:
@commands.cooldown(5, 60, commands.BucketType.user)
async def add_base(self, ctx, x_pos: int, z_pos: int, *args):
"""
Adds your base to the database. The base name is optional if this your first base.
Adds your base to the database. The base name is optional if this your first base
?add_base [X Coordinate] [Z Coordinate] [Base Name]
"""
@ -50,7 +50,7 @@ class Add_Commands:
except EntryNameNotUniqueError:
if name is None:
await ctx.send('{}, you already have one base in the database, you need to specify a base'
' name'.format(ctx.message.author.mention))
' name'.format(ctx.message.author.mention))
else:
await ctx.send(
'{}, a base called **{}** already exists. You need to specify a different name.'.format(
@ -60,7 +60,7 @@ class Add_Commands:
@commands.cooldown(5, 60, commands.BucketType.user)
async def add_shop(self, ctx, x_pos: int, z_pos: int, *args):
"""
Adds your shop to the database. The name is shop optional if this your first shop.
Adds your shop to the database. The name is shop optional if this your first shop
?add_shop [X Coordinate] [Z Coordinate] [Shop Name]
"""
@ -86,7 +86,8 @@ class Add_Commands:
@commands.cooldown(5, 60, commands.BucketType.user)
async def add_tunnel(self, ctx, tunnel_color: str, tunnel_number: int, *args):
"""
Adds your tunnel to the database. If you only have one location, you do not need to specify a location name.
Adds your tunnel to the database. If you only have one location, you do not need to specify a location name
Directions: North South East West
?tunnel [Tunnel Direction] [Tunnel Number] [Location Name]
"""
@ -94,7 +95,7 @@ class Add_Commands:
loc_name = get_name(args)
try:
self.bot.bot_commands.add_tunnel(tunnel_color, tunnel_number, discord_uuid=ctx.message.author.id,
location_name=loc_name)
location_name=loc_name)
await ctx.send('{}, your tunnel has been added to the database'.format(ctx.message.author.mention))
except LocationLookUpError:
await ctx.send('{}, you do not have a location called **{}**.'.format(
@ -102,10 +103,10 @@ class Add_Commands:
except LocationHasTunnelError:
await ctx.send('{}, **{}** already has a tunnel.'.format(ctx.message.author.mention, loc_name))
except TunnelInitError:
await ctx.send('{}, invalid tunnel color.'.format(ctx.message.author.mention))
await ctx.send('{}, invalid tunnel name.'.format(ctx.message.author.mention))
except EntryNameNotUniqueError:
await ctx.send('{}, you have more than one location, you need to specify a location.'
.format(ctx.message.author.mention))
.format(ctx.message.author.mention))
except InvalidTunnelError:
await ctx.send(
'{}, **{}** is an invalid tunnel color.'.format(ctx.message.author.mention, tunnel_color))
@ -114,22 +115,23 @@ class Add_Commands:
@commands.cooldown(5, 60, commands.BucketType.user)
async def add_item(self, ctx, item_name: str, quantity: int, diamond_price: int, *args):
"""
Adds an item to a shop's inventory. If you have one shop, the shop name is not required.
Adds an item to a shop's inventory. If you have one shop, the shop name is not required
Quantity for Diamond Price. eg. 32 Dirt for 1D
?add_item [Item Name] [Quantity] [Price] [Shop name]
"""
shop_name = get_name(args)
try:
self.bot.bot_commands.add_item(item_name, quantity, diamond_price, shop_name=shop_name,
discord_uuid=ctx.message.author.id)
discord_uuid=ctx.message.author.id)
await ctx.send(
'{}, **{}** has been added to the inventory of your shop.'.format(ctx.message.author.mention,
item_name))
except PlayerNotFound:
except NoLocationsInDatabase:
await ctx.send('{}, you don\'t have any shops in the database.'.format(ctx.message.author.mention))
except LocationInitError:
await ctx.send('{}, you have more than one shop in the database, please specify a shop name.'
.format(ctx.message.author.mention))
.format(ctx.message.author.mention))
except LocationLookUpError:
await ctx.send(
'{}, you don\'t have any shops named **{}** in the database.'.format(ctx.message.author.mention,

View File

@ -25,11 +25,15 @@ class Admin_Commands:
self.bot = bot
async def error(self, ctx, error):
if isinstance(error, PlayerNotFound):
error_str = 'that player is not in the database.'
elif isinstance(error, DeleteEntryError):
error_str = 'that player does not have a location by that name.'
else:
error_str = ""
if hasattr(error, "original"):
if isinstance(error.original, PlayerNotFound):
error_str = 'that player is not in the database.'
elif isinstance(error.original, DeleteEntryError) or isinstance(error.original, LocationLookUpError):
error_str = 'that player does not have a location by that name.'
if error_str is "":
error_str = 'the bot encountered the following error: {}'.format(error.__str__())
await ctx.send('{}, {}'.format(ctx.message.author.mention, error_str))
@ -74,7 +78,7 @@ class Admin_Commands:
"""
self.bot.bot_commands.edit_name(new_name, current_name, discord_uuid=discord_uuid)
await ctx.send('{}, **{}** has been rename to **{}**.'.format(ctx.message.author.mention, current_name,
new_name))
new_name))
@edit_name.error
async def edit_error(self, ctx, error):
@ -83,7 +87,7 @@ class Admin_Commands:
@mod.command(pass_context=True)
async def update_mc_uuid(self, ctx, discord_uuid: str, mc_uuid: str):
"""
Updates a user's MC UUID.
Updates a user's MC UUID
"""
self.bot.bot_commands.update_mc_uuid(discord_uuid, mc_uuid)
await ctx.send('{}, **{}** has been updated.'.format(ctx.message.author.mention, discord_uuid))
@ -93,9 +97,9 @@ class Admin_Commands:
await self.error(ctx, error)
@mod.command(pass_context=True)
async def update_discord_uuid(self, ctx, current_discord_uuid: str, new_discord_uuid: str):
async def update_discord_uuid(self, ctx, new_discord_uuid: str, current_discord_uuid: str):
"""
Updates a user's Discord UUID.
Updates a user's Discord UUID
"""
self.bot.bot_commands.update_mc_uuid(current_discord_uuid, new_discord_uuid)
await ctx.send('{}, user **{}** has been updated.'.format(ctx.message.author.mention, current_discord_uuid))
@ -107,7 +111,7 @@ class Admin_Commands:
@mod.command(pass_context=True)
async def update_mc_name(self, ctx, discord_uuid: str):
"""
Updates a user's MC name to the current name on the MC UUID.
Updates a user's MC name to the current name on the MC UUID
"""
self.bot.bot_commands.update_mc_name(discord_uuid)
await ctx.send('{}, user **{}**\'s MC name has update.'.format(ctx.message.author.mention, discord_uuid))
@ -119,7 +123,7 @@ class Admin_Commands:
@mod.command(pass_context=True)
async def status(self, ctx, *args):
"""
Updates "playing [game]" status of the bot.
Updates "playing [game]" status of the bot
"""
status = get_name(args)
await self.bot.change_presence(activity=Game(status))

View File

@ -17,7 +17,7 @@ class Delete_Commands:
@commands.command(pass_context=True)
async def delete(self, ctx, *args):
"""
Deletes a location from the database.
Deletes a location from the database
?delete [Location name]
"""
loc = get_name(args)
@ -44,7 +44,7 @@ class Delete_Commands:
shop_name = self.bot.bot_commands.delete_item(item, shop, discord_uuid=ctx.message.author.id)
await ctx.send('{}, **{}** has been removed from the inventory of **{}**.'.
format(ctx.message.author.mention, item, shop_name))
format(ctx.message.author.mention, item, shop_name))
except LocationLookUpError:
if shop is None:
await ctx.send('{}, you do have any shops in the database.'.format(ctx.message.author.mention))
@ -52,7 +52,7 @@ class Delete_Commands:
await ctx.send('{}, you do not have a shop called **{}**.'.format(ctx.message.author.mention, shop))
except EntryNameNotUniqueError:
await ctx.send('{}, you have more than one shop in the database, please specify a shop name.'
.format(ctx.message.author.mention))
.format(ctx.message.author.mention))
except DeleteEntryError:
if shop is not None:
await ctx.send('{}, **{}** does not sell **{}**.'.format(ctx.message.author.mention, shop, item))

View File

@ -8,6 +8,7 @@ class Edit_Commands:
"""
Commands for editing your stuff in Geoffrey.
"""
def __init__(self, bot):
self.bot = bot
@ -54,7 +55,7 @@ class Edit_Commands:
async def edit_name(self, ctx, new_name: str, current_name: str):
"""
Edits the name of a location
IF A NAME HAS SPACES IN IT YOU NEED TO WRAP IT IN QUOTATION MARKS. eg. "Cool Shop 123"
IF A NAME HAS SPACES IN IT YOU NEED TO WRAP IT IN QUOTATION MARKS. eg. "Cool Shop 123"
?edit_name [New Name] [Current Name]
"""
try:

View File

@ -16,7 +16,7 @@ class Search_Commands:
@commands.cooldown(5, 60, commands.BucketType.user)
async def find(self, ctx, *args):
"""
Finds all the locations and tunnels matching the search term
Finds all the locations matching the search term
?find [Search]
"""
search = get_name(args)
@ -37,7 +37,7 @@ class Search_Commands:
@commands.cooldown(5, 60, commands.BucketType.user)
async def tunnel(self, ctx, player: str):
"""
Finds all the tunnels a player owns.
Finds all the tunnels a player owns
?tunnel [Player]
"""
try:
@ -47,15 +47,16 @@ class Search_Commands:
'{}, **{}** owns the following tunnels: \n{}'.format(ctx.message.author.mention, player, result))
except LocationLookUpError:
await ctx.send('{}, no tunnels for **{}** were found in the database.'
.format(ctx.message.author.mention, player))
.format(ctx.message.author.mention, player))
@commands.command(pass_context=True)
@commands.cooldown(5, 60, commands.BucketType.user)
async def find_around(self, ctx, x_pos: int, z_pos: int, *args):
"""
Finds all the locations around a certain point.
The radius defaults to 200 blocks if no value is given.
Default dimension is overworld.
The radius defaults to 200 blocks if no value is given
Default dimension is the overworld
?find_around [X Coordinate] [Z Coordinate] [Radius] [Optional Flags]
Optional Flags:
@ -84,7 +85,7 @@ class Search_Commands:
ctx.message.author.mention, radius, base_string))
else:
await ctx.send('{}, there are no locations within {} blocks of that point'
.format(ctx.message.author.mention, radius))
.format(ctx.message.author.mention, radius))
except ValueError:
await ctx.send(
'{}, invalid radius, the radius must be a whole number.'.format(ctx.message.author.mention,
@ -111,7 +112,7 @@ class Search_Commands:
async def info(self, ctx, *args):
"""
Displays info about a location.
If the location is a shop, it displays the shop's inventory.
If the location is a shop, it displays the shop's inventory
?info [Location Name]
"""
loc = get_name(args)
@ -134,7 +135,7 @@ class Search_Commands:
try:
loc_str = self.bot.bot_commands.me(discord_uuid=ctx.message.author.id)
await ctx.send('{}, here are your locations in the database: \n {}'.format(ctx.message.author.mention,
loc_str))
loc_str))
except PlayerNotFound:
await ctx.send('{}, you don\'t have any locations in the database.'.format(ctx.message.author.mention))

View File

@ -209,12 +209,10 @@ class TestCommands(TestCase):
self.commands.add_item('dirt', 5, 5, shop_name='test shop', discord_uuid='143072699567177728')
self.commands.add_item('wood', 5, 5, shop_name='test shop', discord_uuid='143072699567177728')
result = self.commands.delete_item('dirt', None, discord_uuid='143072699567177728')
self.commands.delete_item('dirt', None, discord_uuid='143072699567177728')
self.assertRaises(ItemNotFound, self.commands.selling, 'dirt')
if ('dirt' not in result) & ('wood' in result):
pass
else:
self.fail()
self.commands.add_shop(0, 0, shop_name='test shop2', discord_uuid='143072699567177728')
self.assertRaises(EntryNameNotUniqueError, self.commands.delete_item, 'wood', None,

View File

@ -1,6 +1,4 @@
from unittest import TestCase
from BotConfig import get_config
import os
from DiscordHelperFunctions import get_nickname

View File

@ -9,7 +9,7 @@ class TestMinecraftInfoGrabber(TestCase):
self.assertEqual(grab_UUID('BirbHD'), 'fe7e84132570458892032b69ff188bc3')
def test_grab_playername(self):
self.assertEqual(grab_playername('01c29c443f8d4ab490a56919407a5bd2'), 'CoolZero123')
self.assertEqual(grab_playername('01c29c443f8d4ab490a56919407a5bd2'), 'CoolBirb123')
def test_grab_playername_wrong_case(self):
self.assertEqual(grab_UUID('birbhd'), 'fe7e84132570458892032b69ff188bc3')