wip
This commit is contained in:
parent
efea6b72e6
commit
84d25077b5
6 changed files with 10 additions and 19 deletions
|
@ -4,4 +4,6 @@ export default {
|
||||||
'インスタンスの接続エラーにより後続処理が行えなくなる重大な不具合を修正',
|
'インスタンスの接続エラーにより後続処理が行えなくなる重大な不具合を修正',
|
||||||
'全員分の算出が終わるまで、ランキングを非表示に',
|
'全員分の算出が終わるまで、ランキングを非表示に',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const defaultTemplate = '昨日のMisskeyの活動は\n\nノート: {notesCount}({notesDelta})\nフォロー : {followingCount}({followingDelta})\nフォロワー :{followersCount}({followersDelta})\n\nでした。\n{url}';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { User } from '../models/entities/user';
|
import { User } from '../models/entities/user';
|
||||||
import { Score } from '../../common/types/score';
|
import { Score } from '../../common/types/score';
|
||||||
import { api } from '../services/misskey';
|
import { api } from '../services/misskey';
|
||||||
import { toSignedString } from './to-signed-string';
|
import { toSignedString } from '../../common/functions/to-signed-string';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ユーザーのスコアを取得します。
|
* ユーザーのスコアを取得します。
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import views from 'koa-views';
|
import views from 'koa-views';
|
||||||
|
|
||||||
|
|
||||||
import constant from './const';
|
import constant from './const';
|
||||||
|
|
||||||
export const render = views(__dirname + '/views', {
|
export const render = views(__dirname + '/views', {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { User } from '../models/entities/user';
|
import { User } from '../models/entities/user';
|
||||||
import { format } from '../functions/format';
|
import { format } from '../../common/functions/format';
|
||||||
import { getScores } from '../functions/get-scores';
|
import { getScores } from '../functions/get-scores';
|
||||||
import { api } from './misskey';
|
import { api } from './misskey';
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { config } from '../../config';
|
import { config } from '../../config';
|
||||||
import { User } from '../models/entities/user';
|
import { User } from '../../backend/models/entities/user';
|
||||||
import { Score } from '../../common/types/score';
|
import { Score } from '../types/score';
|
||||||
import { defaultTemplate } from '../../common/default-template';
|
import { defaultTemplate } from '../../backend/const';
|
||||||
|
import { IUser } from '../types/user';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 埋め込み変数の型
|
* 埋め込み変数の型
|
||||||
*/
|
*/
|
||||||
export type Variable = {
|
export type Variable = {
|
||||||
description?: string;
|
|
||||||
replace?: string | ((score: Score, user: User) => string);
|
replace?: string | ((score: Score, user: User) => string);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,43 +16,33 @@ export type Variable = {
|
||||||
*/
|
*/
|
||||||
export const variables: Record<string, Variable> = {
|
export const variables: Record<string, Variable> = {
|
||||||
notesCount: {
|
notesCount: {
|
||||||
description: 'ノート数',
|
|
||||||
replace: (score) => String(score.notesCount),
|
replace: (score) => String(score.notesCount),
|
||||||
},
|
},
|
||||||
followingCount: {
|
followingCount: {
|
||||||
description: 'フォロー数',
|
|
||||||
replace: (score) => String(score.followingCount),
|
replace: (score) => String(score.followingCount),
|
||||||
},
|
},
|
||||||
followersCount: {
|
followersCount: {
|
||||||
description: 'フォロワー数',
|
|
||||||
replace: (score) => String(score.followersCount),
|
replace: (score) => String(score.followersCount),
|
||||||
},
|
},
|
||||||
notesDelta: {
|
notesDelta: {
|
||||||
description: '昨日とのノート数の差',
|
|
||||||
replace: (score) => String(score.notesDelta),
|
replace: (score) => String(score.notesDelta),
|
||||||
},
|
},
|
||||||
followingDelta: {
|
followingDelta: {
|
||||||
description: '昨日とのフォロー数の差',
|
|
||||||
replace: (score) => String(score.followingDelta),
|
replace: (score) => String(score.followingDelta),
|
||||||
},
|
},
|
||||||
followersDelta: {
|
followersDelta: {
|
||||||
description: '昨日とのフォロワー数の差',
|
|
||||||
replace: (score) => String(score.followersDelta),
|
replace: (score) => String(score.followersDelta),
|
||||||
},
|
},
|
||||||
url: {
|
url: {
|
||||||
description: 'みす廃アラートのURL',
|
|
||||||
replace: config.url,
|
replace: config.url,
|
||||||
},
|
},
|
||||||
username: {
|
username: {
|
||||||
description: 'ユーザー名',
|
|
||||||
replace: (_, user) => String(user.username),
|
replace: (_, user) => String(user.username),
|
||||||
},
|
},
|
||||||
host: {
|
host: {
|
||||||
description: '所属するインスタンスのホスト名',
|
|
||||||
replace: (_, user) => String(user.host),
|
replace: (_, user) => String(user.host),
|
||||||
},
|
},
|
||||||
rating: {
|
rating: {
|
||||||
description: 'みす廃レート',
|
|
||||||
replace: (_, user) => String(user.rating),
|
replace: (_, user) => String(user.rating),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -65,7 +55,7 @@ const variableRegex = /\{([a-zA-Z0-9_]+?)\}/g;
|
||||||
* @param user ユーザー情報
|
* @param user ユーザー情報
|
||||||
* @returns 生成したテキスト
|
* @returns 生成したテキスト
|
||||||
*/
|
*/
|
||||||
export const format = (score: Score, user: User): string => {
|
export const format = (score: Score, user: IUser): string => {
|
||||||
const template = user.template || defaultTemplate;
|
const template = user.template || defaultTemplate;
|
||||||
return template.replace(variableRegex, (m, name) => {
|
return template.replace(variableRegex, (m, name) => {
|
||||||
const v = variables[name];
|
const v = variables[name];
|
Loading…
Add table
Add a link
Reference in a new issue