Skip to content

Commit 08efc4e

Browse files
committed
move default template to BotTemplates module
1 parent cb06a05 commit 08efc4e

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
defmodule Algora.BotTemplates do
2+
@moduledoc false
3+
4+
def get_default_template(:bounty_created) do
5+
"""
6+
${PRIZE_POOL}
7+
### Steps to solve:
8+
1. **Start working**: Comment `/attempt #${ISSUE_NUMBER}` with your implementation plan
9+
2. **Submit work**: Create a pull request including `/claim #${ISSUE_NUMBER}` in the PR body to claim the bounty
10+
3. **Receive payment**: 100% of the bounty is received 2-5 days post-reward. [Make sure you are eligible for payouts](https://docs.algora.io/bounties/payments#supported-countries-regions)
11+
12+
Thank you for contributing to ${REPO_FULL_NAME}!
13+
${ATTEMPTS}
14+
"""
15+
end
16+
17+
def get_default_template(_type) do
18+
raise "Not implemented"
19+
end
20+
end

lib/algora/bounties/bounties.ex

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ defmodule Algora.Bounties do
44
import Ecto.Query
55

66
alias Algora.Accounts.User
7+
alias Algora.BotTemplates
78
alias Algora.BotTemplates.BotTemplate
89
alias Algora.Bounties.Attempt
910
alias Algora.Bounties.Bounty
@@ -183,30 +184,22 @@ defmodule Algora.Bounties do
183184
prize_pool = format_prize_pool(bounties)
184185
attempts_table = format_attempts_table(attempts, claims)
185186

186-
message =
187+
template =
187188
if custom_template do
188189
custom_template.template
189-
|> String.replace("${PRIZE_POOL}", prize_pool)
190-
|> String.replace("${ISSUE_NUMBER}", to_string(ticket_ref[:number]))
191-
|> String.replace("${REPO_FULL_NAME}", "#{ticket_ref[:owner]}/#{ticket_ref[:repo]}")
192-
|> String.replace("${ATTEMPTS}", attempts_table)
193-
|> String.replace("${FUND_URL}", AlgoraWeb.Endpoint.url())
194-
|> String.replace("${TWEET_URL}", generate_tweet_url(bounties, ticket_ref))
195-
|> String.replace("${ADDITIONAL_OPPORTUNITIES}", "")
196190
else
197-
"""
198-
#{prize_pool}
199-
### Steps to solve:
200-
1. **Start working**: Comment `/attempt ##{ticket_ref[:number]}` with your implementation plan
201-
2. **Submit work**: Create a pull request including `/claim ##{ticket_ref[:number]}` in the PR body to claim the bounty
202-
3. **Receive payment**: 100% of the bounty is received 2-5 days post-reward. [Make sure you are eligible for payouts](https://docs.algora.io/bounties/payments#supported-countries-regions)
203-
204-
Thank you for contributing to #{ticket_ref[:owner]}/#{ticket_ref[:repo]}!
205-
#{attempts_table}
206-
"""
191+
BotTemplates.get_default_template(:bounty_created)
207192
end
208193

209-
String.trim(message)
194+
template
195+
|> String.replace("${PRIZE_POOL}", prize_pool)
196+
|> String.replace("${ISSUE_NUMBER}", to_string(ticket_ref[:number]))
197+
|> String.replace("${REPO_FULL_NAME}", "#{ticket_ref[:owner]}/#{ticket_ref[:repo]}")
198+
|> String.replace("${ATTEMPTS}", attempts_table)
199+
|> String.replace("${FUND_URL}", AlgoraWeb.Endpoint.url())
200+
|> String.replace("${TWEET_URL}", generate_tweet_url(bounties, ticket_ref))
201+
|> String.replace("${ADDITIONAL_OPPORTUNITIES}", "")
202+
|> String.trim()
210203
end
211204

212205
defp generate_tweet_url(bounties, ticket_ref) do

0 commit comments

Comments
 (0)