Compare commits
4 Commits
2e02f39c29
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 52ba72b584 | |||
| df0c6451fc | |||
| e473de3b4b | |||
| 1fb5c45b5b |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +1,6 @@
|
|||||||
[submodule "src/data"]
|
[submodule "src/data"]
|
||||||
path = src/data
|
path = src/data
|
||||||
url = https://git.thewisewolf.dev/HoloTech/psqlmapper.git
|
url = https://git.thewisewolf.dev/HoloTech/psqlmapper.git
|
||||||
|
[submodule "src/modules/profiles"]
|
||||||
|
path = src/modules/profiles
|
||||||
|
url = https://git.thewisewolf.dev/HoloTech/profiles-plugin.git
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ CREATE TABLE version_history(
|
|||||||
from_version INTEGER NOT NULL,
|
from_version INTEGER NOT NULL,
|
||||||
to_version INTEGER NOT NULL,
|
to_version INTEGER NOT NULL,
|
||||||
author TEXT 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');
|
INSERT INTO version_history (component, from_version, to_version, author) VALUES ('ROOT', 0, 1, 'Initial Creation');
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,15 @@ bot_id =
|
|||||||
|
|
||||||
ALSO_READ = config/secrets.conf
|
ALSO_READ = config/secrets.conf
|
||||||
|
|
||||||
wshost = localhost
|
[TWTICH]
|
||||||
wsport = 4343
|
host =
|
||||||
wsdomain = localhost:4343
|
port =
|
||||||
|
domain =
|
||||||
|
redirect_path =
|
||||||
|
oauth_path =
|
||||||
|
evenstub_path =
|
||||||
|
|
||||||
|
webhooks =
|
||||||
|
|
||||||
[LOGGING]
|
[LOGGING]
|
||||||
general_log =
|
general_log =
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
[CROCBOT]
|
[BOT]
|
||||||
client_id =
|
client_id =
|
||||||
client_secret =
|
client_secret =
|
||||||
|
|
||||||
|
[TWITCH]
|
||||||
|
eventsub_secret =
|
||||||
|
|
||||||
[DATA]
|
[DATA]
|
||||||
args =
|
args =
|
||||||
appid =
|
appid =
|
||||||
|
|||||||
22
src/bot.py
22
src/bot.py
@@ -13,6 +13,10 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class ProxyAiohttpAdapter(AiohttpAdapter):
|
class ProxyAiohttpAdapter(AiohttpAdapter):
|
||||||
|
"""
|
||||||
|
Overrides the computed AiohttpAdapter redirect_url
|
||||||
|
to always use provided domain.
|
||||||
|
"""
|
||||||
def _find_redirect(self, request):
|
def _find_redirect(self, request):
|
||||||
return self.redirect_url
|
return self.redirect_url
|
||||||
|
|
||||||
@@ -21,18 +25,26 @@ async def main():
|
|||||||
db = Database(conf.data['args'])
|
db = Database(conf.data['args'])
|
||||||
|
|
||||||
async with db.open():
|
async with db.open():
|
||||||
adapter = ProxyAiohttpAdapter(
|
adapter_keys = (
|
||||||
host=conf.bot.get('wshost', None),
|
'host', 'domain', 'port',
|
||||||
port=conf.bot.getint('wsport', None),
|
'redirect_path', 'oauth_path', 'eventsub_path',
|
||||||
domain=conf.bot.get('wsdomain', None),
|
'eventsub_secret',
|
||||||
eventsub_secret=conf.bot.get('eventsub_secret', None)
|
|
||||||
)
|
)
|
||||||
|
adapter_args = {}
|
||||||
|
for key in adapter_keys:
|
||||||
|
value = conf.twitch.get(key, '').strip()
|
||||||
|
if value:
|
||||||
|
if key == 'port':
|
||||||
|
value = int(value)
|
||||||
|
adapter_args[key] = value
|
||||||
|
adapter = ProxyAiohttpAdapter(**adapter_args)
|
||||||
|
|
||||||
bot = Bot(
|
bot = Bot(
|
||||||
config=conf,
|
config=conf,
|
||||||
dbconn=db,
|
dbconn=db,
|
||||||
adapter=adapter,
|
adapter=adapter,
|
||||||
setup=twitch_setup,
|
setup=twitch_setup,
|
||||||
|
using_webhooks=conf.twitch.getboolean('webhooks', False)
|
||||||
)
|
)
|
||||||
|
|
||||||
async with websockets.serve(sockets.root_handler, '', conf.wserver.getint('port')):
|
async with websockets.serve(sockets.root_handler, '', conf.wserver.getint('port')):
|
||||||
|
|||||||
@@ -29,10 +29,7 @@ class Bot(commands.Bot):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
# Whether we should do eventsub via webhooks or websockets
|
# Whether we should do eventsub via webhooks or websockets
|
||||||
if config.bot.get('eventsub_secret', None):
|
self.using_webhooks = kwargs.get('using_webhooks', False)
|
||||||
self.using_webhooks = True
|
|
||||||
else:
|
|
||||||
self.using_webhooks = False
|
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
self.dbconn = dbconn
|
self.dbconn = dbconn
|
||||||
|
|||||||
@@ -5,7 +5,5 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
async def twitch_setup(bot: 'Bot'):
|
async def twitch_setup(bot: 'Bot'):
|
||||||
# Import and run setup methods from each module
|
from . import profiles
|
||||||
# from . import module
|
await profiles.twitch_setup(bot)
|
||||||
# await module.twitch_setup(bot)
|
|
||||||
pass
|
|
||||||
|
|||||||
1
src/modules/profiles
Submodule
1
src/modules/profiles
Submodule
Submodule src/modules/profiles added at 0363dc2bcd
Reference in New Issue
Block a user