Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
ad0e34b990
|
|||
| 063a9c6b37 | |||
|
f05436e9b9
|
|||
| e305643f69 | |||
| 82a003ffeb | |||
|
fc0c113997
|
|||
|
5c6540580b
|
@@ -1,5 +1,4 @@
|
|||||||
const util = require('util');
|
const util = require('util');
|
||||||
const fetch = require('node-fetch');
|
|
||||||
const amountFromLabels = require('./utils/amount-from-labels');
|
const amountFromLabels = require('./utils/amount-from-labels');
|
||||||
const kindFromLabels = require('./utils/kind-from-labels');
|
const kindFromLabels = require('./utils/kind-from-labels');
|
||||||
|
|
||||||
@@ -56,7 +55,7 @@ module.exports = async function(robot, kredits) {
|
|||||||
robot.logger.debug(`[hubot-kredits] contribution attributes:`);
|
robot.logger.debug(`[hubot-kredits] contribution attributes:`);
|
||||||
robot.logger.debug(util.inspect(contributionAttr, { depth: 1, colors: true }));
|
robot.logger.debug(util.inspect(contributionAttr, { depth: 1, colors: true }));
|
||||||
|
|
||||||
return Contribution.addContribution(contributionAttr).catch(error => {
|
return Contribution.add(contributionAttr).catch(error => {
|
||||||
robot.logger.error(`[hubot-kredits] Error:`, error);
|
robot.logger.error(`[hubot-kredits] Error:`, error);
|
||||||
messageRoom(`I tried to add a contribution for ${giteaUser} for ${url}, but I encountered an error when submitting the tx:`);
|
messageRoom(`I tried to add a contribution for ${giteaUser} for ${url}, but I encountered an error when submitting the tx:`);
|
||||||
messageRoom(error.message);
|
messageRoom(error.message);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ module.exports = async function(robot, kredits) {
|
|||||||
robot.logger.debug(`[hubot-kredits] contribution attributes:`);
|
robot.logger.debug(`[hubot-kredits] contribution attributes:`);
|
||||||
robot.logger.debug(util.inspect(contributionAttr, { depth: 1, colors: true }));
|
robot.logger.debug(util.inspect(contributionAttr, { depth: 1, colors: true }));
|
||||||
|
|
||||||
return Contribution.addContribution(contributionAttr).catch(error => {
|
return Contribution.add(contributionAttr).catch(error => {
|
||||||
robot.logger.error(`[hubot-kredits] Error:`, error);
|
robot.logger.error(`[hubot-kredits] Error:`, error);
|
||||||
messageRoom(`I tried to add a contribution for ${githubUser} for ${url}, but I encountered an error when submitting the tx:`);
|
messageRoom(`I tried to add a contribution for ${githubUser} for ${url}, but I encountered an error when submitting the tx:`);
|
||||||
messageRoom(error.message);
|
messageRoom(error.message);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ module.exports = async function(robot, kredits) {
|
|||||||
kind: 'docs'
|
kind: 'docs'
|
||||||
};
|
};
|
||||||
|
|
||||||
return Contribution.addContribution(contribution).catch(error => {
|
return Contribution.add(contribution).catch(error => {
|
||||||
robot.logger.error(`[hubot-kredits] Adding contribution failed:`, error);
|
robot.logger.error(`[hubot-kredits] Adding contribution failed:`, error);
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
@@ -126,6 +126,7 @@ module.exports = async function(robot, kredits) {
|
|||||||
return [...new Set(changes.map(c => `"${c.title}"`))].join(', ');
|
return [...new Set(changes.map(c => `"${c.title}"`))].join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Currently not used
|
||||||
function calculateAmountForChanges(details) {
|
function calculateAmountForChanges(details) {
|
||||||
let amount;
|
let amount;
|
||||||
|
|
||||||
@@ -144,9 +145,8 @@ module.exports = async function(robot, kredits) {
|
|||||||
const dateNow = new Date();
|
const dateNow = new Date();
|
||||||
const dateYesterday = dateNow.setDate(dateNow.getDate() - 1);
|
const dateYesterday = dateNow.setDate(dateNow.getDate() - 1);
|
||||||
const date = (new Date(dateYesterday)).toISOString().split('T')[0];
|
const date = (new Date(dateYesterday)).toISOString().split('T')[0];
|
||||||
|
|
||||||
const details = analyzeUserChanges(user, changes);
|
const details = analyzeUserChanges(user, changes);
|
||||||
const amount = calculateAmountForChanges(details);
|
const amount = 500;
|
||||||
|
|
||||||
let desc = `Added ${details.charsAdded} characters of text.`;
|
let desc = `Added ${details.charsAdded} characters of text.`;
|
||||||
if (details.pagesChanged.length > 0) {
|
if (details.pagesChanged.length > 0) {
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hubot-kredits",
|
"name": "hubot-kredits",
|
||||||
"version": "3.7.0",
|
"version": "3.8.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hubot-kredits",
|
"name": "hubot-kredits",
|
||||||
"version": "3.7.0",
|
"version": "3.8.0",
|
||||||
"description": "Kosmos Kredits functionality for chat bots",
|
"description": "Kosmos Kredits functionality for chat bots",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user