Skip to content

Commit

Permalink
Merge branch 'refs/heads/rainbowcat' into feat/napcat
Browse files Browse the repository at this point in the history
# Conflicts:
#	main/src/controllers/FileAndFlashPhotoController.ts
#	main/src/controllers/ForwardController.ts
#	main/src/controllers/QuotLyController.ts
#	main/src/controllers/RequestController.ts
#	main/src/controllers/SetupController.ts
#	main/src/models/Instance.ts
#	main/src/models/env.ts
#	main/src/models/posthog.ts
#	main/src/services/ConfigService.ts
#	main/src/services/DeleteMessageService.ts
#	main/src/services/ForwardService.ts
#	main/src/services/InChatCommandsService.ts
  • Loading branch information
clansty committed Jul 11, 2024
2 parents 4af545b + 2f9cc7b commit 75f22b0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@ jobs:
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
"REPO=${{ github.repository }}"
"REF=${{ github.ref }}"
"COMMIT=${{ github.sha }}"
secrets: |
"npmrc=//npm.pkg.github.com/:_authToken=${{ secrets.GPR_TOKEN }}"
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,13 @@ COPY --from=build-front /app/ui/dist /app/front
ENV UI_PATH=/app/front

ENV DATA_DIR=/app/data

ARG REPO
ARG REF
ARG COMMIT
ENV REPO $REPO
ENV REF $REF
ENV COMMIT $COMMIT

EXPOSE 8080
CMD pnpm start
17 changes: 17 additions & 0 deletions main/src/models/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,57 @@ import path from 'path';

const configParsed = z.object({
DATA_DIR: z.string().default(path.resolve('./data')),

LOG_LEVEL: z.enum(['trace', 'debug', 'info', 'warn', 'error', 'fatal', 'mark', 'off']).default('info'),
OICQ_LOG_LEVEL: z.enum(['trace', 'debug', 'info', 'warn', 'error', 'fatal', 'mark', 'off']).default('warn'),
TG_LOG_LEVEL: z.enum(['none', 'error', 'warn', 'info', 'debug']).default('warn'),

FFMPEG_PATH: z.string().optional(),
FFPROBE_PATH: z.string().optional(),

SIGN_API: z.string().url().optional(),
SIGN_VER: z.string().optional(),

TG_API_ID: z.string().regex(/^\d+$/).transform(Number),
TG_API_HASH: z.string(),
TG_BOT_TOKEN: z.string(),
TG_CONNECTION: z.enum(['websocket', 'tcp']).default('tcp'),
TG_INITIAL_DCID: z.string().regex(/^\d+$/).transform(Number).optional(),
TG_INITIAL_SERVER: z.string().ip().optional(),
IPV6: z.string().transform((v) => ['true', '1', 'yes'].includes(v.toLowerCase())).default('false'),

PROXY_IP: z.string().ip().optional(),
PROXY_PORT: z.string().regex(/^\d+$/).transform(Number).optional(),
PROXY_USERNAME: z.string().optional(),
PROXY_PASSWORD: z.string().optional(),

TGS_TO_GIF: z.string().default('tgs_to_gif'),

CRV_API: z.string().url().optional(),
CRV_VIEWER_APP: z.string().url().startsWith('https://t.me/').optional(),
CRV_KEY: z.string().optional(),

ZINC_URL: z.string().url().optional(),
ZINC_USERNAME: z.string().optional(),
ZINC_PASSWORD: z.string().optional(),

BAIDU_APP_ID: z.string().optional(),
BAIDU_API_KEY: z.string().optional(),
BAIDU_SECRET_KEY: z.string().optional(),

DISABLE_FILE_UPLOAD_TIP: z.string().transform((v) => ['true', '1', 'yes'].includes(v.toLowerCase())).default('false'),

LISTEN_PORT: z.string().regex(/^\d+$/).transform(Number).default('8080'),

UI_PATH: z.string().optional(),
UI_PROXY: z.string().url().optional(),
WEB_ENDPOINT: z.string().url().optional(),

POSTHOG_OPTOUT: z.string().transform((v) => ['true', '1', 'yes'].includes(v.toLowerCase())).default('false'),

REPO: z.string().default('Local Build'),
REF: z.string().default('Local Build'),
COMMIT: z.string().default('Local Build'),
}).safeParse(process.env);

if (!configParsed.success) {
Expand Down
4 changes: 4 additions & 0 deletions main/src/models/posthog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export default {
if (typeof properties?.error === 'object' && properties.error.stack) {
properties.error = properties.error.stack;
}
properties.repo = env.REPO;
properties.ref = env.REF;
properties.commit = env.COMMIT;

client.capture({
event, properties,
distinctId: hostname,
Expand Down
3 changes: 3 additions & 0 deletions main/src/services/ForwardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ export default class ForwardService {
break;
}
case 'sface': {
if (!elem.text) {
elem.text = '表情:' + elem.id;
}
message += `[<i>${helper.htmlEscape(elem.text)}</i>]`;
break;
}
Expand Down

0 comments on commit 75f22b0

Please sign in to comment.