All files / src/plugins Plugin.ts

0% Statements 0/9
100% Branches 0/0
0% Functions 0/2
0% Lines 0/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84                                                                                                                                                                       
import { IInitializationContext } from '@medjaibot/framework/plugin/IInitializationContext';
import { injectable } from 'inversify';
 
/**
 * A basic plugin definition
 *
 * @export
 * @abstract
 * @class Plugin
 * @since 0.0.1
 * @version 0.0.1
 * @author Yannick Fricke <yannickfricke@googlemail.com>
 * @license MIT
 * @copyright MedjaiBot https://github.com/MedjaiBot/server
 */
@injectable()
export abstract class Plugin {
    /**
     * The id of the plugin in the followoing format
     * Github: "com.github.<Your Username>.<Repo Name>"
     *
     * @type {string}
     * @memberof Plugin
     */
    public id: string;
 
    /**
     * The name of the plugin
     *
     * @type {string}
     * @memberof Plugin
     */
    public name: string;
 
    /**
     * The version of the plugin
     *
     * @type {string}
     * @memberof Plugin
     */
    public version: string;
 
    /**
     * The author(s) of the plugin
     *
     * @type {string}
     * @memberof Plugin
     */
    public author: string;
 
    /**
     * Creates an instance of Plugin.
     * @param {string} id The id iof the plugin
     * @param {string} name The name of the plugin
     * @param {string} version The version of the plugin
     * @param {string} author The author(s) of the plugin
     * @memberof Plugin
     */
    constructor(
        id: string,
        name: string,
        version: string,
        author: string,
    ) {
        this.id = id;
        this.name = name;
        this.version = version;
        this.author = author;
    }
 
    /**
     * Lifecycle hook
     * Will be called when the plugin was loaded
     * Use this to do the initial work
     *
     * @abstract
     * @param context The initialization context
     * @memberof Plugin
     */
    public abstract onInit(
        context: IInitializationContext,
    ): void;
}