Skip to content

Discord bot: announce each new volunteer and the ancestor #26

@loredanacirstea

Description

@loredanacirstea

Listen to the RegisterVolunteer event on the blockchain and post a message on Discord with this announcement:

Tentative volunteer registered: <USERNAME>, <ETHEREUM_ADDRESS>. Ancestor: <ANCESTOR_USERNAME>, <ANCESTOR_ADDRESS>.
Tx: https://rinkeby.etherscan.io/tx/<TRANSACTION_HASH>

Add event watcher, similar to watching for new registered tasks:

function watchTasks (web3, thelaurel, lastBlock, callback, milliseconds) {
console.log('---- monitor watchTasks');
return watchEvent(web3, thelaurel, 'RegisterTask', lastBlock, callback, milliseconds);
}

and
const unsubscribeTasks = await watchTasks(web3, thelaurel, lastBlock, async (taskEvent) => {
, for building the data used in the message.

The actual message is formed in the bot.js file, similar to

monitoring-bot/bot.js

Lines 149 to 163 in 06b6481

function onTaskEvent (task) {
const etherscanlink = `https://rinkeby.etherscan.io/tx/` + task.transactionHash;
let msg_discord = `**Task registered by ${task.organizerData} - ${displayLaurelAmount(task.task.amount)} ${task.laurel}**
${task.gitHubIssue ? 'Url: ' + displayIssue(task.gitHubIssue) : 'ID: ' + task.taskid}
Tx: <${etherscanlink}>
`
const msg_twitter = `Task registered by ${task.organizerData} - ${displayLaurelAmount(task.task.amount)} ${task.laurel}
Tx: ${etherscanlink}
${task.gitHubIssue ? 'Url: ' + displayIssueTwitter(task.gitHubIssue) : task.taskid}
`
msg_discord = task.gitHubIssue ? (msg_discord + `Claim Url: <${LINK_CLAIM}&issue=${task.gitHubIssue.number}>`) : msg_discord;
console.log('-----onTaskEvent', msg_discord);
return postMessage(msg_discord, msg_twitter);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    not-takenYou can work on this task. Announce yourself in Discord before starting, so we can remove the label.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions