Nosedrum.Helpers (nosedrum v0.6.0) View Source
User interaction helpers that don't fit into their own module.
Link to this section Summary
Functions
Escape @everyone
and @here
mentions in the given content
with a zero-width space character.
Try to split the given text
using OptionParser.split/1
and fall back to
String.split/1
if not applicable.
Link to this section Functions
Specs
Escape @everyone
and @here
mentions in the given content
with a zero-width space character.
Example
iex> Nosedrum.Helpers.escape_server_mentions("hello world")
"hello world"
iex> Nosedrum.Helpers.escape_server_mentions("hello @everyone @here")
"hello @everyone @here" # No space to be seen, but no mention either!
Specs
Try to split the given text
using OptionParser.split/1
and fall back to
String.split/1
if not applicable.
OptionParser.split/1
raises a RuntimeError
if the text it is given
contains opening quotation marks that were not closed again. In other cases,
it is desirable to split a string into quoted parts, for example:
iex> Nosedrum.Helpers.quoted_split("echo \"hello bot\"")
["echo", "hello bot"]
iex> Nosedrum.Helpers.quoted_split("echo \"hello bot")
["echo", "\"hello", "bot"]