mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-27 16:10:30 +08:00
pre-commit changes
This commit is contained in:
@@ -7,7 +7,14 @@ import oasst_backend.models.db_payload as db_payload
|
||||
from loguru import logger
|
||||
from oasst_backend.exceptions import OasstError, OasstErrorCode
|
||||
from oasst_backend.journal_writer import JournalWriter
|
||||
from oasst_backend.models import ApiClient, Person, Post, PostReaction, TextLabels, WorkPackage
|
||||
from oasst_backend.models import (
|
||||
ApiClient,
|
||||
Person,
|
||||
Post,
|
||||
PostReaction,
|
||||
TextLabels,
|
||||
WorkPackage,
|
||||
)
|
||||
from oasst_backend.models.payload_column_type import PayloadContainer
|
||||
from oasst_shared.schemas import protocol as protocol_schema
|
||||
from sqlmodel import Session, func
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
TOKEN=<discord bot token>
|
||||
DECLARE_GLOBAL_COMMANDS=<testing guild id>
|
||||
OWNER_IDS=<your user id>
|
||||
PREFIX="./"
|
||||
PREFIX="./"
|
||||
|
||||
@@ -7,4 +7,4 @@ __pycache__/
|
||||
.env
|
||||
|
||||
# Database files
|
||||
*.db
|
||||
*.db
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
"""The official Open-Assistant Discord Bot."""
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Entry point for the bot."""
|
||||
import logging
|
||||
import os
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Bot logic."""
|
||||
import aiosqlite
|
||||
import hikari
|
||||
@@ -26,7 +26,7 @@ async def on_starting(event: hikari.StartingEvent):
|
||||
miru.install(bot) # component handler
|
||||
bot.load_extensions_from("./bot/extensions") # load extensions
|
||||
|
||||
bot.d.db = await aiosqlite.connect("./bot/db/database.db") # TODO: Update
|
||||
bot.d.db = await aiosqlite.connect("./bot/db/database.db")
|
||||
await bot.d.db.executescript(open("./bot/db/schema.sql").read())
|
||||
await bot.d.db.commit()
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Configuration for the bot."""
|
||||
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
from os import getenv
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from dotenv import load_dotenv # type: ignore
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Database schemas."""
|
||||
from aiosqlite import Row, Connection
|
||||
from pydantic import BaseModel
|
||||
import typing as t
|
||||
|
||||
from aiosqlite import Connection, Row
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class GuildSettings(BaseModel):
|
||||
"""Guild settings."""
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# TODO: Convert file to markdown
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Example plugin for reference.
|
||||
|
||||
@@ -8,13 +8,14 @@ import lightbulb
|
||||
import miru
|
||||
from aiosqlite import Connection
|
||||
|
||||
from bot.db.schemas import GuildSettings
|
||||
from bot.utils import EMPTY
|
||||
|
||||
plugin = lightbulb.Plugin(
|
||||
"TextLabels",
|
||||
)
|
||||
plugin.add_checks(lightbulb.guild_only) # Context menus are only enabled in guilds
|
||||
|
||||
from bot.utils import EMPTY
|
||||
from bot.db.schemas import GuildSettings
|
||||
|
||||
DISCORD_GRAY = 0x2F3136
|
||||
|
||||
|
||||
@@ -4,18 +4,18 @@ import asyncio
|
||||
import logging
|
||||
import typing as t
|
||||
from datetime import datetime
|
||||
from aiosqlite import Connection
|
||||
|
||||
import hikari
|
||||
import lightbulb
|
||||
import lightbulb.decorators
|
||||
import miru
|
||||
from aiosqlite import Connection
|
||||
from oasst_shared.schemas import protocol as protocol_schema
|
||||
from oasst_shared.schemas.protocol import TaskRequestType
|
||||
|
||||
from bot.api_client import OasstApiClient, TaskType
|
||||
from bot.utils import EMPTY
|
||||
from bot.db.schemas import GuildSettings
|
||||
from bot.utils import EMPTY
|
||||
|
||||
plugin = lightbulb.Plugin("WorkPlugin")
|
||||
|
||||
@@ -76,7 +76,7 @@ async def _handle_task(ctx: lightbulb.SlashContext, task_type: TaskRequestType)
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
await ctx.author.send("Task timed out. Exiting")
|
||||
# TODO: NACK task maybe?
|
||||
await oasst_api.nack_task(task.id, reason="timed out")
|
||||
return
|
||||
|
||||
# Invalid response
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
nox
|
||||
|
||||
black
|
||||
isort
|
||||
|
||||
codespell
|
||||
flake8
|
||||
pyright
|
||||
isort
|
||||
nox
|
||||
pyright
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
flake8==6.0.0
|
||||
|
||||
# Plugins
|
||||
|
||||
Flake8-pyproject # use the pyproject.toml as the config file
|
||||
flake8-bandit # runs bandit
|
||||
flake8-black # runs black
|
||||
# flake8-broken-line # forbey "\" linebreaks
|
||||
@@ -21,6 +17,10 @@ flake8-mutable # mutable default argument detection
|
||||
flake8-pep3101 # new-style format strings only
|
||||
flake8-print # complain about print statements in code
|
||||
flake8-printf-formatting # forbey printf-style python2 string formatting
|
||||
|
||||
# Plugins
|
||||
|
||||
Flake8-pyproject # use the pyproject.toml as the config file
|
||||
flake8-pytest-style # pytest checks
|
||||
flake8-raise # exception raising linting
|
||||
flake8-use-fstring # format string checking
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Message templates for the discord bot."""
|
||||
import jinja2
|
||||
import typing
|
||||
|
||||
import jinja2
|
||||
from loguru import logger
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Automated linting, formatting, and typechecking."""
|
||||
import nox
|
||||
from nox.sessions import Session
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
hikari # discord framework
|
||||
hikari[speedups]
|
||||
uvloop; os_name != 'nt'
|
||||
hikari-lightbulb # command handler
|
||||
hikari-miru # modals and buttons
|
||||
|
||||
python-dotenv # .env file support
|
||||
aiosqlite # database
|
||||
aiohttp # http client
|
||||
aiohttp[speedups] # speedups for aiohttp
|
||||
loguru
|
||||
aiosqlite # database
|
||||
hikari # discord framework
|
||||
hikari-lightbulb # command handler
|
||||
hikari-miru # modals and buttons
|
||||
hikari[speedups]
|
||||
loguru
|
||||
|
||||
python-dotenv # .env file support
|
||||
uvloop; os_name != 'nt'
|
||||
|
||||
Reference in New Issue
Block a user