from lib.config import config
from lib.bot import bot

VERSION = config.get_value('version')

bot.run(VERSION)
Exemple #2
0
import os
import sys

__DIR_PATH = os.path.dirname(os.path.realpath(__file__))
__ROOT_PATH = os.path.normpath(os.path.join(__DIR_PATH, '..'))
if __ROOT_PATH not in sys.path:
    sys.path.append(__ROOT_PATH)

import names
import random
import secrets
from lib.config import config
from lib.db_manager import db_manager_no_lock
from lib.db_manager import db_create_constants as CREATE_CONSTANTS

manager = db_manager_no_lock.DatabaseManager(config.get_value(config.DB_NAME))
manager.create_all_tables()

try:
    while True:
        seller_email = input('Seller email: ')
        seller_exists = (manager.has_rows('SELLER', '*', " email = '{}' ".format(seller_email)) > 0)

        if not seller_exists:
            address = input('Address: ')
            phone_number = input('Phone number: ')
            print('Creating seller...')
            manager.insert_seller(seller_email, address, phone_number)
            print('There is now a seller!')

        quantity = input('Quantity: ')
Exemple #3
0
from unicodedata import *
from glob import glob

from apscheduler.schedulers.asyncio import AsyncIOScheduler
from discord.ext.commands.errors import BadArgument, CommandNotFound, MissingRequiredArgument
from discord.ext.commands import Bot as BotBase
from discord.ext.commands import Context
from discord.errors import Forbidden
from discord import Intents, Embed

from lib.config import config
from lib.db import db

COGS = [path.split('\\')[-1][:-3] for path in glob('./lib/cogs/*.py')]
IGNORE_EXCEPTIONS = (CommandNotFound, BadArgument)
OWNER_IDS = config.get_value('ownerids')
PREFIX = config.get_value('prefix')

class Ready(object):
    def __init__(self) -> None:
        for cog in COGS:
            setattr(self, cog, False)
    
    def ready_up(self, cog):
        setattr(self, cog, True)
        print(f'{cog.capitalize()} cog ready')
    
    def all_ready(self):
        return all([getattr(self, cog) for cog in COGS])

Exemple #4
0
import os
import sys

__DIR_PATH = os.path.dirname(os.path.realpath(__file__))
__ROOT_PATH = os.path.normpath(os.path.join(__DIR_PATH, '../..'))
if __ROOT_PATH not in sys.path:
    sys.path.append(__ROOT_PATH)

import flask
import os
from lib.config import config
from lib.db_manager import db_manager

API_VIEWS = flask.Blueprint('api_views', __name__)
__DATABASE = db_manager.DatabaseManager(config.get_value(config.DB_NAME))


@API_VIEWS.route('/get_all_items')
def all_items():
    items = __DATABASE.retrieve_all_items()
    return flask.jsonify(items)


@API_VIEWS.route('/get_popular_items/<int:n>')
def popular_items(n):
    items = __DATABASE.retrieve_popular_items(n)
    return flask.jsonify(items)


@API_VIEWS.route('/get_sellers')
def all_sellers():
Exemple #5
0
import os
import sys

__DIR_PATH = os.path.dirname(os.path.realpath(__file__))
__ROOT_PATH = os.path.normpath(os.path.join(__DIR_PATH, '../..'))
if __ROOT_PATH not in sys.path:
    sys.path.append(__ROOT_PATH)

from typing import Tuple
from lib.config import config
from lib.db_manager import db_manager
from lib.db_manager import db_create_constants
from lib.security import security_utils
import passlib.hash

__AUTH_MANAGER = db_manager.DatabaseManager(config.get_value(config.DB_NAME))


def is_registered(username: str) -> bool:
    "Check if user with username, username, is registered."
    return __AUTH_MANAGER.has_rows('login_info', '*',
                                   ' email = "{}" '.format(username))


def is_customer(username: str) -> bool:
    "Check if user is a customer."
    cond: str = ' email = "{}" AND role = "CUSTOMER" '.format(username)
    return __AUTH_MANAGER.has_rows('login_info', '*', cond)


def is_seller(username: str) -> bool: