Files
omnibot/lib/util.ex
Alek Ratzloff d56c0bf75c Update wordbot leaderboard and scoreboard to use "denotified" nicks
Nicknames that are sent by wordbot for the leaderboard command and the
end-of-game scoreboard are split up by zero-width space characters, to
avoid pinging the users at random times.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 17:23:29 -07:00

18 lines
473 B
Elixir

defmodule Omnibot.Util do
def string_empty?(s), do: String.length(s) == 0
def string_or_nil(s), do: if(string_empty?(s), do: nil, else: s)
def now_unix, do: now_unix("Etc/UTC")
def now_unix(tz), do: DateTime.now!(tz) |> DateTime.to_unix()
@doc """
Inserts a zero-width space character inside of a nickname so that it won't
create a notification for that user.
"""
def denotify_nick(nick) do
String.graphemes(nick) |> Enum.join("\u200b")
end
end