Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
substrate-tip-bot
Commits
aab596c8
Verified
Commit
aab596c8
authored
Oct 11, 2021
by
Adam Zerella
Browse files
More lint fixing
parent
ae5fe7d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
index.js
View file @
aab596c8
...
...
@@ -8,13 +8,13 @@ module.exports = (app) => {
app
.
on
(
'
issue_comment
'
,
async
(
context
)
=>
{
// Get all the relevant contextual information.
le
t
commentText
=
context
.
payload
.
comment
.
body
;
le
t
pullRequestBody
=
context
.
payload
.
issue
.
body
;
le
t
pullRequestUrl
=
context
.
payload
.
issue
.
html_url
;
le
t
tipper
=
context
.
payload
.
comment
.
user
.
login
;
le
t
contributor
=
context
.
payload
.
issue
.
user
.
login
;
le
t
pullRequestNumber
=
context
.
payload
.
issue
.
number
;
le
t
pullRequestRepo
=
context
.
payload
.
repository
.
name
;
cons
t
commentText
=
context
.
payload
.
comment
.
body
;
cons
t
pullRequestBody
=
context
.
payload
.
issue
.
body
;
cons
t
pullRequestUrl
=
context
.
payload
.
issue
.
html_url
;
cons
t
tipper
=
context
.
payload
.
comment
.
user
.
login
;
cons
t
contributor
=
context
.
payload
.
issue
.
user
.
login
;
cons
t
pullRequestNumber
=
context
.
payload
.
issue
.
number
;
cons
t
pullRequestRepo
=
context
.
payload
.
repository
.
name
;
// The bot only triggers on creation of a new comment on a pull request.
if
(
...
...
@@ -29,7 +29,7 @@ module.exports = (app) => {
}
// Any problems along the way will be stored here, and used to return an error if needed.
le
t
problemsText
=
[];
cons
t
problemsText
=
[];
if
(
tipper
===
contributor
)
{
// todo undo
...
...
@@ -52,8 +52,8 @@ module.exports = (app) => {
let
network
,
address
,
size
;
// match "polkadot address: <ADDRESS>"
le
t
addressRegex
=
/
(
polkadot|kusama|localtest
)
address:
\s?([
a-z0-9
]
+
)
/i
;
le
t
maybeMatch
=
pullRequestBody
.
match
(
addressRegex
);
cons
t
addressRegex
=
/
(
polkadot|kusama|localtest
)
address:
\s?([
a-z0-9
]
+
)
/i
;
cons
t
maybeMatch
=
pullRequestBody
.
match
(
addressRegex
);
if
(
!
maybeMatch
||
maybeMatch
.
length
!=
3
)
{
problemsText
.
push
(
`Contributor did not properly post their Polkadot or Kusama address. Make sure the pull request has: "{network} address: {address}".`
...
...
@@ -69,7 +69,7 @@ module.exports = (app) => {
}
// Tip initiation comment should be: "/tip { small / medium / large }"
le
t
textParts
=
commentText
.
split
(
'
'
);
cons
t
textParts
=
commentText
.
split
(
'
'
);
if
(
textParts
.
length
!==
2
)
{
problemsText
.
push
(
`Invalid command! Payload should be: "/tip { small / medium / large }".`
...
...
@@ -104,7 +104,7 @@ module.exports = (app) => {
`Valid command! \n
${
tipper
}
wants to tip
${
contributor
}
(
${
address
}
on
${
network
}
) a
${
size
}
tip for pull request
${
pullRequestUrl
}
.`
);
// Send the transaction to the network.
le
t
result
=
await
tipUser
(
cons
t
result
=
await
tipUser
(
address
,
contributor
,
network
,
...
...
@@ -179,7 +179,7 @@ async function tipUser(
`You are connected to chain
${
chain
}
using
${
nodeName
}
v
${
nodeVersion
}
`
);
le
t
reason
=
`TO:
${
contributor
}
FOR:
${
pullRequestRepo
}
#
${
pullRequestNumber
}
(
${
size
}
)`
;
cons
t
reason
=
`TO:
${
contributor
}
FOR:
${
pullRequestRepo
}
#
${
pullRequestNumber
}
(
${
size
}
)`
;
// TODO before submitting, check tip does not already exist via a storage query.
// TODO potentially prevent duplicates by also checking for reasons with the other sizes.
const
unsub
=
await
api
.
tx
.
tips
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment