2018-05-21 15:59:35 +00:00
|
|
|
from discord.ext import commands
|
2018-07-22 23:56:07 +00:00
|
|
|
from Commands import *
|
2018-05-29 14:04:01 +00:00
|
|
|
from BotErrors import *
|
2018-06-03 02:42:31 +00:00
|
|
|
from MinecraftAccountInfoGrabber import *
|
2018-07-21 18:28:31 +00:00
|
|
|
from BotConfig import *
|
2018-07-23 02:51:22 +00:00
|
|
|
import threading
|
2018-07-21 18:28:31 +00:00
|
|
|
|
2018-05-21 15:59:35 +00:00
|
|
|
command_prefix = '?'
|
2018-05-25 16:32:29 +00:00
|
|
|
description = '''
|
2018-08-05 22:20:37 +00:00
|
|
|
Geoffrey (pronounced JOFF-ree) started his life as an inside joke none of you will understand.
|
|
|
|
At some point, she was to become an airhorn bot. Now, they know where your stuff is.
|
2018-05-22 02:41:15 +00:00
|
|
|
|
2018-07-01 15:10:10 +00:00
|
|
|
Please respect Geoffrey, the bot is very sensitive.
|
2018-07-14 22:25:33 +00:00
|
|
|
|
2018-08-05 22:20:37 +00:00
|
|
|
If have a suggestion or if something is borked, you can PM my ding dong of a creator ZeroHD.
|
|
|
|
|
|
|
|
*You must use ?register before adding things to Geoffrey*
|
2018-05-22 02:41:15 +00:00
|
|
|
'''
|
2018-05-25 16:32:29 +00:00
|
|
|
|
2018-05-25 22:00:43 +00:00
|
|
|
bad_error_message = 'OOPSIE WOOPSIE!! Uwu We made a fucky wucky!! A wittle fucko boingo! The admins at our ' \
|
2018-06-30 15:07:56 +00:00
|
|
|
'headquarters are working VEWY HAWD to fix this! (Error in command {}: {})'
|
2018-05-25 22:00:43 +00:00
|
|
|
|
2018-05-25 16:32:29 +00:00
|
|
|
bot = commands.Bot(command_prefix=command_prefix, description=description, case_insensitive=True)
|
|
|
|
|
2018-06-23 16:08:40 +00:00
|
|
|
# Bot Commands ******************************************************************'
|
|
|
|
|
2018-06-03 02:42:31 +00:00
|
|
|
|
2018-05-21 15:59:35 +00:00
|
|
|
@bot.event
|
|
|
|
async def on_ready():
|
2018-05-25 16:32:29 +00:00
|
|
|
print('GeoffreyBot')
|
|
|
|
print('Username: ' + bot.user.name)
|
|
|
|
print('ID: ' + bot.user.id)
|
|
|
|
|
|
|
|
|
|
|
|
@bot.event
|
|
|
|
async def on_command_error(error, ctx):
|
2018-05-25 20:30:47 +00:00
|
|
|
if isinstance(error, commands.CommandNotFound):
|
2018-06-02 16:11:31 +00:00
|
|
|
error_str = 'Command not found, ding dongs like you can use ?help to see all the commands this bot can do.'
|
2018-07-29 14:29:27 +00:00
|
|
|
elif isinstance(error, commands.CommandOnCooldown):
|
|
|
|
return
|
2018-05-26 14:53:36 +00:00
|
|
|
elif isinstance(error, commands.UserInputError):
|
2018-07-28 00:02:41 +00:00
|
|
|
error_str = 'Invalid syntax for **{}** you ding dong, please read ?help {}.'\
|
2018-06-02 16:11:31 +00:00
|
|
|
.format(ctx.invoked_with, ctx.invoked_with)
|
2018-08-05 22:20:37 +00:00
|
|
|
elif isinstance(error.original, NoPermissionError):
|
|
|
|
error_str = 'You don\'t have permission for that cool command.'
|
2018-06-03 02:42:31 +00:00
|
|
|
elif isinstance(error.original, UsernameLookupFailed):
|
|
|
|
error_str = error.original.__doc__
|
2018-07-08 19:19:40 +00:00
|
|
|
elif isinstance(error.original, PlayerNotFound):
|
|
|
|
error_str = 'Make sure to use ?register first you ding dong.'
|
2018-07-21 01:50:24 +00:00
|
|
|
elif isinstance(error.original, EntryNameNotUniqueError):
|
2018-07-14 22:25:33 +00:00
|
|
|
error_str = 'An entry in the database already has that name ding dong.'
|
2018-07-22 23:56:07 +00:00
|
|
|
elif isinstance(error.original, DatabaseValueError):
|
2018-07-23 00:01:49 +00:00
|
|
|
error_str = 'Use a shorter name or a smaller value, dong ding.'
|
2018-08-05 22:20:37 +00:00
|
|
|
elif isinstance(error.original, NotOnServerError):
|
|
|
|
error_str = 'Command needs to be run on 24CC. Run this command there whoever you are.'.format()
|
2018-05-25 20:30:47 +00:00
|
|
|
else:
|
2018-06-30 15:07:56 +00:00
|
|
|
error_str = bad_error_message.format(ctx.invoked_with, error)
|
2018-05-25 20:30:47 +00:00
|
|
|
|
2018-07-23 00:01:49 +00:00
|
|
|
await bot.send_message(ctx.message.channel, '{} **Error Running Command:** {}'.format(ctx.message.author.mention,
|
|
|
|
error_str))
|
2018-05-25 16:32:29 +00:00
|
|
|
|
2018-07-23 02:51:22 +00:00
|
|
|
def update_user_names(bot_commands):
|
|
|
|
threading.Timer(600, update_user_names, [bot_commands]).start()
|
|
|
|
session = bot_commands.interface.database.Session()
|
2018-07-24 01:12:23 +00:00
|
|
|
print("Updating MC usernames...")
|
2018-07-23 02:51:22 +00:00
|
|
|
player_list = session.query(Player).all()
|
|
|
|
|
|
|
|
for player in player_list:
|
|
|
|
player.name = grab_playername(player.mc_uuid)
|
|
|
|
|
|
|
|
session.commit()
|
|
|
|
|
|
|
|
session.close()
|
|
|
|
|
2018-05-25 16:32:29 +00:00
|
|
|
# Bot Startup ******************************************************************
|
2018-06-23 16:08:40 +00:00
|
|
|
|
2018-08-05 22:20:37 +00:00
|
|
|
|
2018-07-21 18:28:31 +00:00
|
|
|
config = read_config()
|
2018-06-23 16:08:40 +00:00
|
|
|
|
2018-07-21 18:28:31 +00:00
|
|
|
TOKEN = config['Discord']['Token']
|
2018-06-30 15:53:27 +00:00
|
|
|
|
2018-07-21 18:28:31 +00:00
|
|
|
engine_arg = get_engine_arg(config)
|
2018-06-30 15:53:27 +00:00
|
|
|
|
2018-07-22 23:56:07 +00:00
|
|
|
bot_commands = Commands(engine_arg)
|
2018-07-15 15:56:56 +00:00
|
|
|
|
2018-08-05 22:20:37 +00:00
|
|
|
extensions = ['Add_Commands', 'Delete_Commands', 'Edit_Commands', 'Search_Commands', 'Admin_Commands']
|
2018-05-21 16:57:20 +00:00
|
|
|
|
2018-08-05 22:20:37 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
for extension in extensions:
|
|
|
|
try:
|
|
|
|
bot.load_extension(extension)
|
|
|
|
except Exception as e:
|
|
|
|
print('Failed to load extension {}'.format(extension))
|
|
|
|
update_user_names(bot_commands)
|
|
|
|
bot.run(TOKEN)
|
2018-07-23 02:51:22 +00:00
|
|
|
|
2018-07-28 00:02:41 +00:00
|
|
|
|