Bunch of polishing, looks good for release. Version number now 1.0.0.
parent
2c118906dd
commit
81ed6f9032
|
@ -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."""
|
||||
|
|
|
@ -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:
|
||||
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:
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
__version__ = '1.0dev'
|
||||
|
||||
__version__ = '1.0.0'
|
||||
|
|
|
@ -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*
|
||||
|
||||
|
|
|
@ -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]
|
||||
"""
|
||||
|
||||
|
@ -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]
|
||||
"""
|
||||
|
@ -102,7 +103,7 @@ 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))
|
||||
|
@ -114,7 +115,8 @@ 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]
|
||||
"""
|
||||
|
@ -125,7 +127,7 @@ class Add_Commands:
|
|||
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.'
|
||||
|
|
|
@ -25,11 +25,15 @@ class Admin_Commands:
|
|||
self.bot = bot
|
||||
|
||||
async def error(self, ctx, error):
|
||||
if isinstance(error, PlayerNotFound):
|
||||
error_str = ""
|
||||
|
||||
if hasattr(error, "original"):
|
||||
if isinstance(error.original, PlayerNotFound):
|
||||
error_str = 'that player is not in the database.'
|
||||
elif isinstance(error, DeleteEntryError):
|
||||
elif isinstance(error.original, DeleteEntryError) or isinstance(error.original, LocationLookUpError):
|
||||
error_str = 'that player does not have a location by that name.'
|
||||
else:
|
||||
|
||||
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))
|
||||
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -8,6 +8,7 @@ class Edit_Commands:
|
|||
"""
|
||||
Commands for editing your stuff in Geoffrey.
|
||||
"""
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
@ -54,8 +54,9 @@ class Search_Commands:
|
|||
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:
|
||||
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
from unittest import TestCase
|
||||
from BotConfig import get_config
|
||||
import os
|
||||
|
||||
from DiscordHelperFunctions import get_nickname
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue