Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
]));
process.exit(0);
}
const yamlConfig = yaml.safeLoad(fs.readFileSync("./discord-registration.yaml", "utf8"));
const registration = AppServiceRegistration.fromObject(yamlConfig);
const config = new DiscordBridgeConfig();
config.applyConfig(yaml.safeLoad(fs.readFileSync(options.config, "utf8")) as DiscordBridgeConfig);
config.applyEnvironmentOverrides(process.env);
if (registration === null) {
throw new Error("Failed to parse registration file");
}
const botUserId = `@${registration.sender_localpart}:${config.bridge.domain}`;
const clientFactory = new ClientFactory({
appServiceUserId: botUserId,
token: registration.as_token,
url: config.bridge.homeserverUrl,
});
const bridge = new Bridge({
clientFactory,
controller: {
onEvent: () => { },
},
domain: config.bridge.domain,
homeserverUrl: config.bridge.homeserverUrl,
intentOptions: {
clients: {
dontJoin: true, // handled manually
},
]));
process.exit(0);
}
const yamlConfig = yaml.safeLoad(fs.readFileSync("./discord-registration.yaml", "utf8"));
const registration = AppServiceRegistration.fromObject(yamlConfig);
const config = new DiscordBridgeConfig();
config.applyConfig(yaml.safeLoad(fs.readFileSync(options.config, "utf8")) as DiscordBridgeConfig);
config.applyEnvironmentOverrides(process.env);
if (registration === null) {
throw new Error("Failed to parse registration file");
}
const botUserId = `@${registration.sender_localpart}:${config.bridge.domain}`;
const clientFactory = new ClientFactory({
appServiceUserId: botUserId,
token: registration.as_token,
url: config.bridge.homeserverUrl,
});
const bridge = new Bridge({
clientFactory,
controller: {
onEvent: () => { },
},
domain: config.bridge.domain,
homeserverUrl: config.bridge.homeserverUrl,
intentOptions: {
clients: {
dontJoin: true, // handled manually
},
async function run(port: number, fileConfig: DiscordBridgeConfig) {
const config = new DiscordBridgeConfig();
config.applyConfig(fileConfig);
config.applyEnvironmentOverrides(process.env);
Log.Configure(config.logging);
log.info("Starting Discord AS");
const yamlConfig = yaml.safeLoad(fs.readFileSync(cli.opts.registrationPath, "utf8"));
const registration = AppServiceRegistration.fromObject(yamlConfig);
if (registration === null) {
throw new Error("Failed to parse registration file");
}
const botUserId = `@${registration.sender_localpart}:${config.bridge.domain}`;
const clientFactory = new ClientFactory({
appServiceUserId: botUserId,
token: registration.as_token,
url: config.bridge.homeserverUrl,
});
const store = new DiscordStore(config.database);
const callbacks: { [id: string]: callbackFn; } = {};
const bridge = new Bridge({
clientFactory,
controller: {
// onUserQuery: userQuery,
onAliasQueried: async (alias: string, roomId: string) => {
try {
return await callbacks.onAliasQueried(alias, roomId);
} catch (err) { log.error("Exception thrown while handling \"onAliasQueried\" event", err); }
}
if (!options.userid) {
console.error("Missing userid parameter. Check -h");
process.exit(1);
}
const yamlConfig = yaml.safeLoad(fs.readFileSync("discord-registration.yaml", "utf8"));
const registration = AppServiceRegistration.fromObject(yamlConfig);
const config: DiscordBridgeConfig = yaml.safeLoad(fs.readFileSync(options.config, "utf8")) as DiscordBridgeConfig;
if (registration === null) {
throw new Error("Failed to parse registration file");
}
const clientFactory = new ClientFactory({
appServiceUserId: `@${registration.sender_localpart}:${config.bridge.domain}`,
token: registration.as_token,
url: config.bridge.homeserverUrl,
});
const client = clientFactory.getClientAs();
const intent = new Intent(client, client, {registered: true});
async function run() {
try {
await intent.setPowerLevel(options.roomid, options.userid, options.power);
console.log("Power levels set");
process.exit(0);
} catch (err) {
console.error("Could not apply power levels to room:", err);
process.exit(1);
}
{
header: "Options",
optionList: optionDefinitions,
},
]));
process.exit(0);
}
const yamlConfig = yaml.safeLoad(fs.readFileSync("./discord-registration.yaml", "utf8"));
const registration = AppServiceRegistration.fromObject(yamlConfig);
const config: DiscordBridgeConfig = yaml.safeLoad(fs.readFileSync(options.config, "utf8")) as DiscordBridgeConfig;
if (registration === null) {
throw new Error("Failed to parse registration file");
}
const clientFactory = new ClientFactory({
appServiceUserId: `@${registration.sender_localpart}:${config.bridge.domain}`,
token: registration.as_token,
url: config.bridge.homeserverUrl,
});
const bridge = new Bridge({
controller: {
onEvent: () => { },
},
domain: "rubbish",
homeserverUrl: true,
registration: true,
});
const discordstore = new DiscordStore(config.database ? config.database.filename : "discord.db");
run: function (port, config) {
//Read registration file
var regObj = yaml.safeLoad(fs.readFileSync("twitter-registration.yaml", 'utf8'));
regObj = AppServiceRegistration.fromObject(regObj);
if (regObj === null) {
throw new Error("Failed to parse registration file");
}
var room_handler;
var clientFactory = new ClientFactory(
{
sdk: require("matrix-js-sdk"),
url: config.bridge.homeserverUrl,
token: regObj.as_token,
appServiceUserId: "@" + regObj.sender_localpart + ":" + config.bridge.domain
}
);
bridge = new Bridge({
homeserverUrl: config.bridge.homeserverUrl,
domain: config.bridge.domain,
registration: regObj,
controller: {
onUserQuery: userQuery,
onEvent: (request, context) => { room_handler.passEvent(request, context); },
onAliasQuery: (alias, aliasLocalpart) => {