Remove token from config file
This commit is contained in:
parent
c0d92ea66d
commit
cc7831a313
9 changed files with 11 additions and 22 deletions
|
@ -1,7 +1,7 @@
|
||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
const config = require("./config")
|
const {reg} = require("./src/matrix/read-registration")
|
||||||
const token = config.discordToken
|
const token = reg.ooye.discord_token
|
||||||
const id = Buffer.from(token.split(".")[0], "base64").toString()
|
const id = Buffer.from(token.split(".")[0], "base64").toString()
|
||||||
|
|
||||||
function addbot() {
|
function addbot() {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
echo "Open this link to add the bot to a Discord server:"
|
echo "Open this link to add the bot to a Discord server:"
|
||||||
echo "https://discord.com/oauth2/authorize?client_id=$(grep discordToken config.js | sed -E 's!.*: ["'\'']([A-Za-z0-9+=/_-]*).*!\1!g' | base64 -d)&scope=bot&permissions=1610883072"
|
echo "https://discord.com/oauth2/authorize?client_id=$(grep discord_token registration.yaml | sed -E 's!.*: ["'\'']([A-Za-z0-9+=/_-]*).*!\1!g' | base64 -d)&scope=bot&permissions=1610883072"
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
discordToken: "yes"
|
|
||||||
}
|
|
|
@ -81,11 +81,7 @@ Follow these steps:
|
||||||
|
|
||||||
1. Install dependencies: `npm install`
|
1. Install dependencies: `npm install`
|
||||||
|
|
||||||
1. Copy `config.example.js` to `config.js` and fill in Discord token.
|
1. Run `node scripts/seed.js` to check your setup and set the bot's initial state. It will prompt you for information. You only need to run this once ever.
|
||||||
|
|
||||||
1. Copy `registration.example.yaml` to `registration.yaml` and fill in bracketed values. You could generate each hex string with `dd if=/dev/urandom bs=32 count=1 2> /dev/null | basenc --base16 | dd conv=lcase 2> /dev/null`. Register the registration in Synapse's `homeserver.yaml` through the usual appservice installation process, then restart Synapse.
|
|
||||||
|
|
||||||
1. Run `node scripts/seed.js` to check your setup and set the bot's initial state. You only need to run this once ever.
|
|
||||||
|
|
||||||
1. Start the bridge: `node start.js`
|
1. Start the bridge: `node start.js`
|
||||||
|
|
||||||
|
@ -113,7 +109,6 @@ To get into the rooms on your Matrix account, either add yourself to `invite` in
|
||||||
* Run this to start the bridge:
|
* Run this to start the bridge:
|
||||||
├── start.js
|
├── start.js
|
||||||
* Runtime configuration, like tokens and user info:
|
* Runtime configuration, like tokens and user info:
|
||||||
├── config.js
|
|
||||||
├── registration.yaml
|
├── registration.yaml
|
||||||
* The bridge's SQLite database is stored here:
|
* The bridge's SQLite database is stored here:
|
||||||
├── db
|
├── db
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = async function(db) {
|
module.exports = async function(db) {
|
||||||
const config = require("../../../config")
|
const id = require("../../../addbot").id
|
||||||
const id = Buffer.from(config.discordToken.split(".")[0], "base64").toString()
|
|
||||||
db.prepare("UPDATE OR REPLACE sim SET user_id = ? WHERE user_id = '0'").run(id)
|
db.prepare("UPDATE OR REPLACE sim SET user_id = ? WHERE user_id = '0'").run(id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Passthrough
|
* @typedef {Object} Passthrough
|
||||||
* @property {import("repl").REPLServer} repl
|
* @property {import("repl").REPLServer} repl
|
||||||
* @property {typeof import("./config")} config
|
|
||||||
* @property {import("./d2m/discord-client")} discord
|
* @property {import("./d2m/discord-client")} discord
|
||||||
* @property {import("heatsync").default} sync
|
* @property {import("heatsync").default} sync
|
||||||
* @property {import("better-sqlite3/lib/database")} db
|
* @property {import("better-sqlite3/lib/database")} db
|
||||||
|
|
|
@ -5,7 +5,7 @@ const util = require("util")
|
||||||
const {addbot} = require("../addbot")
|
const {addbot} = require("../addbot")
|
||||||
|
|
||||||
const passthrough = require("./passthrough")
|
const passthrough = require("./passthrough")
|
||||||
const {discord, config, sync, db} = passthrough
|
const {discord, sync, db} = passthrough
|
||||||
|
|
||||||
const data = sync.require("../test/data")
|
const data = sync.require("../test/data")
|
||||||
const createSpace = sync.require("./d2m/actions/create-space")
|
const createSpace = sync.require("./d2m/actions/create-space")
|
||||||
|
|
8
start.js
8
start.js
|
@ -4,18 +4,18 @@ const sqlite = require("better-sqlite3")
|
||||||
const migrate = require("./src/db/migrate")
|
const migrate = require("./src/db/migrate")
|
||||||
const HeatSync = require("heatsync")
|
const HeatSync = require("heatsync")
|
||||||
|
|
||||||
const config = require("./config")
|
const {reg} = require("./src/matrix/read-registration")
|
||||||
const passthrough = require("./src/passthrough")
|
const passthrough = require("./src/passthrough")
|
||||||
const db = new sqlite("src/db/ooye.db")
|
const db = new sqlite("src/db/ooye.db")
|
||||||
|
|
||||||
/** @type {import("heatsync").default} */ // @ts-ignore
|
/** @type {import("heatsync").default} */ // @ts-ignore
|
||||||
const sync = new HeatSync()
|
const sync = new HeatSync()
|
||||||
|
|
||||||
Object.assign(passthrough, {config, sync, db})
|
Object.assign(passthrough, {sync, db})
|
||||||
|
|
||||||
const DiscordClient = require("./src/d2m/discord-client")
|
const DiscordClient = require("./src/d2m/discord-client")
|
||||||
|
|
||||||
const discord = new DiscordClient(config.discordToken, "no")
|
const discord = new DiscordClient(reg.ooye.discord_token)
|
||||||
passthrough.discord = discord
|
passthrough.discord = discord
|
||||||
|
|
||||||
const {as} = require("./src/matrix/appservice")
|
const {as} = require("./src/matrix/appservice")
|
||||||
|
@ -26,7 +26,7 @@ passthrough.from = orm.from
|
||||||
passthrough.select = orm.select
|
passthrough.select = orm.select
|
||||||
|
|
||||||
const power = require("./src/matrix/power.js")
|
const power = require("./src/matrix/power.js")
|
||||||
// sync.require("./src/m2d/event-dispatcher")
|
sync.require("./src/m2d/event-dispatcher")
|
||||||
|
|
||||||
;(async () => {
|
;(async () => {
|
||||||
await migrate.migrate(db)
|
await migrate.migrate(db)
|
||||||
|
|
|
@ -13,7 +13,6 @@ const data = require("./data")
|
||||||
const fetch = require("node-fetch")
|
const fetch = require("node-fetch")
|
||||||
const {green} = require("colorette")
|
const {green} = require("colorette")
|
||||||
|
|
||||||
const config = require("../config")
|
|
||||||
const passthrough = require("../src/passthrough")
|
const passthrough = require("../src/passthrough")
|
||||||
const db = new sqlite(":memory:")
|
const db = new sqlite(":memory:")
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ const discord = {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(passthrough, { discord, config, sync, db })
|
Object.assign(passthrough, { discord, sync, db })
|
||||||
|
|
||||||
const orm = sync.require("../src/db/orm")
|
const orm = sync.require("../src/db/orm")
|
||||||
passthrough.from = orm.from
|
passthrough.from = orm.from
|
||||||
|
|
Loading…
Reference in a new issue