summaryrefslogtreecommitdiff
path: root/lib/lsg_irc/last_fm_handler.ex
diff options
context:
space:
mode:
authorhref <href@random.sh>2018-02-17 21:21:42 +0100
committerhref <href@random.sh>2018-02-17 21:21:42 +0100
commit50c6a09ff64cb081b27a0c30790b86873449d172 (patch)
treeba1bebfc7e367f169276692e0ac02709d62d6516 /lib/lsg_irc/last_fm_handler.ex
parenttxt: fix against malicious filenames (aka 'fuck you shiv') (diff)
:)
Diffstat (limited to 'lib/lsg_irc/last_fm_handler.ex')
-rw-r--r--lib/lsg_irc/last_fm_handler.ex15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/lsg_irc/last_fm_handler.ex b/lib/lsg_irc/last_fm_handler.ex
index ad6dae9..6ecdab9 100644
--- a/lib/lsg_irc/last_fm_handler.ex
+++ b/lib/lsg_irc/last_fm_handler.ex
@@ -4,14 +4,9 @@ defmodule LSG.IRC.LastFmHandler do
@moduledoc """
# last.fm
- !lastfm [nick|username]
- say what nick/specified username is listening on lastfm; if last.fm username is known (via +lastfm).
- !lastfmall
- say what known users (+lastfm) are listening
- +lastfm <username>
- links the nick who use the command to <username> last.fm account.
- -lastfm
- unlinks the nick's previously set last.fm username.
+ * **!lastfm `[nick|username]`**
+ * **!lastfmall**
+ * **+lastfm `<username last.fm>`, -lastfm**
"""
defstruct client: nil, dets: nil
@@ -24,7 +19,7 @@ defmodule LSG.IRC.LastFmHandler do
def init([client]) do
ExIRC.Client.add_handler(client, self())
- dets_filename = Application.get_env(:lsg, __MODULE__)[:dets_path]
+ dets_filename = (LSG.data_path() <> "/" <> "lastfm.dets") |> String.to_charlist
{:ok, dets} = :dets.open_file(dets_filename, [])
{:ok, %__MODULE__{client: client, dets: dets}}
end
@@ -128,7 +123,7 @@ defmodule LSG.IRC.LastFmHandler do
end
defp lookup_nick(username, state) do
- case :dets.match(state.dets, {:'$1', username}) do
+ case :dets.match(state.dets, {:'$1', String.downcase(username)}) do
[[match]] -> match
[[match] | _many] -> match
_ -> username