Bladeren bron

BeganApplicationReview added

singulart 2 jaren geleden
bovenliggende
commit
fbf96039b4
3 gewijzigde bestanden met toevoegingen van 22 en 1 verwijderingen
  1. 12 0
      scripts/wg-bot/src/joystream/discord.ts
  2. 9 1
      scripts/wg-bot/src/joystream/embeds.ts
  3. 1 0
      scripts/wg-bot/src/simulate.ts

+ 12 - 0
scripts/wg-bot/src/joystream/discord.ts

@@ -5,6 +5,7 @@ import {
     getApplicationTerminatedEmbed, 
     getApplicationWithdrawnEmbed, 
     getAppliedOnOpeningEmbed, 
+    getBeganApplicationReviewEmbed, 
     getLeaderSetEmbed, 
     getLeaderUnsetEmbed, 
     getMintCapacityChangedEmbed, 
@@ -34,6 +35,17 @@ export const processBlock = async (api: ApiPromise, client: Discord.Client, bloc
             const channel: Discord.TextChannel = client.channels.cache.get(workingGroups[section]) as Discord.TextChannel;
             if (channel) {
                 switch(method) {
+                    case "BeganApplicationReview":
+                        const beganReviewId = data[0] as OpeningId
+                        const beganReviewOpeningObject = await getOpening(api, section, hash, beganReviewId);
+                        const beganReviewHiringOpening = await getHiringOpening(api, hash, beganReviewOpeningObject.hiring_opening_id);
+                        const applicants = await Promise.all([...beganReviewOpeningObject.applications].map( async(appId: ApplicationId) => {
+                            const application = await getApplication(api, section, hash, appId);
+                            return await getMember(api, application.member_id);
+                        }));
+                        const beganReviewHiringOpeningText = JSON.parse(beganReviewHiringOpening.human_readable_text.toString());
+                        channel.send({ embeds: [getBeganApplicationReviewEmbed(beganReviewHiringOpeningText, applicants, blockNumber, value)] });
+                        break;
                     case "ApplicationTerminated":
                         const id = data[0] as ApplicationId
                         const terminatedApplication = await getApplication(api, section, hash, id);

+ 9 - 1
scripts/wg-bot/src/joystream/embeds.ts

@@ -115,12 +115,20 @@ export const getApplicationTerminatedOrWithdrawEmbed = (action: string, applicat
 export const getStakeUpdatedEmbed = (stake: Stake, member: Membership, action: string, blockNumber: number, event: EventRecord): Discord.MessageEmbed => {
     
     return addCommonProperties(new Discord.MessageEmbed()
-        .setTitle(`💰💰💰 ${member.handle}'s stake has been ${action} `)
+        .setTitle(`💰💰💰 ${member.handle}'s stake has been ${action}`)
         .addFields(
             { name: 'Stake', value: formatBalance(stake.value.toString(), { withUnit: 'JOY' }), inline: true }
         ), blockNumber, event );
 }
 
+export const getBeganApplicationReviewEmbed = (opening: any, applicants: Membership[], blockNumber: number, event: EventRecord): Discord.MessageEmbed => {
+    return addCommonProperties(new Discord.MessageEmbed()
+        .setTitle(`🏛 🏛 🏛 Applications review for opening '${opening.job.title}' started!`)
+        .setDescription(`Applicants: \n${applicants.map((applicant: Membership) => 
+            `📁 **${applicant.handle}** [\`${applicant.controller_account}\`]`).join('\n')}`), 
+            blockNumber, event);
+}
+
 const addCommonProperties = (embed: Discord.MessageEmbed, blockNumber: number, event: EventRecord) => {
     return embed.addFields(
         { name: 'Block', value: blockNumber + "", inline: true },

+ 1 - 0
scripts/wg-bot/src/simulate.ts

@@ -12,6 +12,7 @@ const eventsMapping = {
     'AppliedOnOpening': 4264168,
     'StakeIncreased': 4264798,
     'StakeDecreased': 4264862,
+    'BeganApplicationReview': 4276739,
 }