2024-11-25 13:07:42 +01:00
|
|
|
defmodule Ejabberd.Module.Example do
|
|
|
|
|
|
|
|
@moduledoc """
|
|
|
|
Example ejabberd module written in Elixir.
|
|
|
|
|
|
|
|
This is an example to demonstrate the usage of Elixir to
|
|
|
|
create ejabberd modules.
|
|
|
|
|
|
|
|
Example configuration:
|
|
|
|
modules:
|
|
|
|
'Ejabberd.Module.Example': {}
|
|
|
|
"""
|
|
|
|
|
|
|
|
@behaviour :gen_mod
|
|
|
|
import Ejabberd.Logger
|
2015-01-29 18:43:47 +01:00
|
|
|
|
|
|
|
def start(host, _opts) do
|
2024-11-25 13:07:42 +01:00
|
|
|
info("Starting Ejabberd.Module.Example for host '#{host}'")
|
2016-09-08 11:34:42 +02:00
|
|
|
Ejabberd.Hooks.add(:set_presence_hook, host, __MODULE__, :on_presence, 50)
|
2015-01-29 18:43:47 +01:00
|
|
|
:ok
|
|
|
|
end
|
2016-08-01 15:46:14 +02:00
|
|
|
|
2015-01-29 18:43:47 +01:00
|
|
|
def stop(host) do
|
2024-11-25 13:07:42 +01:00
|
|
|
info("Stopping Ejabberd.Module.Example for host '#{host}'")
|
2016-09-08 11:34:42 +02:00
|
|
|
Ejabberd.Hooks.delete(:set_presence_hook, host, __MODULE__, :on_presence, 50)
|
2015-01-29 18:43:47 +01:00
|
|
|
:ok
|
|
|
|
end
|
2016-08-01 15:46:14 +02:00
|
|
|
|
2015-01-29 18:43:47 +01:00
|
|
|
def on_presence(user, _server, _resource, _packet) do
|
2023-12-13 22:20:45 +01:00
|
|
|
info("Receive presence for #{user}")
|
2015-01-29 18:43:47 +01:00
|
|
|
:none
|
2016-08-01 15:46:14 +02:00
|
|
|
end
|
2018-12-26 17:32:39 +01:00
|
|
|
|
|
|
|
def depends(_host, _opts) do
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
|
|
|
def mod_options(_host) do
|
|
|
|
[]
|
|
|
|
end
|
2021-03-09 18:33:35 +01:00
|
|
|
|
|
|
|
def mod_doc() do
|
2023-12-13 22:20:45 +01:00
|
|
|
%{:desc => "This is just a demonstration."}
|
2021-03-09 18:33:35 +01:00
|
|
|
end
|
|
|
|
|
2015-01-29 18:43:47 +01:00
|
|
|
end
|