An Idobata.io (Japanese) client in Elixir.
If available in Hex, the package can be installed
by adding ex_idobata
to your list of dependencies in mix.exs
:
def deps do
[
{:ex_idobata, "~> 0.1"}
]
end
To post messages or images to use hook API.
alias ExIdobata.Hook
# room UUID, it's the last part of hook API,
# for examle https://idobata.io/hook/custom/00000000-0000-0000-0000-000000000000
room_uuid = "00000000-0000-0000-0000-000000000000"
# post plain text message
Hook.contents()
|> Hook.source("Hi")
|> Hook.post(room_uuid)
# post Markdown message
Hook.contents()
|> Hook.source("# Hi")
|> Hook.markdown()
|> Hook.post(room_uuid)
# post HTML message
Hook.contents()
|> Hook.source("<h1>Hi</h1>")
|> Hook.html()
|> Hook.post(room_uuid)
# post message with image
Hook.contents()
|> Hook.source("hi")
|> Hook.image("./hello.gif")
|> Hook.post(room_uuid)
If room_uuid
omitted, the function post
uses a value of environemnt variable IDOBATA_HOOK_ROOM_UUID
as UUID.
To use another environment variable, pass a tuple with :system
and the variable name (e.g., {:system, "ANOTHER_ROOM_UUID"}
).
access_token = ExIdobata.API.AccessToken.get(email, password)
This access token used API functions described below.
viewer = ExIdobata.API.Viewer.get(access_token)
# `viewer.name` is an account user name
rooms = ExIdobata.API.Room.get(access_token)
To post a plain text message.
ExIdobata.API.post(access_token, room, "Hi")
It's same as bellow.
ExIdobata.API.post(access_token, room, "Hi", :plain)
To post a Markdown message.
ExIdobata.API.post(access_token, room, "*Hi*", :markdown)
To post a HTML message.
ExIdobata.API.post(access_token, room, "<h1>Hi</h1>", :html)