mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 19:17:19 +00:00
feat: Phisherman integration
This commit is contained in:
parent
f92ee9ba4f
commit
13c94a81cc
18 changed files with 681 additions and 17 deletions
49
backend/src/plugins/Phisherman/PhishermanPlugin.ts
Normal file
49
backend/src/plugins/Phisherman/PhishermanPlugin.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { PluginOptions, typedGuildCommand } from "knub";
|
||||
import { GuildPingableRoles } from "../../data/GuildPingableRoles";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { ConfigSchema, PhishermanPluginType } from "./types";
|
||||
import {
|
||||
getPhishermanDomainInfo,
|
||||
hasPhishermanMasterAPIKey,
|
||||
phishermanApiKeyIsValid,
|
||||
reportTrackedDomainsToPhisherman,
|
||||
} from "../../data/Phisherman";
|
||||
import { mapToPublicFn } from "../../pluginUtils";
|
||||
import { getDomainInfo } from "./functions/getDomainInfo";
|
||||
import { pluginInfo } from "./info";
|
||||
|
||||
const defaultOptions: PluginOptions<PhishermanPluginType> = {
|
||||
config: {
|
||||
api_key: null,
|
||||
},
|
||||
overrides: [],
|
||||
};
|
||||
|
||||
export const PhishermanPlugin = zeppelinGuildPlugin<PhishermanPluginType>()({
|
||||
name: "phisherman",
|
||||
showInDocs: true,
|
||||
info: pluginInfo,
|
||||
|
||||
configSchema: ConfigSchema,
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
public: {
|
||||
getDomainInfo: mapToPublicFn(getDomainInfo),
|
||||
},
|
||||
|
||||
async beforeLoad(pluginData) {
|
||||
pluginData.state.validApiKey = null;
|
||||
|
||||
if (!hasPhishermanMasterAPIKey()) {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.warn("Could not load Phisherman plugin: master API key is missing");
|
||||
return;
|
||||
}
|
||||
|
||||
const apiKey = pluginData.config.get().api_key;
|
||||
if (apiKey && (await phishermanApiKeyIsValid(apiKey).catch(() => false))) {
|
||||
pluginData.state.validApiKey = apiKey;
|
||||
}
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue