0
0
Fork 0

コメント追加したり

This commit is contained in:
xeltica 2021-09-04 18:24:11 +09:00
parent 1c45e759c3
commit b9575d2c5b
22 changed files with 945 additions and 809 deletions

View file

@ -2,6 +2,9 @@ import { config } from '../../config';
import { User } from '../models/entities/user';
import { Score } from '../../common/types/score';
/**
* 稿
*/
export const defaultTemplate = `昨日のMisskeyの活動は
: {notesCount}({notesDelta})
@ -11,11 +14,17 @@ export const defaultTemplate = `昨日のMisskeyの活動は
{url}`;
/**
*
*/
export type Variable = {
description?: string;
replace?: string | ((score: Score, user: User) => string);
};
/**
*
*/
export const variables: Record<string, Variable> = {
notesCount: {
description: 'ノート数',
@ -61,6 +70,12 @@ export const variables: Record<string, Variable> = {
const variableRegex = /\{([a-zA-Z0-9_]+?)\}/g;
/**
*
* @param score
* @param user
* @returns
*/
export const format = (score: Score, user: User): string => {
const template = user.template || defaultTemplate;
return template.replace(variableRegex, (m, name) => {