Cron tweet tasks enabled/disabled

This commit is contained in:
vjrj 2018-04-01 16:37:59 +02:00
parent 21531d1fd2
commit 4dfdd48e6a
2 changed files with 41 additions and 30 deletions

View file

@ -36,46 +36,55 @@ Meteor.startup(() => {
// collectionTTL: 172800
});
SyncedCron.add({
name: 'Check for fires stats in Spain and tweet about',
timezone: 'Europe/Madrid',
// Optionally set a positive offset if you wish to 'snooze' a schedule
// offset: 30 * 60 * 100,
// context: {
// userID: 'xyz'
// },
schedule: (parser) => {
const esEn = Meteor.settings.private.twitter.es.enabled;
const enEn = Meteor.settings.private.twitter.en.enabled;
if (esEn) {
SyncedCron.add({
name: 'Check for fires stats in Spain and tweet about',
timezone: 'Europe/Madrid',
// Optionally set a positive offset if you wish to 'snooze' a schedule
// offset: 30 * 60 * 100,
// context: {
// userID: 'xyz'
// },
schedule: (parser) => {
// this.magic = true; // Context is accesible here as this context.
// parser is a later.parse object
// return parser.text('every 2 minutes');
// http://bunkat.github.io/later/
const sched = parser.text(Meteor.settings.private.twitter.es.when);
if (sched.error !== -1) {
console.error(`Twitter cron 'when' field parsed with errors: ${sched.error}`);
}
return sched;
},
job: () => tweetIberiaFires()
const sched = parser.text(Meteor.settings.private.twitter.es.when);
if (sched.error !== -1) {
console.error(`Twitter cron 'when' field parsed with errors: ${sched.error}`);
}
return sched;
},
job: () => tweetIberiaFires()
/* console.log('cron is working');
* console.log(this.userID) // Context Object becomes this argument
* console.log(this.magic) /
* var numbersCrunched = CrushSomeNumbers();
* return numbersCrunched;
return tweetFires(); */
});
});
}
SyncedCron.add({
name: 'Check for fires stats in Europe and tweet about',
timezone: 'Europe/Madrid',
schedule: (parser) => {
const sched = parser.text(Meteor.settings.private.twitter.en.when);
if (sched.error !== -1) {
console.error(`Twitter cron 'when' field parsed with errors: ${sched.error}`);
}
return sched;
},
job: () => tweetEuropeFires()
});
if (enEn) {
SyncedCron.add({
name: 'Check for fires stats in Europe and tweet about',
timezone: 'Europe/Madrid',
schedule: (parser) => {
const sched = parser.text(Meteor.settings.private.twitter.en.when);
if (sched.error !== -1) {
console.error(`Twitter cron 'when' field parsed with errors: ${sched.error}`);
}
return sched;
},
job: () => tweetEuropeFires()
});
}
SyncedCron.start();
if (esEn || enEn) {
SyncedCron.start();
}
});

View file

@ -33,6 +33,7 @@
"ironPassword": "SomePasswordAlLeast32LongYouKnowHowToCount",
"twitter": {
"es": {
"enabled": true,
"comment": "using later.js",
"when": "at 9:15 am also at 3:15 pm also at 10:00 pm",
"consumer_key": "...",
@ -41,6 +42,7 @@
"access_token_secret": "..."
},
"en": {
"enabled": true,
"comment": "using later.js",
"when": "at 9:15 am also at 3:15 pm also at 10:00 pm",
"consumer_key": "...",