Compare commits

..

12 Commits

Author SHA1 Message Date
2f2582d0ae routine: Update subathon module pointer 2025-10-30 23:43:59 +10:00
a107292233 fix: Typo in join column name 2025-10-30 22:05:31 +10:00
deb812bf6f fix: Logger discord import 2025-09-24 23:33:43 +10:00
985335d33b Update subathon module pointer 2025-09-24 23:32:15 +10:00
4130b0ecca Update subathon pointer 2025-09-22 23:32:14 +10:00
9c81518623 Update example config 2025-09-22 23:29:48 +10:00
6d30bc87de routine: Update profiles pointer. 2025-09-02 19:27:36 +10:00
0dc2dc82d1 Update subathon pointer. 2025-09-02 10:40:16 +10:00
ce07a1e89e Temporary fix for transaction issues. 2025-09-02 08:57:26 +10:00
38ba997dbe Patch for new aio adapter. 2025-09-02 08:36:03 +10:00
9209dbaa8d Fix typos. 2025-09-02 07:59:40 +10:00
d71a40965e Update submodule pointers. 2025-09-02 07:15:56 +10:00
9 changed files with 24 additions and 17 deletions

View File

@@ -4,7 +4,7 @@ CREATE TABLE version_history(
from_version INTEGER NOT NULL,
to_version INTEGER NOT NULL,
author TEXT NOT NULL,
_timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW(),
_timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
INSERT INTO version_history (component, from_version, to_version, author) VALUES ('ROOT', 0, 1, 'Initial Creation');

View File

@@ -1,6 +1,7 @@
[BOT]
prefix = ?
bot_id =
owner_id =
ALSO_READ = config/secrets.conf

View File

@@ -1,4 +1,4 @@
[CROCBOT]
[BOT]
client_id =
client_secret =

View File

@@ -12,11 +12,16 @@ from modules import twitch_setup
logger = logging.getLogger(__name__)
class FixedAiohttpAdapter(AiohttpAdapter):
def _find_redirect(self, request):
return self.redirect_url
async def main():
db = Database(conf.data['args'])
async with db.open():
adapter = AiohttpAdapter(
adapter = FixedAiohttpAdapter(
host=conf.bot.get('wshost', None),
port=conf.bot.getint('wsport', None),
domain=conf.bot.get('wsdomain', None),

View File

@@ -178,17 +178,15 @@ class Bot(commands.Bot):
# Save the token and scopes to data
# Wrap this in a transaction so if it fails halfway we rollback correctly
async with self.dbconn.connection() as conn:
self.dbconn.conn = conn
async with conn.transaction():
row = await UserAuth.fetch_or_create(userid, token=token, refresh_token=refresh)
if row.token != token or row.refresh_token != refresh:
await row.update(token=token, refresh_token=refresh)
await self.data.user_auth_scopes.delete_where(userid=userid)
await self.data.user_auth_scopes.insert_many(
('userid', 'scope'),
*((userid, scope) for scope in new_scopes)
)
# TODO
row = await UserAuth.fetch_or_create(userid, token=token, refresh_token=refresh)
if row.token != token or row.refresh_token != refresh:
await row.update(token=token, refresh_token=refresh)
await self.data.user_auth_scopes.delete_where(userid=userid)
await self.data.user_auth_scopes.insert_many(
('userid', 'scope'),
*((userid, scope) for scope in new_scopes)
)
logger.info("Updated auth token for user '%s' with scopes: %s", resp.user_id, ', '.join(new_scopes))
return resp

View File

@@ -14,6 +14,7 @@ import aiohttp
from .config import conf
from utils.ratelimits import Bucket, BucketOverFull, BucketFull
from utils.lib import utc_now
log_logger = logging.getLogger(__name__)
@@ -365,6 +366,8 @@ class WebHookHandler(logging.StreamHandler):
await self._send(batched)
async def _send(self, message, as_file=False):
import discord
from discord import File
try:
self.bucket.request()
except BucketOverFull: