generated from HoloTech/twitch-bot-template
Compare commits
12 Commits
c114f1a54a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f2582d0ae | |||
| a107292233 | |||
| deb812bf6f | |||
| 985335d33b | |||
| 4130b0ecca | |||
| 9c81518623 | |||
| 6d30bc87de | |||
| 0dc2dc82d1 | |||
| ce07a1e89e | |||
| 38ba997dbe | |||
| 9209dbaa8d | |||
| d71a40965e |
@@ -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');
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[BOT]
|
||||
prefix = ?
|
||||
bot_id =
|
||||
owner_id =
|
||||
|
||||
ALSO_READ = config/secrets.conf
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[CROCBOT]
|
||||
[BOT]
|
||||
client_id =
|
||||
client_secret =
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Submodule src/modules/profiles updated: 543a65b7fb...0363dc2bcd
Submodule src/modules/subathon updated: 0ea90b5cd2...11c77bcc89
Submodule src/modules/tracker updated: 094b1e3c57...f853f01bf8
Reference in New Issue
Block a user