From 6036aea919c4ed98d5827c2103373ad59e547136 Mon Sep 17 00:00:00 2001 From: GooeyTuxedo Date: Tue, 18 Apr 2023 14:21:24 -0700 Subject: [PATCH] update README.md and quiet down logs --- README.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++- src/blockchain.ts | 2 +- src/index.ts | 6 +++++ 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 03a231c..2e3ec57 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,65 @@ -# gwei-alert-bot +# Gwei Alert Bot +## Introduction + +This repo contains Docker build files for a Discord bot built with Node.js and utilizes a composed Redis container for storage. + +## Requirements + +- Docker + Docker Compose +- A Discord bot token +- A EVM RPC endpoint URL (websocket enabled) OR a local node running at `localhost:8545` (using docker host network mode) + +## Usage + +1. Clone the repository to your local machine + +```bash +git clone https://git.ssh.surf/MrTuxedo/gwei-alert-bot.git +``` + +2. Create a .env file in the root of the project and add the following environment variables: + +```makefile +RPC_URL= +DISCORD_BOT_TOKEN= +DISCORD_CLIENT= +``` + +3. Run the Docker container + +```bash +docker compose up -d +``` + +## Rebuilding with new changes + +1. Stop the running bot and remove container by same name + +```bash +docker compose down +``` + +2. Pull the new work + +```bash +git pull +``` + +3. Build and Run + +```bash +docker compose up -d --build +``` + +## Environment Variables + +The following environment variables must be set in either `.env` or `docker-compose.yml` in order for the bot to function properly: + +- RPC_URL: Your RPC url +- DISCORD_BOT_TOKEN: the Oauth2 token for your Discord bot. +- DISCORD_CLIENT: the client ID for your Discord bot. (app ID) + +### License + +[WTFPL](./LICENSE) \ No newline at end of file diff --git a/src/blockchain.ts b/src/blockchain.ts index 1268148..a6f7871 100644 --- a/src/blockchain.ts +++ b/src/blockchain.ts @@ -27,7 +27,7 @@ export const subToBlockHeaders = (setDiscordStatus: () => Promise) => { web3.eth.getGasPrice((error, gasPrice) => { if (error) console.error(error); - console.log('Gas price in wei:', gasPrice); + if (shouldSetStatus) console.log('Gas price in wei:', gasPrice); redisClient.set('gas-price', Math.round(Number(gasPrice))) }); diff --git a/src/index.ts b/src/index.ts index 192392d..c6f7f0b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,9 @@ +/* This program is free software. It comes without any warranty, to + * the extent permitted by applicable law. You can redistribute it + * and/or modify it under the terms of the Do What The Fuck You Want + * To Public License, Version 2, as published by Sam Hocevar. See + * http://www.wtfpl.net/ for more details. */ + import 'dotenv/config.js'; import fs from 'node:fs'; import path from 'node:path';