|
@@ -11,19 +11,19 @@ const utils_1 = require("./utils");
|
|
|
const wiki_1 = require("./wiki");
|
|
|
exports.keywordMap = {
|
|
|
'ガチャ.*予告': '卡池',
|
|
|
- '(選べる.*|一日一回無料)ガチャ': '卡池',
|
|
|
- 'イベント開催決定': '活动',
|
|
|
+ '(選べる.*|一日一回無料|スタートダッシュ.*)ガチャ': '卡池',
|
|
|
+ 'イベント開催決定|フォトオーディション開催': '活动',
|
|
|
'タワー.*追加': '新塔',
|
|
|
'(生放送|配信)予告': '生放',
|
|
|
'メンテナンス予告': '维护',
|
|
|
'(育成応援|お仕事).*開催': '工作',
|
|
|
- '新曲一部公開': '新曲',
|
|
|
+ '新曲一部公開|3DLIVE映像公開': '新曲',
|
|
|
'キャラクター紹介': '组合',
|
|
|
'今後のアップデート情報': '计划',
|
|
|
'(?<!今後の)アップデート情報': '改修',
|
|
|
};
|
|
|
exports.recurringKeywords = [
|
|
|
- '(育成応援|お仕事).*開催', 'イベント開催決定', 'ガチャ$',
|
|
|
+ '(育成応援|お仕事|フォトオーディション).*開催', 'イベント開催決定', 'ガチャ$|フェスガチャ',
|
|
|
'アップデート情報', 'キャラクター紹介',
|
|
|
'(生放送|配信)予告', 'メンテナンス予告'
|
|
|
];
|
|
@@ -37,10 +37,13 @@ const processTweetBody = (tweet) => {
|
|
|
.replace(/((?<=\s)#.*?\s+)+$/g, '')
|
|
|
.trim()
|
|
|
.match(/(.*?)\n\n(.*)/s).slice(1);
|
|
|
- const date = new Date(tweet.created_at)
|
|
|
+ const dateMatch = /(\d+\/\d+)\(.\).*(?:から|~)\n/.exec(body);
|
|
|
+ const date = (dateMatch ?
|
|
|
+ new Date(`${new Date(tweet.created_at).getFullYear()}/${dateMatch[1]}`) :
|
|
|
+ new Date(tweet.created_at))
|
|
|
.toLocaleDateString('en-CA', { timeZone: 'Asia/Tokyo' })
|
|
|
.replace(/-/g, '');
|
|
|
- const pageTitle = title.replace(/[【】\/]/g, '') + `${exports.recurringKeywords.some(keyword => new RegExp(keyword).exec(title)) ? `-${date}` : ''}`;
|
|
|
+ const pageTitle = title.replace(/[【】\/\n]/g, '') + `${exports.recurringKeywords.some(keyword => new RegExp(keyword).exec(title)) ? `-${date}` : ''}`;
|
|
|
return { title, body, pageTitle, date };
|
|
|
};
|
|
|
exports.processTweetBody = processTweetBody;
|
|
@@ -127,27 +130,28 @@ class default_1 {
|
|
|
}
|
|
|
if (lock.offset === '0')
|
|
|
tweets.splice(1);
|
|
|
- return (0, utils_1.chainPromises)(tweets.reverse().map(tweet => () => {
|
|
|
+ return (0, utils_1.chainPromises)(tweets.slice(0).reverse().map(tweet => () => {
|
|
|
const match = /(.*?)\n\n(.*)/s.exec(tweet.full_text);
|
|
|
- if (!match)
|
|
|
- return Promise.resolve({});
|
|
|
- for (const keyword in exports.keywordMap) {
|
|
|
- if (new RegExp(keyword).exec(match[1])) {
|
|
|
- const tweetUrl = `${currentFeed}/status/${tweet.id_str}`;
|
|
|
- logger.info(`working on ${tweetUrl}`);
|
|
|
- return this.publisher.post(tweet, exports.keywordMap[keyword])
|
|
|
- .then(action => {
|
|
|
- if (action.result === 'Success') {
|
|
|
- this.lock.lastActions.push(action);
|
|
|
- logger.info(`successfully posted content of ${tweetUrl} to bwiki, link:`);
|
|
|
- logger.info(`https://wiki.biligame.com/idolypride/index.php?curid=${action.pageid}`);
|
|
|
- const message = `已更新如下页面:${(0, exports.parseAction)(action)}`;
|
|
|
- return Promise.all(this.lock.subscribers.map(subscriber => this.bot.sendTo(subscriber, message)));
|
|
|
- }
|
|
|
- }).then(updateDate).then(() => updateOffset(tweet.id_str));
|
|
|
+ if (match)
|
|
|
+ for (const keyword in exports.keywordMap) {
|
|
|
+ if (new RegExp(keyword).exec(match[1])) {
|
|
|
+ const tweetUrl = `${currentFeed}/status/${tweet.id_str}`;
|
|
|
+ logger.info(`working on ${tweetUrl}`);
|
|
|
+ return this.publisher.post(tweet, exports.keywordMap[keyword])
|
|
|
+ .then(action => {
|
|
|
+ if (action.result === 'Success') {
|
|
|
+ this.lock.lastActions.push(action);
|
|
|
+ logger.info(`successfully posted content of ${tweetUrl} to bwiki, link:`);
|
|
|
+ logger.info(`https://wiki.biligame.com/idolypride/index.php?curid=${action.pageid}`);
|
|
|
+ const message = `已更新如下页面:${(0, exports.parseAction)(action)}`;
|
|
|
+ return Promise.all(this.lock.subscribers.map(subscriber => this.bot.sendTo(subscriber, message))).then(() => { updateDate(); updateOffset(tweet.id_str); return true; });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }));
|
|
|
+ return Promise.resolve(false);
|
|
|
+ })).then(updated => { if (updated)
|
|
|
+ return; updateDate(); updateOffset(tweets[0].id_str); });
|
|
|
})
|
|
|
.then(() => {
|
|
|
let timeout = this.workInterval * 1000;
|