2025-10-13 23:20:26 -05:00
|
|
|
import { type Region } from './regions';
|
2024-04-03 15:19:48 -05:00
|
|
|
|
2024-09-06 21:45:58 -05:00
|
|
|
export const MIN_REGION_IDS: Record<Region, number> = {
|
2024-05-18 21:12:11 -05:00
|
|
|
asia: 20e8,
|
|
|
|
|
com: 10e8,
|
|
|
|
|
eu: 5e8,
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-06 21:45:58 -05:00
|
|
|
export const MAX_REGION_IDS: Record<Region, number> = {
|
2024-05-18 21:12:11 -05:00
|
|
|
asia: 31e8 - 1,
|
2024-09-06 21:45:58 -05:00
|
|
|
com: MIN_REGION_IDS.asia - 1,
|
|
|
|
|
eu: MIN_REGION_IDS.com - 1,
|
2024-05-18 21:12:11 -05:00
|
|
|
};
|
|
|
|
|
|
2024-04-13 18:20:49 -05:00
|
|
|
export function idToRegion(id: number): Region {
|
2024-04-03 15:19:48 -05:00
|
|
|
if (id >= 42e8) {
|
|
|
|
|
throw new Error('bot id');
|
|
|
|
|
} else if (id >= 31e8) {
|
|
|
|
|
throw new Error('china id');
|
|
|
|
|
} else if (id >= 20e8) {
|
|
|
|
|
return 'asia';
|
|
|
|
|
} else if (id >= 10e8) {
|
|
|
|
|
return 'com';
|
|
|
|
|
} else if (id >= 5e8) {
|
|
|
|
|
return 'eu';
|
|
|
|
|
} else if (id >= 0) {
|
|
|
|
|
throw new Error('ru id');
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(`id ${id} is out of range`);
|
|
|
|
|
}
|
|
|
|
|
}
|