Code Monkey home page Code Monkey logo

coxir_commander's Introduction

Commander

A command handler utility for coxir.

Usage

Let us consider the following example.

defmodule Test do
  use Coxir.Commander
  use Commands.Other

  @prefix "!"

  command ping do
    Message.reply(message, "pong!")
  end

  @channel "432535429162729494"
  command info do
    # ···
  end

  @space user: :cookies
  command eat(amount \\ 1) do
    # ···
  end

  @space :user
  @permit :KICK_MEMBERS
  command kick(reason) do
    # ···
    Member.kick(member)
  end

  @permit &is_admin?/2
  command eval(code) do
    # ···
  end
end

We may observe commands are independently configurable by the use of @space, @permit and @channel.
As their name suggest, the first one serves for namespacing, the second one allows for permission restriction
either through an atom or a custom function - in this case is_admin/2 ships with the utility, and the latter limits
the command to a specific channel. Moreover, other modules defining commands may be included with use.

coxir_commander's People

Contributors

geopjr avatar satom99 avatar xh4h avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.