Пример #1
0
def main():
    args = parse_args()
    bot_config, web_config, db_config = load_config(args.config_path)

    web_app = init_web_app(web_config)

    globibot = Globibot(bot_config, db_config, web_app, args.plugin_path)

    run_async(web_app.run(), globibot.boot())
Пример #2
0
def main():
    args = parse_args()
    bot_config, web_config, db_config = load_config(args.config_path)

    web_app = init_web_app(web_config)

    globibot = Globibot(
        bot_config,
        db_config,
        web_app,
        args.plugin_path
    )

    run_async(
        web_app.run(),
        globibot.boot()
    )
Пример #3
0
async def notify_start_handle():
    from utils.app import Application
    app = Application.current()

    async def _f():
        f = await _notify_start_handle()
        print(f)

    app.timers["notice"] = run_async(_f())
Пример #4
0
                    #if q hasnt been solved but is correct, set solved, update rankings
                    await conn.execute(
                        f'UPDATE team{team_id[0]} SET solved=$1, attempts=$2 WHERE problem_no=$3',
                        True, attempts, problem_no)
                    await conn.execute(
                        f'UPDATE rankings_2022 SET score=score + 1 WHERE team_id=$1',
                        team_id[0])
                    print("TI", team_id[0])
                print("TEAM ID: ", team_id[0], "ATTEMPTS: ", attempts)
            else:
                if solved:
                    await conn.execute(
                        f'UPDATE team{team_id[0]} SET attempts=$1, solved=$2 where problem_no=$3',
                        len(answers), False, problem_no)
                    await conn.execute(
                        f'UPDATE rankings_2022 SET score=score - 1 WHERE team_id=$1',
                        team_id[0])

        # everything below here clears attempts for a certain q. if ur using this part, comment out above
        #data = await conn.fetchrow(f'SELECT * from team{team_id[0]} WHERE problem_no=$1', problem_no)
        #solved = data['solved']
        #await conn.execute(f'UPDATE team{team_id[0]} ' + "SET answers='{}', attempts=0, solved='f' WHERE problem_no=$1", problem_no)
        #if solved:
        #await conn.execute('UPDATE rankings_2022 SET score=score - 1 WHERE team_id=$1', team_id[0])
        #print("SOLVED: ", team_id[0])

    # print(f"Cleared {problem_no} for TEAM ID: {team_id[0]}")


run_async(execute())
Пример #5
0
def log_post(data):
    run_async(__log_post(data))
Пример #6
0
from decimal import Decimal
from utils import get_connection, run_async

import csv

with open('../data/2022/opho_ans.csv') as csvin:
    questions = [(i + 1, Decimal(line[0].rstrip()), Decimal(line[1].rstrip()))
                 for i, line in enumerate(csv.reader(csvin))]
# print(questions)


async def insert_problems():
    conn = await get_connection()
    insert_problem_query = 'INSERT INTO problems(problem_no, answer,error_bound) VALUES ($1, $2,$3)'
    pr_query = 'UPDATE problems SET answer=$2, error_bound=$3 WHERE problem_no=$1'
    for question_no, answer, error in questions:
        await conn.execute(pr_query, question_no, answer, error)
        print(f"PR: {question_no} ANSWER: {answer} ERROR bound {error}")


run_async(insert_problems())
Пример #7
0
def dingding_post(data):
    run_async(_dingding_post(data))
Пример #8
0
from utils import run_async, get_connection


async def initialize_team(teamname, password, problem_number):
    conn = await get_connection()
    insert_and_return = f"""
        INSERT INTO user_details_2022(username, password) VALUES ('{teamname}', '{password}') RETURNING user_id
    """

    team_id = await conn.fetchval(insert_and_return)

    print("TEAM ID:", team_id)

    create_table = f"""
        CREATE TABLE team{team_id}(problem_no integer,solved BOOLEAN NOT NULL, attempts integer, answers decimal[], timestamp timestamp);
    """
    insert_query = f"""
        INSERT INTO team{team_id} (problem_no, solved, attempts) VALUES """ + ', '.join(
        f"({number}, FALSE, 0)"
        for number in range(1, problem_number + 1)) + ";"

    insert_rankings = f"""INSERT INTO rankings_2022(team_id, score) VALUES ($1, 0)"""
    await conn.execute(create_table)
    await conn.execute(insert_query)
    await conn.execute(insert_rankings, team_id)


run_async(initialize_team("Epsilon", "playboicarti", 35))