feat(chat): support BanchoBot
This commit is contained in:
30
app/service/create_banchobot.py
Normal file
30
app/service/create_banchobot.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from app.const import BANCHOBOT_ID
|
||||
from app.database.lazer_user import User
|
||||
from app.database.statistics import UserStatistics
|
||||
from app.dependencies.database import engine
|
||||
from app.models.score import GameMode
|
||||
|
||||
from sqlmodel import exists, select
|
||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||
|
||||
|
||||
async def create_banchobot():
|
||||
async with AsyncSession(engine) as session:
|
||||
is_exist = (await session.exec(select(exists()).where(User.id == 2))).first()
|
||||
if not is_exist:
|
||||
banchobot = User(
|
||||
username="BanchoBot",
|
||||
email="banchobot@ppy.sh",
|
||||
is_bot=True,
|
||||
pw_bcrypt="0",
|
||||
id=BANCHOBOT_ID,
|
||||
avatar_url="https://a.ppy.sh/3",
|
||||
country_code="SH",
|
||||
website="https://twitter.com/banchoboat",
|
||||
)
|
||||
session.add(banchobot)
|
||||
statistics = UserStatistics(user_id=BANCHOBOT_ID, mode=GameMode.OSU)
|
||||
session.add(statistics)
|
||||
await session.commit()
|
||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
from datetime import UTC, datetime, timedelta
|
||||
import json
|
||||
|
||||
from app.const import BANCHOBOT_ID
|
||||
from app.database.playlists import Playlist
|
||||
from app.database.room import Room
|
||||
from app.dependencies.database import engine, get_redis
|
||||
@@ -26,12 +27,12 @@ async def create_daily_challenge_room(
|
||||
return await create_playlist_room(
|
||||
session=session,
|
||||
name=str(today),
|
||||
host_id=3,
|
||||
host_id=BANCHOBOT_ID,
|
||||
playlist=[
|
||||
Playlist(
|
||||
id=0,
|
||||
room_id=0,
|
||||
owner_id=3,
|
||||
owner_id=BANCHOBOT_ID,
|
||||
ruleset_id=ruleset_id,
|
||||
beatmap_id=beatmap,
|
||||
required_mods=required_mods,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from app.config import settings
|
||||
from app.const import BANCHOBOT_ID
|
||||
from app.database.lazer_user import User
|
||||
from app.database.statistics import UserStatistics
|
||||
from app.dependencies.database import engine
|
||||
@@ -15,6 +16,9 @@ async def create_rx_statistics():
|
||||
async with AsyncSession(engine) as session:
|
||||
users = (await session.exec(select(User.id))).all()
|
||||
for i in users:
|
||||
if i == BANCHOBOT_ID:
|
||||
continue
|
||||
|
||||
if settings.enable_rx:
|
||||
for mode in (
|
||||
GameMode.OSURX,
|
||||
|
||||
Reference in New Issue
Block a user