-
Clone Mongooseim:
git clone https://github.com/esl/MongooseIM
-
Copy customized configuration files and build it:
cp mongooseim/vars.config MongooseIM/rel/vars.config.in cp mongooseim/ejabberd.cfg MongooseIM/rel/files cd MongooseIM && make rel
-
Add
xmpp.lambdadays.org
as an alternative name for 127.0.0.1 in your/etc/hosts
-
Start MongooseIM:
_build/prod/rel/mongooseim/bin/mongooseimctl live
-
Register accounts for the Bot (
test_bot
) and a sample user (test_user
):Run the commands from the MongooseIM directory
_build/prod/rel/mongooseim/bin/mongooseimctl register test_user xmpp.lambdadays.org test_user _build/prod/rel/mongooseim/bin/mongooseimctl register test_bot xmpp.lambdadays.org test_bot
-
Create a test MUC room (
test_room
) in MongooseIM:User = <<"user1">>. Server = <<"xmpp.lambdadays.org">>. From = {jid, User, Server, <<"res">>, User, Server, <<"res">>}. mod_muc:create_instant_room(Server, <<"test_room">>, From, <<"photo">>, []).
You can verify that the room was created with
ets:tab2list(muc_online_room).
-
Start the Bot
The default bot configuration sits in
apps/bot/config/config.exs
mix do deps.get, compile iex -S mix
-
Check that the Bot is connectd to the
test_room
:mod_muc_room:get_room_users(jid:from_binary(<<"[email protected]">>)).
-
Connect the sample user to the room using the [PSI] client.
- General -> Join Groupchat
- Host:
muc.xmpp.lambdadays.org
- Room:
test_room
- Nickname:
user1
- Password: (empty)
-
Talk to the Bot:
<user1> test_bot help <test_bot> test_bot help - Displays all of the help commands that test_bot knows about. test_bot help <query> - Displays all help commands that match <query>. test_bot: ping - Responds with 'pong' test_bot: actions - Lists available actions provided by this bot test_bot: action <action_id> - Performs an action provided by this bot <user1> test_bot actions <test_bot> user1: Here are the actions you can perform: Action id: action1 Desription: desc1 Action id: action2 Desription: desc2 Key in `test_bot action <action_id>` to perform the action. <user1> test_bot action action1 <test_bot> user1: running action
The
actions
andaction ID
commands are provided by theBot.Service.Responder
which delegates to a service through its callback:config :bot, Bot.Service, callback: Bot.Service.Mock
To implement a service one has to create an umbrella application in the apps
and implement
the Bot.Service
behaviour. Then the module fulfilling that behaviour has to be pointed to
in the configuration:
config :bot, Bot.Service,
callback: MyService.API
-
Start the MongooseIM server with
xmpp.lambdadays.org
domain -
Register the
photo_bot
and the sample user:_build/prod/rel/mongooseim/bin/mongooseimctl register photo_bot xmpp.lambdadays.org photo_bot _build/prod/rel/mongooseim/bin/mongooseimctl register test_user xmpp.lambdadays.org test_user
-
Create the
photo_room
in the server:User = <<"user1">>. Server = <<"xmpp.lambdadays.org">>. From = {jid, User, Server, <<"res">>, User, Server, <<"res">>}. mod_muc:create_instant_room(Server, <<"photo_room">>, From, <<"foto">>, []).
-
Make sure that the configuration in the
config/photo_pi.exs
is correct and start the bot:MIX_ENV=photo_pi mix do deps.get, compile, run --no-halt
-
Make sure that Twitter API access tokens are configured in
config/secrets.exs
fileconfig :extwitter, oauth: [ consumer_key: "...", consumer_secret: "...", access_token: "...", access_token_secret: "..." ]
-
Configure default status message which will be posted with a photo
config :photo_pi, PhotoPi.Twitter, status_message: "blah blah"
-
Check who is in the room:
mod_muc_room:get_room_users(jid:from_binary(<<"[email protected]">>)).
Use the instructions from the previous chapter to connect a
test_user
to the room.
-
Start the MongooseIM server with
xmpp.lambdadays.org
domain -
Register the
music_bot
and the sample user:_build/prod/rel/mongooseim/bin/mongooseimctl register music_bot xmpp.lambdadays.org music_bot _build/prod/rel/mongooseim/bin/mongooseimctl register test_user xmpp.lambdadays.org test_user
-
Create the
music_room
in the server:User = <<"user1">>. Server = <<"xmpp.lambdadays.org">>. From = {jid, User, Server, <<"res">>, User, Server, <<"res">>}. mod_muc:create_instant_room(Server, <<"music_room">>, From, <<"music">>, []).
-
Make sure that the configuration in the
config/music_pi.exs
is correct and start the bot:MIX_ENV=music_pi mix do deps.get, compile, run --no-halt
-
Check who is in the room:
mod_muc_room:get_room_users(jid:from_binary(<<"[email protected]">>)).
Use the instructions from the previous chapter to connect a
test_user
to the room.
MIX_ENV=photo_pi mix release --name=photo_pi
And then run with:
_build/dev/rel/photo_pi/bin/photo_pi console
The
config/secrets.exs
has to be set appropriately.
MIX_ENV=music_pi mix release --name=music_pi
And then run with:
_build/dev/rel/music_pi/bin/musci_pi console