Bot now starts automatically

+subprocess kicked off when URLs are being loaded
+renamed bot dir to discord_bot
doc_update
Joey Hines 2018-12-01 18:25:53 -06:00
parent 803d25d67f
commit 37dd0950a5
16 changed files with 26 additions and 31 deletions

View File

@ -1,7 +1,7 @@
from GeoffreyApp.api.bot.BotErrors import *
from GeoffreyApp.api.discord_bot.BotErrors import *
from django.db.models import Q, F
from GeoffreyApp.models import *
from GeoffreyApp.api.bot.MinecraftAccountInfoGrabber import *
from GeoffreyApp.api.discord_bot.MinecraftAccountInfoGrabber import *
post_list = []
get_list = []

View File

@ -2,7 +2,7 @@ from simplejson.errors import JSONDecodeError
import requests
from GeoffreyApp.api.bot.BotErrors import UsernameLookupFailed
from GeoffreyApp.api.discord_bot.BotErrors import UsernameLookupFailed
uuid_lookup_url = 'https://api.mojang.com/users/profiles/minecraft/{}'
username_lookup_url = 'https://api.mojang.com/user/profiles/{}/names'

View File

@ -8,7 +8,7 @@ import logging.handlers as handlers
from sys import stdout
from os import path
from GeoffreyApp.api.bot.BotErrors import *
from GeoffreyApp.api.discord_bot.BotErrors import *
from GeoffreyApp.api.commands import *
from django.conf import settings
@ -16,9 +16,9 @@ logger = logging.getLogger(__name__)
description = '''
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.
At some point, she was to become an airhorn discord_bot. Now, they know where your stuff is.
Please respect Geoffrey, the bot is very sensitive.
Please respect Geoffrey, the discord_bot is very sensitive.
All commands must be prefaced with '?'
@ -26,7 +26,7 @@ If have a suggestion or if something is borked, you can PM my ding dong of a cre
*You must use ?register before adding things to Geoffrey*
For a better a explanation on how this bot works go the following link:
For a better a explanation on how this discord_bot works go the following link:
https://github.com/joeyahines/Geoffrey/blob/master/README.md
'''
@ -132,7 +132,7 @@ class GeoffreyBot(commands.Bot):
def setup_logging():
discord_logger = logging.getLogger('discord')
discord_logger.setLevel(logging.INFO)
bot_info_logger = logging.getLogger('GeoffreyApp.api.bot.bot')
bot_info_logger = logging.getLogger('GeoffreyApp.api.discord_bot.discord_bot')
bot_info_logger.setLevel(logging.INFO)
console = logging.StreamHandler(stdout)
console.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
@ -141,6 +141,7 @@ def setup_logging():
def start_bot():
asyncio.set_event_loop(asyncio.new_event_loop())
bot = None
try:
bot = GeoffreyBot()
@ -148,7 +149,7 @@ def start_bot():
@bot.command(pass_context=True)
async def test(ctx):
"""
Checks if the bot is alive.
Checks if the discord_bot is alive.
"""
await ctx.send('I\'m here you ding dong')

View File

@ -25,7 +25,7 @@ class Add_Commands:
try:
player_name = get_nickname(ctx.message.author, self.bot.special_users)
self.bot.bot_commands.register(player_name, ctx.message.author.id)
await ctx.send('{}, you have been added to the database. Use ?help to see all the commands this bot can do.'
await ctx.send('{}, you have been added to the database. Use ?help to see all the commands this discord_bot can do.'
.format(ctx.message.author.mention))
except AttributeError:
raise NotOnServerError

View File

@ -34,14 +34,14 @@ class Admin_Commands:
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__())
error_str = 'the discord_bot encountered the following error: {}'.format(error.__str__())
await ctx.send('{}, {}'.format(ctx.message.author.mention, error_str))
@commands.command(pass_context=True)
async def test(self, ctx):
"""
Checks if the bot is alive.
Checks if the discord_bot is alive.
"""
if check_mod(ctx.message.author, self.bot.admin_users):
await ctx.send('I\'m here you ding dong')
@ -123,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 discord_bot
"""
status = get_name(args)
await self.bot.change_presence(activity=Game(status))

View File

@ -1,7 +1,7 @@
from discord.ext import commands
from geoffrey.BotErrors import *
from geoffrey.DiscordHelperFunctions import *
from GeoffreyApp.api.discord_bot.BotErrors import *
from GeoffreyApp.api.discord_bot.DiscordHelperFunctions import *
class Search_Commands:

View File

@ -2,7 +2,7 @@ from django.views.generic import View
from django.http import JsonResponse
import GeoffreyApp.api.commands as commands
from GeoffreyApp.api.bot.BotErrors import *
from GeoffreyApp.api.discord_bot.BotErrors import *
def run_command(request, command, command_list):

View File

@ -1,14 +0,0 @@
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Geoffrey.settings")
if __name__ == '__main__':
import django
django.setup()
from GeoffreyApp.api.bot.bot import start_bot
start_bot()

View File

@ -4,6 +4,7 @@ from sys import maxsize
# Create your models here.
class Player(models.Model):
name = models.CharField(max_length=30, unique=True)
mc_uuid = models.CharField(max_length=36, unique=True)

View File

@ -1,7 +1,14 @@
from django.urls import path
from multiprocessing import Process
from GeoffreyApp.api.discord_bot.bot import start_bot
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
]
p = Process(target=start_bot)
p.start()
print("Thread start...")