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>
This commit is contained in:
@@ -2,7 +2,7 @@ defmodule Omnibot.Contrib.Wordbot.Bot do
|
|||||||
use Omnibot.Module.Base
|
use Omnibot.Module.Base
|
||||||
use Omnibot.Module.GenServer
|
use Omnibot.Module.GenServer
|
||||||
|
|
||||||
alias Omnibot.{Contrib.Wordbot, Irc, State}
|
alias Omnibot.{Contrib.Wordbot, Irc, State, Util}
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@split_pattern ~r/[\s\b]+/
|
@split_pattern ~r/[\s\b]+/
|
||||||
@@ -15,7 +15,7 @@ defmodule Omnibot.Contrib.Wordbot.Bot do
|
|||||||
|> Enum.reverse()
|
|> Enum.reverse()
|
||||||
|> Enum.take(5)
|
|> Enum.take(5)
|
||||||
|> Enum.with_index()
|
|> Enum.with_index()
|
||||||
|> Enum.map(fn {%{user: nick, score: score}, rank} -> "#{rank + 1}. #{nick}. #{score}" end)
|
|> Enum.map(fn {%{user: nick, score: score}, rank} -> "#{rank + 1}. #{Util.denotify_nick(nick)}. #{score}" end)
|
||||||
|> Enum.each(&Irc.send_to(irc, channel, &1))
|
|> Enum.each(&Irc.send_to(irc, channel, &1))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ defmodule Omnibot.Contrib.Wordbot.Bot do
|
|||||||
|> Map.new()
|
|> Map.new()
|
||||||
|> IO.inspect()
|
|> IO.inspect()
|
||||||
|
|
||||||
Enum.each(scores, &Irc.send_to(irc, channel, "#{rankings[&1.score] + 1}. #{&1.user}. #{&1.score}"))
|
Enum.each(scores, &Irc.send_to(irc, channel, "#{rankings[&1.score] + 1}. #{Util.denotify_nick(&1.user)}. #{&1.score}"))
|
||||||
|
|
||||||
# Stop the watcher, start new round
|
# Stop the watcher, start new round
|
||||||
delete_watcher(channel)
|
delete_watcher(channel)
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ defmodule Omnibot.Util do
|
|||||||
create a notification for that user.
|
create a notification for that user.
|
||||||
"""
|
"""
|
||||||
def denotify_nick(nick) do
|
def denotify_nick(nick) do
|
||||||
Enum.join(nick, "\u200b")
|
String.graphemes(nick) |> Enum.join("\u200b")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user