modubot / modubot.js

Modubot: the scalable and extensible IRC bot.
https://modubot.net
BSD 3-Clause "New" or "Revised" License
19 stars 3 forks source link

ACLs #30

Closed kamaln7 closed 10 years ago

kamaln7 commented 10 years ago

Proposal 1

Define ACLs in the commands key of the plugin (https://github.com/Modubot/Modubot.js/blob/master/src/plugins/kamaln7/plugin/plugin.ts#L12)

Allow access to everyone:

this.commands: {
    'ping': 'onCommandPing'
}

Voiced-only access (available access levels: https://github.com/Modubot/Modubot.js/blob/master/src/Modubot/Bot.ts#L177 ):

this.commands: {
    'ping': {
        method: 'onCommandPing',
        acl: '+'
    }
}

Customization?

this.commands: {
    'ping': {
        method: 'onCommandPing',
        acl: function(from, to, host) {
            // e.g.:
            // from: 'kamal_', to: '#modubot', host: 'freq.in'
            return host == 'freq.in'; // Allow access from @freq.in users only
        }
    }
}

Proposal 2

The plugin would check for permissions itself.

Example:

onCommandPing(from:any, to:any, message:any, args:any) {
    this.bot.hasAccess(from, to, {
        channel: '+', // Only allow voiced only if the command was run in a channel
        query: false, // Do not allow running the command in a query window
        admin: false // Admin override, defaults to true
    }, function(hasAccess){
        if (!hasAccess) return;

        // user has access
    });
}
kamaln7 commented 10 years ago

Went for Proposal 2.