|
|
@ -4,12 +4,13 @@ Bot commands.
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
from random import choice
|
|
|
|
from random import choice
|
|
|
|
|
|
|
|
|
|
|
|
from discord import Embed, Intents
|
|
|
|
from discord import Embed, Intents
|
|
|
|
from discord.ext import commands
|
|
|
|
from discord.ext import commands
|
|
|
|
from settings.config import IMAGE_TYPES, OW_API_CONFIG, PERMISSIONS
|
|
|
|
from settings.config import IMAGE_TYPES, OW_API_CONFIG, PERMISSIONS, QUOTE_STACK
|
|
|
|
|
|
|
|
|
|
|
|
from utils.database import (count_quotes, count_quotes_user, get_by_id, get_quote_contains,
|
|
|
|
from utils.database import (count_quotes, count_quotes_user, get_by_id, get_quote_contains,
|
|
|
|
get_quotes, remove_quote, set_quote)
|
|
|
|
get_quotes, remove_quote, set_quote)
|
|
|
@ -21,8 +22,8 @@ from utils.weather import displayweather, getweatherdata
|
|
|
|
client = commands.Bot(command_prefix='--', intents=Intents.all())
|
|
|
|
client = commands.Bot(command_prefix='--', intents=Intents.all())
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
quote_id_stack = []
|
|
|
|
with open(QUOTE_STACK, mode='r') as f:
|
|
|
|
|
|
|
|
quote_id_stack = json.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
@client.command(aliases=['q'])
|
|
|
|
@client.command(aliases=['q'])
|
|
|
|
async def quote(bot: object, *quote: str) -> str:
|
|
|
|
async def quote(bot: object, *quote: str) -> str:
|
|
|
@ -74,6 +75,10 @@ async def random_quote(bot: object) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
if stack_len >= stack_limit:
|
|
|
|
if stack_len >= stack_limit:
|
|
|
|
quote_id_stack.pop(0)
|
|
|
|
quote_id_stack.pop(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Writes to persistent stackfile
|
|
|
|
|
|
|
|
with open(QUOTE_STACK, mode='w') as f:
|
|
|
|
|
|
|
|
json.dump(quote_id_stack, f)
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# To image links.
|
|
|
|
# To image links.
|
|
|
|