A bot specifically for the Adam Learns show (Twitch, Discord, etc.).
This code is publicly viewable, but it isn't exactly "open-source":
.env.example
to another file (e.g. .env.development.local
) and fill out the values.NODE_ENV=development pnpm tsx packages/bots/src/get-tokens.ts
cd packages/web
pnpm run dev
cd packages/bots
NODE_ENV=development pnpm run start
cd packages/database
pnpm run watch
cd packages/youtube-api
pnpm run watch
Just run the pnpm
script from the root package.json
, e.g. pnpm run docker:web
.
pnpm run lint
(optionally with --fix
at the end)pnpm run type-check
docker compose -f ./packages/database/src/test_compose.yml up
bots
package doesn't need a .env.test
file since it doesn't connect to a real database.NODE_ENV=test pnpm test
. If you want to run only certain files, add them like this NODE_ENV=test pnpm test ./packages/bots/src/test/bot.test.ts
.pnpm coverage
, open the results with open coverage/index.html
.cd packages/database
pnpm run kysely-migration-cli create migration-name-with-hyphens
backUpDatabase
in my shell (command defined here)NODE_ENV=development pnpm run kysely-migration-cli latest
.env.example
for how to configure this. However, they won't automatically regenerate types.DATABASE_URL=postgres://postgres:bar@localhost/foo pnpm run kysely-codegen
cp ./node_modules/kysely-codegen/dist/db.d.ts ./src/types/db.d.ts
bots
image:
docker build . -t adamlearns/abbott-bots -f packages/bots/Dockerfile
.web
image:
docker build . -t adamlearns/abbott-web -f packages/web/Dockerfile
.Notes:
pnpm-lock.yaml
is, which we need from each package that gets built. Also, packages may depend on one another (e.g. bots
depends on database
)..dockerignore
files can be next to the Dockerfile
s as long as their names match the Dockerfile
s (reference).ircv3
I had to install the ircv3
package specifically for one issue: ChatMessage
has a target
that is only provided as a result of ircv3
's PrivateMessage
class, so this line of code would have a TypeScript error without installing ircv3
. This is partially because @types/ircv3
does not exist.
pip3 install docker
(or its equivalent, python3 -m pip install docker
)inventory.ini
to contain the IP address of the target (e.g. a mini PC).cd ansible
ansible-playbook -i inventory.ini playbook.yaml -K
.env
file. It may help to start with a local one: scp .env.development.local adam@minipc:code/Abbott/
DATABASE_BACKUP_LOCATION=/database_backups
in the .env
file since that's what Docker expects.~/database_backups
exists on the host.ssh -L 3000:localhost:3000 -L 3005:localhost:3005 adam@minipc
get-tokens
uses for its redirect, and 3005 is what get-youtube-tokens
uses..env
file with database and YouTube creds: cd code/Abbott/packages/bots
docker run --net=host -v .:/envfile --entrypoint /bin/bash -it ghcr.io/adamlearns/abbott-bots:latest
--net=host
is needed to be able to contact the database since it's running in a separate container)-p 3000:3000
thanks to --net=host
)cd app/deploy/dist
cp /envfile/.env.production.local ./
apt install -y vim
vim .env.production.local
@db
in the database connection string to @127.0.0.1
NODE_ENV=produc'tion node get-tokens
localhost:3000
, it'll go through the SSH tunnel onto the mini PC.get-tokens
twice: once to save the bot's token, and once to save the streamer's token.NODE_ENV=production node get-youtube-tokens
pg_dump
on my main computer and then psql -h MINI_PC_IP
to restore it directly to the mini PC.get-tokens
with a test database from my Macget-tokens
and probably this README.docker-compose-adam-dev.yml
..env.development.local
from the bots
directory to .env.madeup.local
.DATABASE_CONNECTION_STRING
to point to port 5434 (which is what the compose file exposes)cd packages/bots
NODE_ENV=madeup pnpx tsx src/get-tokens.ts
cd packages/bots
NODE_ENV=development pnpx tsx src/get-youtube-tokens.ts
NODE_ENV=development pnpm tsx ./packages/bots/src/discord/deploy-commands.ts
NODE_ENV
as appropriate (e.g. to production
)bot
and applications.commands
options#content-announcement
channel.
Are you building everything? Run pnpm watch
. The typical problem is that I'll make changes in the database
package and then not be able to run that code from another package. It's because nothing is building database
.