MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / extractMediaOptions

Method extractMediaOptions

rev/rev.ts:517–556  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

515
516 // ==================== 参数解析 ====================
517
518 // 解析媒体处理参数: h=水平翻转, v=垂直翻转, c=颜色反转
519 private extractMediaOptions(args: string[]): MediaOptions {
520 let flipMode: FlipMode = null;
521 let flipSpecified = false;
522 let invertColors = false;
523 let index = 0;
524 const totalArgs = args.length;
525
526 while (index < args.length) {
527 const token = args[index].toLowerCase();
528
529 if (token === 'h') {
530 flipMode = 'h';
531 flipSpecified = true;
532 index++;
533 } else if (token === 'v') {
534 flipMode = 'v';
535 flipSpecified = true;
536 index++;
537 } else if (token === 'c') {
538 invertColors = true;
539 index++;
540 } else {
541 break;
542 }
543 }
544
545 // 默认行为:如果只有 c 参数,不添加翻转;否则默认水平翻转
546 if (
547 !flipSpecified &&
548 !(invertColors && index === totalArgs && totalArgs > 0)
549 ) {
550 flipMode = 'h';
551 }
552
553 return {
554 flipMode,
555 invertColors,
556 remaining: args.slice(index),
557 };
558 }
559

Callers 1

REVPluginClass · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected