Igor v0.1.0 Igor View Source
Bot framework for Matrix.
Link to this section Summary
Functions
The handle for a bot.
Returns a specification to start this module under a supervisor.
Convert Matrix HTML to an approximate text rendering that should be more useful for parsing. This will not necessarily be a useful text rendering for displaying to a user; it is only meant to be used for parsing.
Parse text into a command list if possible.
React to a message.
Send a message to a room.
Start the bot process.
Strip out the replied-to message from a message reply in Matrix HTML format.
Just uses a naive method of splitting on </mx-reply> and returning the last
segment.
Link to this section Types
t()
View Sourcet() :: %Igor{
bot_name: String.t(),
client: Polyjuice.Client.t(),
command_prefix: Regex.t(),
opts: Keyword.t(),
responders: [],
storage: Polyjuice.Client.Storage.t()
}
Link to this section Functions
The handle for a bot.
Returns a specification to start this module under a supervisor.
See Supervisor.
Convert Matrix HTML to an approximate text rendering that should be more useful for parsing. This will not necessarily be a useful text rendering for displaying to a user; it is only meant to be used for parsing.
Examples
iex> Igor.html_to_text("<mx-reply>Someone else's message</mx-reply>foo<img alt=\"bar\"><b>baz</b>")
"foobarbaz"
iex> Igor.html_to_text("Yes <a href=\"https://matrix.to/#/%40uhoreg:matrix.org\">master</a>")
"Yes @uhoreg:matrix.org"
Parse text into a command list if possible.
Examples
iex> Igor.parse_text_to_command("igor: foo bar baz", %Igor{})
["foo", "bar", "baz"]
iex> Igor.parse_text_to_command("!foo bar baz", %Igor{})
["foo", "bar", "baz"]
React to a message.
send(message, room, bot)
View Sourcesend(
message ::
Igor.Message.t() | Polyjuice.Client.MsgBuilder.MsgData.t() | map(),
room :: String.t() | Igor.Message.t(),
bot :: Igor.t()
) :: Any
Send a message to a room.
The message can be a string, a tuple (where the first item is the message
in plain text, and the second item is the message in HTML), an
Igor.Message, or a map (giving the full message contents).
The room can either be a room ID as a string, or the Igor.Message that
the message is sent in response to.
Start the bot process.
Strip out the replied-to message from a message reply in Matrix HTML format.
Just uses a naive method of splitting on </mx-reply> and returning the last
segment.