Skip to content

Commit

Permalink
Merge pull request #1 from ProducerMatt/dummy-rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
ProducerMatt authored Feb 21, 2024
2 parents bf32d42 + 22a38d6 commit 2cbc0c9
Show file tree
Hide file tree
Showing 16 changed files with 433 additions and 193 deletions.
37 changes: 37 additions & 0 deletions .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[
{"deps/nostrum/lib/nostrum/consumer.ex", "Function Nostrum.ConsumerGroup.join/1 does not exist."},
{"lib/service/discord.ex", "Function Nostrum.Api.create_message/2 does not exist."},
{"lib/service/discord.ex", "Function Nostrum.Api.get_channel_message/2 does not exist."},
{"lib/service/discord.ex", "Function Nostrum.Cache.Me.get/0 does not exist."},
{"lib/service/discord.ex", "Function Nostrum.Struct.User.full_name/1 does not exist."},
{"lib/stampede/application.ex", "Function Mix.env/0 does not exist."},
{"lib/stampede/interact.ex", "Function Mix.env/0 does not exist."},
{"/build/source/lib/elixir/lib/gen_server.ex", "Callback info about the Nostrum.Consumer behaviour is not available."},
{"lib/plugin.ex", "Function job_result/0 has no local return."},
{"lib/plugin.ex", "Function plugin_job_result/0 has no local return."},
{"lib/service/discord.ex", "Function logger_state/0 has no local return."},
{"lib/service/dummy.ex", "@spec for send_msg has more types than are returned by the function."},
{"lib/service/dummy.ex", "Function dummy_channel_id/0 has no local return."},
{"lib/service/dummy.ex", "Function dummy_msg_id/0 has no local return."},
{"lib/service/dummy.ex", "Function msg_content/0 has no local return."},
{"lib/service/dummy.ex", "Function msg_reference/0 has no local return."},
{"lib/service/dummy.ex", "Function msg_tuple/0 has no local return."},
{"lib/service/dummy.ex", "Function msg_tuple_incoming/0 has no local return."},
{"lib/service/dummy.ex", "Function channel/0 has no local return."},
{"lib/service/dummy.ex", "Function channel_buffers/0 has no local return."},
{"lib/service/dummy.ex", "Function dummy_servers/0 has no local return."},
{"lib/site_config.ex", "Function schema/0 has no local return."},
{"lib/stampede.ex", "Function log_level/0 has no local return."},
{"lib/stampede.ex", "Function log_msg/0 has no local return."},
{"lib/stampede.ex", "Function prefix/0 has no local return."},
{"lib/stampede.ex", "Function module_function_args/0 has no local return."},
{"lib/stampede.ex", "Function io_list/0 has no local return."},
{"lib/stampede.ex", "Function traceback/0 has no local return."},
{"lib/stampede.ex", "Function enabled_plugs/0 has no local return."},
{"lib/stampede.ex", "Function channel_lock_action/0 has no local return."},
{"lib/stampede.ex", "Function channel_lock_status/0 has no local return."},
{"lib/stampede.ex", "Function throw_internal_error/0 has no local return."},
{"lib/stampede.ex", "Function throw_internal_error/1 only terminates with explicit exception."},
{"lib/stampede/interact.ex", "Function mod_state/0 has no local return."},
{"deps/type_check/lib/type_check/spec.ex", "The pattern can never match the type {:ok, [], _}."}
]
19 changes: 0 additions & 19 deletions config/dialyzer.ignore

This file was deleted.

1 change: 1 addition & 0 deletions lib/plugin/sentience.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule Plugin.Sentience do
S.Response.new(
confidence: 1,
text: S.confused_response(),
origin_msg_id: msg.id,
why: ["I didn't have any better ideas."]
)
else
Expand Down
12 changes: 10 additions & 2 deletions lib/plugin/test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ defmodule Plugin.Test do
S.Response.new(
confidence: 10,
text: "pong!",
origin_msg_id: msg.id,
why: ["They pinged so I ponged!"]
)

Expand All @@ -24,8 +25,9 @@ defmodule Plugin.Test do
S.Response.new(
confidence: 10,
text: nil,
origin_msg_id: msg.id,
why: ["They want to test callbacks."],
callback: {__MODULE__, :callback_example, [num]}
callback: {__MODULE__, :callback_example, [num, msg.id]}
)

# test channel locks
Expand All @@ -34,6 +36,7 @@ defmodule Plugin.Test do
confidence: 10,
text: "locked in on #{msg.author_id} awaiting b",
why: ["Channel lock stage 1"],
origin_msg_id: msg.id,
callback: nil,
channel_lock: {:lock, msg.channel_id, {__MODULE__, :lock_callback, [:b]}}
)
Expand All @@ -53,9 +56,10 @@ defmodule Plugin.Test do
end
end

def callback_example(_cfg, num) when is_number(num) do
def callback_example(_cfg, num, msg_id) when is_number(num) do
S.Response.new(
confidence: 10,
origin_msg_id: msg_id,
text: "Called back with number #{num}"
)
end
Expand All @@ -67,6 +71,7 @@ defmodule Plugin.Test do
confidence: 10,
text: "b response. awaiting c",
why: ["Channel lock stage 1"],
origin_msg_id: msg.id,
callback: nil,
channel_lock: {:lock, msg.channel_id, {__MODULE__, :lock_callback, [:c]}}
)
Expand All @@ -76,6 +81,7 @@ defmodule Plugin.Test do
confidence: 10,
text: "lock broken by #{msg.author_id}",
why: ["Unmatched message, #{other |> S.pp()}"],
origin_msg_id: msg.id,
callback: nil,
channel_lock: {:unlock, msg.channel_id}
)
Expand All @@ -89,6 +95,7 @@ defmodule Plugin.Test do
confidence: 10,
text: "c response. interaction done!",
why: ["Channel lock test done"],
origin_msg_id: msg.id,
callback: nil,
channel_lock: {:unlock, msg.channel_id}
)
Expand All @@ -98,6 +105,7 @@ defmodule Plugin.Test do
confidence: 10,
text: "lock broken by #{msg.author_id}",
why: ["Unmatched message, #{other}"],
origin_msg_id: msg.id,
callback: nil,
channel_lock: {:unlock, msg.channel_id}
)
Expand Down
3 changes: 3 additions & 0 deletions lib/plugin/why.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ defmodule Plugin.Why do
confidence: valid_confidence,
text:
"It looks like you're asking about one of my messages, but you didn't reference which one.",
origin_msg_id: msg.id,
why: ["User didn't reference any message."]
)

Expand All @@ -42,13 +43,15 @@ defmodule Plugin.Why do
Response.new(
confidence: valid_confidence,
text: traceback,
origin_msg_id: msg.id,
why: ["User asked why I said something, so I told them."]
)

other ->
Response.new(
confidence: valid_confidence,
text: msg_fail(),
origin_msg_id: msg.id,
why: [
"We checked for an interaction from message ",
S.pp(ref),
Expand Down
2 changes: 1 addition & 1 deletion lib/service/discord.ex
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ defmodule Service.Discord.Handler do
our_msg =
Discord.into_msg(discord_msg)

our_cfg = S.CfgTable.get_server(Discord, our_msg.server_id)
our_cfg = S.CfgTable.get_cfg!(Discord, our_msg.server_id)

case Plugin.get_top_response(our_cfg, our_msg) do
%Response{text: r_text} when r_text != nil ->
Expand Down
Loading

0 comments on commit 2cbc0c9

Please sign in to comment.