Git Product home page Git Product logo

tennu-cooldown's Introduction

tennu-cooldown

A plugin for the tennu irc framework.

Allows commands normally reserved for admins, to be used by regular users with a cooldown.

This plugin is for usage with select existing plugins that support it.

IMPORTANT

Configuration

"asay": {
    "cooldown": 103
},
"agoogle": {
    "cooldown": 10
},
"correction": {
    "cooldown": 10
},
"title": {
    "cooldown": 10
},
"tell": {
    "cooldown": 10
},

Developers

Adding cooldowns into your own plugin with isAdmin fallback

var PluginThatUsesAdminCooldown = {
    requiresRoles: ['admin'],
    init: function(client, imports) {

        const helps = {
            "shout": [
                "Let it all out!."
            ]
        };

        // Always throw a helpful error when a user is missing important configuration variables for your plugin
        var shoutConfig = client.config("shout");
        if (!shoutConfig)
        {
            throw Error(this.name + ': is missing some or all of its configuration.');
        }

        // This chunk of code is what lets tennu-cooldown take over if it exists
        // It also logs to the user that its using cooldowns
        var isAdmin = imports.admin.isAdmin;
        var adminCooldown = client._plugins.getRole("cooldown");
        if(adminCooldown)
        {
            if(!shoutConfig.cooldown) {
                client._logger.warn('shout: cooldown found, no config set.');
            } else {
                isAdmin = adminCooldown(shoutConfig.cooldown);
                client._logger.notice('shout: cooldowns enabled: ' + shoutConfig.cooldown + ' seconds.');            
            }
        }

        return {
            handlers: {
                "!shout": function(IRCMessage) {
                    return isAdmin(IRCMessage.hostmask).then(function(isadmin) {
                    
                        // isAdmin will be "undefined" if cooldown system is enabled
                        // isAdmin will be true/false if cooldown system is disabled
                        if(typeof(isadmin) === "undefined" || isadmin === true)
                        {
                            return 'Stop dont touch me there!';   
                        }                    
                    
                        if(result)
                        {
                            return 'AHH';
                        }                        
                    });
                }
            },

            help: {
                "!shout": helps.shout
            },

            commands: ["shout"]
        }
    }
};

module.exports = PluginThatUsesAdminCooldown;

Installing Into Tennu

See Downloadable Plugins here.

Todo:

  • Tests

tennu-cooldown's People

Contributors

lordzerohour avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.