Bot now starts automatically
+subprocess kicked off when URLs are being loaded +renamed bot dir to discord_botdoc_update
parent
803d25d67f
commit
37dd0950a5
|
@ -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 django.db.models import Q, F
|
||||||
from GeoffreyApp.models import *
|
from GeoffreyApp.models import *
|
||||||
from GeoffreyApp.api.bot.MinecraftAccountInfoGrabber import *
|
from GeoffreyApp.api.discord_bot.MinecraftAccountInfoGrabber import *
|
||||||
|
|
||||||
post_list = []
|
post_list = []
|
||||||
get_list = []
|
get_list = []
|
||||||
|
|
|
@ -2,7 +2,7 @@ from simplejson.errors import JSONDecodeError
|
||||||
|
|
||||||
import requests
|
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/{}'
|
uuid_lookup_url = 'https://api.mojang.com/users/profiles/minecraft/{}'
|
||||||
username_lookup_url = 'https://api.mojang.com/user/profiles/{}/names'
|
username_lookup_url = 'https://api.mojang.com/user/profiles/{}/names'
|
|
@ -8,7 +8,7 @@ import logging.handlers as handlers
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
from GeoffreyApp.api.bot.BotErrors import *
|
from GeoffreyApp.api.discord_bot.BotErrors import *
|
||||||
from GeoffreyApp.api.commands import *
|
from GeoffreyApp.api.commands import *
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
description = '''
|
description = '''
|
||||||
Geoffrey (pronounced JOFF-ree) started his life as an inside joke none of you will understand.
|
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 '?'
|
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*
|
*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
|
https://github.com/joeyahines/Geoffrey/blob/master/README.md
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -132,7 +132,7 @@ class GeoffreyBot(commands.Bot):
|
||||||
def setup_logging():
|
def setup_logging():
|
||||||
discord_logger = logging.getLogger('discord')
|
discord_logger = logging.getLogger('discord')
|
||||||
discord_logger.setLevel(logging.INFO)
|
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)
|
bot_info_logger.setLevel(logging.INFO)
|
||||||
console = logging.StreamHandler(stdout)
|
console = logging.StreamHandler(stdout)
|
||||||
console.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
|
console.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
|
||||||
|
@ -141,6 +141,7 @@ def setup_logging():
|
||||||
|
|
||||||
|
|
||||||
def start_bot():
|
def start_bot():
|
||||||
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||||
bot = None
|
bot = None
|
||||||
try:
|
try:
|
||||||
bot = GeoffreyBot()
|
bot = GeoffreyBot()
|
||||||
|
@ -148,7 +149,7 @@ def start_bot():
|
||||||
@bot.command(pass_context=True)
|
@bot.command(pass_context=True)
|
||||||
async def test(ctx):
|
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')
|
await ctx.send('I\'m here you ding dong')
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Add_Commands:
|
||||||
try:
|
try:
|
||||||
player_name = get_nickname(ctx.message.author, self.bot.special_users)
|
player_name = get_nickname(ctx.message.author, self.bot.special_users)
|
||||||
self.bot.bot_commands.register(player_name, ctx.message.author.id)
|
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))
|
.format(ctx.message.author.mention))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise NotOnServerError
|
raise NotOnServerError
|
|
@ -34,14 +34,14 @@ class Admin_Commands:
|
||||||
error_str = 'that player does not have a location by that name.'
|
error_str = 'that player does not have a location by that name.'
|
||||||
|
|
||||||
if error_str is "":
|
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))
|
await ctx.send('{}, {}'.format(ctx.message.author.mention, error_str))
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def test(self, ctx):
|
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):
|
if check_mod(ctx.message.author, self.bot.admin_users):
|
||||||
await ctx.send('I\'m here you ding dong')
|
await ctx.send('I\'m here you ding dong')
|
||||||
|
@ -123,7 +123,7 @@ class Admin_Commands:
|
||||||
@mod.command(pass_context=True)
|
@mod.command(pass_context=True)
|
||||||
async def status(self, ctx, *args):
|
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)
|
status = get_name(args)
|
||||||
await self.bot.change_presence(activity=Game(status))
|
await self.bot.change_presence(activity=Game(status))
|
|
@ -1,7 +1,7 @@
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from geoffrey.BotErrors import *
|
from GeoffreyApp.api.discord_bot.BotErrors import *
|
||||||
from geoffrey.DiscordHelperFunctions import *
|
from GeoffreyApp.api.discord_bot.DiscordHelperFunctions import *
|
||||||
|
|
||||||
|
|
||||||
class Search_Commands:
|
class Search_Commands:
|
|
@ -2,7 +2,7 @@ from django.views.generic import View
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
|
|
||||||
import GeoffreyApp.api.commands as commands
|
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):
|
def run_command(request, command, command_list):
|
||||||
|
|
|
@ -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()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ from sys import maxsize
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
|
||||||
|
|
||||||
class Player(models.Model):
|
class Player(models.Model):
|
||||||
name = models.CharField(max_length=30, unique=True)
|
name = models.CharField(max_length=30, unique=True)
|
||||||
mc_uuid = models.CharField(max_length=36, unique=True)
|
mc_uuid = models.CharField(max_length=36, unique=True)
|
||||||
|
|
7
urls.py
7
urls.py
|
@ -1,7 +1,14 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
from multiprocessing import Process
|
||||||
|
from GeoffreyApp.api.discord_bot.bot import start_bot
|
||||||
|
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.index, name='index'),
|
path('', views.index, name='index'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
p = Process(target=start_bot)
|
||||||
|
p.start()
|
||||||
|
print("Thread start...")
|
Loading…
Reference in New Issue