-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Astrian/dev
Add new features
- Loading branch information
Showing
7 changed files
with
89 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Import Airtable API and config | ||
const Airtable = require('airtable'); | ||
const debug = require('debug')('rsvpbot:importrsvp.js') | ||
|
||
// Import RSVP base | ||
const base = new Airtable({apiKey: process.env.AIRTABLE_TOKEN}).base(process.env.BASE_ID); | ||
|
||
module.exports = async function (faction, location, rsvplist) { | ||
let counter = 0 | ||
for (let i in rsvplist) { | ||
// check agent imported | ||
let agentsbase = await base(location).select({ | ||
view: "Grid view", | ||
filterByFormula: `{特工代号} = '${rsvplist[i]}'` | ||
}).firstPage() | ||
if (agentsbase.length) { debug(`特工 ${rsvplist[i]} 已在本场有所记录,将被忽略。`) } | ||
else { | ||
// if the agent not be logged into sheet, add a record for him/her | ||
let newrec = {} | ||
newrec['特工代号'] = rsvplist[i] | ||
newrec['阵营'] = faction | ||
await base(location).create(newrec) | ||
counter++ | ||
} | ||
} | ||
return `有 ${counter} 位特工的 RSVP 信息成功被录入。` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters