decord/source/modules/chat/SlowmodeUtils.tsx

82 lines
3.9 KiB
TypeScript
Raw Normal View History

2026-07-25 08:10:48 +00:00
// Module ID: 5919
2026-07-27 11:26:19 +00:00
// Function ID: 52608
2026-07-20 16:05:17 +00:00
// Name: canBypassSlowmodeHelper
2026-07-25 08:10:48 +00:00
// Dependencies: [3759, 653, 566, 1212, 664, 3713, 2]
2026-07-20 16:05:17 +00:00
// Exports: canBypassSlowmode, getSlowmodeDescription, getSlowmodeIndicatorText, useCanBypassSlowmode
2026-07-25 08:10:48 +00:00
// Module 5919 (canBypassSlowmodeHelper)
2026-07-23 10:11:24 +00:00
import _isNativeReflectConstruct from "_isNativeReflectConstruct";
import { Permissions } from "ME";
const require = arg1;
function canBypassSlowmodeHelper(channel, arg1, _isNativeReflectConstruct) {
return _isNativeReflectConstruct.can(Permissions.BYPASS_SLOWMODE, channel);
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
const result = require("initialize").fileFinishedImporting("modules/chat/SlowmodeUtils.tsx");
2026-07-20 16:05:17 +00:00
export const canBypassSlowmode = function canBypassSlowmode(channel, SendMessage) {
2026-07-23 10:11:24 +00:00
return canBypassSlowmodeHelper(channel, undefined, _isNativeReflectConstruct);
2026-07-20 16:05:17 +00:00
};
export const useCanBypassSlowmode = function useCanBypassSlowmode(channel, slowmodeType) {
2026-07-23 10:11:24 +00:00
const _require = channel;
const items = [_isNativeReflectConstruct];
return _require(566).useStateFromStores(items, () => outer1_5(closure_0, undefined, outer1_3));
2026-07-20 16:05:17 +00:00
};
export const getSlowmodeIndicatorText = function getSlowmodeIndicatorText(stateFromStores, canBypassSlowmode) {
if (canBypassSlowmode) {
2026-07-23 10:11:24 +00:00
const intl2 = require(1212) /* getSystemLocale */.intl;
return intl2.string(require(1212) /* getSystemLocale */.t["8+NidX"]);
} else if (stateFromStores >= importDefault(664).Millis.HOUR) {
2026-07-25 08:10:48 +00:00
const durationResult = importDefault(3713).duration(stateFromStores);
2026-07-20 16:05:17 +00:00
const _HermesInternal3 = HermesInternal;
const combined = "" + durationResult.minutes();
2026-07-25 08:10:48 +00:00
const obj4 = importDefault(3713);
2026-07-20 16:05:17 +00:00
const _HermesInternal4 = HermesInternal;
const combined1 = "" + durationResult.seconds();
const padStartResult = combined.padStart(2, "0");
const _HermesInternal5 = HermesInternal;
return "" + durationResult.hours() + ":" + padStartResult + ":" + combined1.padStart(2, "0");
} else if (stateFromStores > 0) {
2026-07-25 08:10:48 +00:00
const durationResult1 = importDefault(3713).duration(stateFromStores);
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
const combined2 = "" + durationResult1.seconds();
2026-07-25 08:10:48 +00:00
const obj = importDefault(3713);
2026-07-20 16:05:17 +00:00
const _HermesInternal2 = HermesInternal;
return "" + durationResult1.minutes() + ":" + combined2.padStart(2, "0");
} else {
2026-07-23 10:11:24 +00:00
const intl = require(1212) /* getSystemLocale */.intl;
return intl.string(require(1212) /* getSystemLocale */.t.Icu3bf);
2026-07-20 16:05:17 +00:00
}
};
export const getSlowmodeDescription = function getSlowmodeDescription(rateLimitPerUser) {
let flag = arg1;
if (arg1 === undefined) {
flag = false;
}
2026-07-23 10:11:24 +00:00
if (rateLimitPerUser >= importDefault(664).Seconds.HOUR) {
2026-07-20 16:05:17 +00:00
const _Math2 = Math;
2026-07-23 10:11:24 +00:00
const rounded = Math.floor(rateLimitPerUser / importDefault(664).Seconds.HOUR);
2026-07-20 16:05:17 +00:00
const _Math3 = Math;
2026-07-23 10:11:24 +00:00
const diff = rateLimitPerUser - rounded * importDefault(664).Seconds.HOUR;
const rounded1 = Math.floor(diff / importDefault(664).Seconds.MINUTE);
const diff1 = rateLimitPerUser - rounded * importDefault(664).Seconds.HOUR;
const diff2 = diff1 - rounded1 * importDefault(664).Seconds.MINUTE;
const intl3 = require(1212) /* getSystemLocale */.intl;
const t3 = require(1212) /* getSystemLocale */.t;
2026-07-20 16:05:17 +00:00
let obj = { hours: rounded, minutes: rounded1, seconds: diff2 };
2026-07-23 10:11:24 +00:00
return intl3.formatToPlainString(flag ? t3.oEwLez : t3["3hz51F"], obj);
2026-07-20 16:05:17 +00:00
} else if (rateLimitPerUser >= 60) {
const _Math = Math;
const rounded2 = Math.floor(rateLimitPerUser / 60);
2026-07-23 10:11:24 +00:00
const intl2 = require(1212) /* getSystemLocale */.intl;
const t2 = require(1212) /* getSystemLocale */.t;
2026-07-20 16:05:17 +00:00
obj = { minutes: rounded2, seconds: rateLimitPerUser - 60 * rounded2 };
return intl2.formatToPlainString(flag ? t2.DARKYm : t2.sY3wlG, obj);
} else {
2026-07-23 10:11:24 +00:00
const intl = require(1212) /* getSystemLocale */.intl;
const t = require(1212) /* getSystemLocale */.t;
2026-07-20 16:05:17 +00:00
obj = { seconds: rateLimitPerUser };
2026-07-23 10:11:24 +00:00
return intl.formatToPlainString(flag ? t["9yE8Ga"] : t.IWntYg, obj);
2026-07-20 16:05:17 +00:00
}
};