Add HeXi bot codebase: custom plugins, web frontends, tests

- hexi core: message handling, rate limiting, cooldown, plugin manager
- Custom plugins: BF stats, daily check-in, quotes, persona cards, etc.
- Community plugins vendored under hexi/plugins with local fixes
- Web admin frontends (learning-chat, persona-admin), unified hexi/web
- Tests for rate_limit/cooldown/memes/persona; poetry.lock

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-09-01 13:13:40 +08:00
co-authored by Claude
parent 1783c60afa
commit b61d09f09f
3201 changed files with 160436 additions and 171 deletions
+30
View File
@@ -0,0 +1,30 @@
import { createContext, useContext, useState, type ReactNode } from 'react'
import { authLogin, clearSession, getUserName, setSession } from '../api/client'
interface AuthState {
token: string
username: string
login: (u: string, p: string) => Promise<void>
logout: () => void
}
const Ctx = createContext<AuthState>({ token: '', username: '', login: async () => {}, logout: () => {} })
export function AuthProvider({ children }: { children: ReactNode }) {
const [token, setToken] = useState(() => localStorage.getItem('hexi_web_token') || '')
const [username, setUsername] = useState(() => localStorage.getItem('hexi_web_username') || '')
const login = async (u: string, p: string) => {
const data = await authLogin(u, p)
setSession(data.token, data.username)
setToken(data.token)
setUsername(data.username)
}
const logout = () => {
clearSession()
setToken('')
setUsername('')
}
return <Ctx.Provider value={{ token, username, login, logout }}>{children}</Ctx.Provider>
}
export const useAuth = () => useContext(Ctx)