Skip to content

Instantly share code, notes, and snippets.

@satom99
Created April 10, 2018 16:31
Show Gist options
  • Save satom99/f3504c1c7df2774134084d8d7e1568f9 to your computer and use it in GitHub Desktop.
Save satom99/f3504c1c7df2774134084d8d7e1568f9 to your computer and use it in GitHub Desktop.
Command handler
defmodule Consumer do
use Coxir
use Coxir.Commands
@prefix "~"
@space :none
@channel :any
@permit :none
command ping do
message
|> Message.reply("pong!")
end
@space :user
command info(user // :self) do
# show an user's info
end
@space :user
command cookies(user // :self) do
# list an user's cookies
end
@space user: :roles
command add(user // :self, role) do
# set a role for an user
end
@space user: :roles
command remove(user // :self, role) do
# remove a role from an user
end
@space :user
@permit :is_mod?
command kick(user) do
# kick an user
end
@space :user
@permit :is_mod?
command nick(user, name) do
# set an user's nickname
end
@space :user
command nick(name) do
# self nickname-set
end
defp is_mod?(user) do
# check whether a given user is a mod
true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment