-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from jchristgit/more-team-encouragement
Provide more team encouragement
- Loading branch information
Showing
4 changed files
with
51 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
defmodule FFBot.Encouragement do | ||
@moduledoc """ | ||
Encouragement functions for our Comrades. | ||
""" | ||
|
||
# Fractional percentage of how often the bot will generate a supportive | ||
# comment on merge. | ||
@support_a_comrade_margin 0.01 | ||
# Fractional percentage of how often the bot will generate an encouraging | ||
# comment on conflicts. | ||
@encourage_a_comrade_threshold 0.01 | ||
|
||
defp supports_comrades? do | ||
Application.get_env(:ff_bot, :disable_propaganda?) == nil | ||
end | ||
|
||
defp should_generate_supportive_comment? do | ||
:rand.uniform() < @support_a_comrade_margin | ||
end | ||
|
||
defp should_generate_encouraging_comment? do | ||
:rand.uniform() < @encourage_a_comrade_threshold | ||
end | ||
|
||
@doc """ | ||
On a slim chance, generate a comment that expresses appreciation in the comrade's work. | ||
""" | ||
def maybe_supportive_comment do | ||
if supports_comrades?() && should_generate_supportive_comment?() do | ||
". Glory to Arstotzka!" | ||
else | ||
"" | ||
end | ||
end | ||
|
||
@doc """ | ||
On a slim chance, generate a comment that expresses encouragement for the comrade to work better. | ||
""" | ||
def maybe_encouraging_comment do | ||
if supports_comrades?() && should_generate_encouraging_comment?() do | ||
". March on, Comrade!" | ||
else | ||
"" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters