Skip to content

Add cronjob to notify admin about missing solvers (#314) - #563

Closed
doitwithnotepad wants to merge 5 commits into
lnp2pBot:mainfrom
doitwithnotepad:main
Closed

Add cronjob to notify admin about missing solvers (#314)#563
doitwithnotepad wants to merge 5 commits into
lnp2pBot:mainfrom
doitwithnotepad:main

Conversation

@doitwithnotepad

Copy link
Copy Markdown
  • Schedule a daily job at midnight to check for solvers using node-schedule.

  • Implement checkSolvers(bot) to send a message to the community admin if no solvers are found.

  • Increment the count of messages sent to the admin in the database.

  • Add logic to disable the community if no solvers are added after a specified number of notifications.

Fixes #314

- Schedule a daily job at midnight to check for solvers using `node-schedule`.

- Implement `checkSolvers(bot)` to send a message to the community admin if no solvers are found.

- Increment the count of messages sent to the admin in the database.

- Add logic to disable the community if no solvers are added after a specified number of notifications.

Fixes lnp2pBot#314

@Catrya Catrya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @doitwithnotepad when it has to check if there are solvers it shows this in the logs :
error: Unhandled Rejection: TypeError: checkSolvers is not a function

Comment thread jobs/check_solvers.ts Outdated
Comment thread jobs/check_solvers.ts Outdated
@doitwithnotepad

Copy link
Copy Markdown
Author

Hi @doitwithnotepad when it has to check if there are solvers it shows this in the logs : error: Unhandled Rejection: TypeError: checkSolvers is not a function

It should now, 28360d2.

Comment thread jobs/check_solvers.ts Outdated
Comment thread jobs/index.js
const calculateEarnings = require('./calculate_community_earnings');
const deleteCommunity = require('./communities');
const nodeInfo = require('./node_info');
const checkSolvers = require('./check_solvers');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @doitwithnotepad please test the code before push a commit, that way you'll see if it works or not

we are getting the same error

error: Unhandled Rejection: TypeError: checkSolvers is not a function

this is because the function checkSolvers() is not well imported, please replace with:

const { checkSolvers } = require('./check_solvers');

Comment thread jobs/check_solvers.ts
logger.info(`Community ${community._id} has been disabled due to lack of solvers.`);
} else {
await community.save();
const admin = await User.findOne({ tg_id: community.creator_id, admin: true });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user.admin is only used for global admin, not community admins, we don't need to add it on this findOne() request

@grunch

grunch commented Aug 29, 2024

Copy link
Copy Markdown
Member

Hi @doitwithnotepad which is the status of this PR? are you able to finish it?

@Catrya

Catrya commented Oct 22, 2024

Copy link
Copy Markdown
Member

Hi @doitwithnotepad, are you able to finish this PR? The issue #314 is on the reward board , if you don't finish it, we should allow another dev to do it, and move it to status: looking for dev, what do you think?

@doitwithnotepad

Copy link
Copy Markdown
Author

I can't do it right now, maybe later, sorry for the delay in answering.

@Catrya

Catrya commented Feb 25, 2025

Copy link
Copy Markdown
Member

close in favor #618

@Catrya Catrya closed this Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bot message to community admin to update solvers

3 participants