feat: remove !h and make the bot have an in-memory dict of greeted users instead of using the backoff service
This commit is contained in:
parent
48a3235323
commit
b2185f4174
52 changed files with 404 additions and 353 deletions
|
|
@ -1,41 +0,0 @@
|
|||
import secrets
|
||||
|
||||
from litestar import MediaType, get
|
||||
from litestar.datastructures.cookie import Cookie
|
||||
from litestar.response import Redirect, Template
|
||||
|
||||
from src.huesoporro.actions.authenticate import AuthenticateAction
|
||||
from src.huesoporro.settings import Settings
|
||||
|
||||
|
||||
@get(path="/o/code")
|
||||
async def get_code(code: str, authenticate_action: AuthenticateAction) -> Redirect:
|
||||
token = await authenticate_action.run(code)
|
||||
return Redirect(
|
||||
"/",
|
||||
cookies=[
|
||||
Cookie(
|
||||
key="huesoporroAuth",
|
||||
value=token,
|
||||
expires=604800, # 1 week
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@get(
|
||||
"/login",
|
||||
media_type=MediaType.HTML,
|
||||
)
|
||||
async def login(s: Settings) -> Template:
|
||||
scopes = "+".join(s.twitch_scopes)
|
||||
return Template(
|
||||
"login.html",
|
||||
context={
|
||||
"twitch_login_url": "https://id.twitch.tv/oauth2/authorize?response_type=code"
|
||||
f"&client_id={s.twitch_client_id}"
|
||||
f"&redirect_uri={s.server_hostname}o/code"
|
||||
f"&scope={scopes}"
|
||||
f"&state={secrets.token_urlsafe(32)}"
|
||||
},
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue