312 lines
7.9 KiB
JavaScript
312 lines
7.9 KiB
JavaScript
/**
|
|
* @author Marzavec ( https://github.com/marzavec )
|
|
* @summary App settings
|
|
* @version 1.0.0
|
|
* @description Exports an object that hold common constants
|
|
* @module Constants
|
|
*/
|
|
|
|
/**
|
|
* Internal version, used mainly for debugging
|
|
* @typedef {object} CodebaseVersion
|
|
*/
|
|
export const CodebaseVersion = '2.2.3b';
|
|
|
|
/* Base error ranges */
|
|
const GlobalErrors = 10;
|
|
const CaptchaNotif = GlobalErrors + 10;
|
|
const JoinErrors = CaptchaNotif + 10;
|
|
const ChannelErrors = JoinErrors + 10;
|
|
const InviteErrors = ChannelErrors + 10;
|
|
const SessionErrors = InviteErrors + 10;
|
|
const SaveConfigErrors = SessionErrors + 10;
|
|
const ClaimChannelErrors = SaveConfigErrors + 10;
|
|
const MakePrivateErrors = ClaimChannelErrors + 10;
|
|
const MakePublicErrors = MakePrivateErrors + 10;
|
|
const RenewClaimErrors = MakePublicErrors + 10;
|
|
const SetLevelErrors = RenewClaimErrors + 10;
|
|
const SetMOTDErrors = SetLevelErrors + 10;
|
|
const UnclaimChannelErrors = SetMOTDErrors + 10;
|
|
const ChangeColorErrors = UnclaimChannelErrors + 10;
|
|
const EmoteErrors = ChangeColorErrors + 10;
|
|
const WhisperErrors = EmoteErrors + 10;
|
|
const ForceColorErrors = WhisperErrors + 10;
|
|
const ForceFlairErrors = ForceColorErrors + 10;
|
|
const UsersErrors = ForceFlairErrors + 10;
|
|
const HackRequest = UsersErrors + 10;
|
|
const KickErrors = HackRequest + 10;
|
|
const LockRoomErrors = KickErrors + 10;
|
|
const WalletErrors = LockRoomErrors + 10;
|
|
|
|
/**
|
|
* Holds the numeric id values for each error type
|
|
* @typedef {object} Errors
|
|
*/
|
|
export const Errors = {
|
|
Global: {
|
|
RATELIMIT: GlobalErrors + 1,
|
|
UNKNOWN_USER: GlobalErrors + 2,
|
|
PERMISSION: GlobalErrors + 3,
|
|
INTERNAL_ERROR: GlobalErrors + 4,
|
|
MISSING_TRIPCODE: GlobalErrors + 5,
|
|
UNKNOWN_CMD: GlobalErrors + 6,
|
|
INVALID_PAYLOAD: GlobalErrors + 7,
|
|
LOGIN_REQUIRED: GlobalErrors + 8,
|
|
INVALID_DATA: GlobalErrors + 9,
|
|
},
|
|
|
|
Captcha: {
|
|
MUST_SOLVE: CaptchaNotif + 1,
|
|
},
|
|
|
|
Join: {
|
|
RATELIMIT: JoinErrors + 1,
|
|
INVALID_NICK: JoinErrors + 2,
|
|
ALREADY_JOINED: JoinErrors + 3,
|
|
NAME_TAKEN: JoinErrors + 4,
|
|
CHANNEL_LOCKED: JoinErrors + 5,
|
|
},
|
|
|
|
Channel: {
|
|
INVALID_NAME: ChannelErrors + 1,
|
|
INVALID_LENGTH: ChannelErrors + 2,
|
|
DEY_BANNED: ChannelErrors + 3,
|
|
},
|
|
|
|
Invite: {
|
|
RATELIMIT: InviteErrors + 1,
|
|
},
|
|
|
|
Session: {
|
|
BAD_SESSION: SessionErrors + 1,
|
|
},
|
|
|
|
SaveConfig: {
|
|
GENERAL_FAILURE: SaveConfigErrors + 1,
|
|
},
|
|
|
|
ClaimChannel: {
|
|
MODS_CANT: ClaimChannelErrors + 1,
|
|
ALREADY_OWNED: ClaimChannelErrors + 2,
|
|
},
|
|
|
|
MakePrivate: {
|
|
MISSING_PERMS: MakePrivateErrors + 1,
|
|
ALREADY_PRIVATE: MakePrivateErrors + 2,
|
|
},
|
|
|
|
MakePublic: {
|
|
MISSING_PERMS: MakePublicErrors + 1,
|
|
ALREADY_PUBLIC: MakePublicErrors + 2,
|
|
},
|
|
|
|
RenewClaim: {
|
|
MODS_CANT: RenewClaimErrors + 1,
|
|
NOT_OWNER: RenewClaimErrors + 2,
|
|
TOO_SOON: RenewClaimErrors + 3,
|
|
},
|
|
|
|
SetLevel: {
|
|
BAD_TRIP: SetLevelErrors + 1,
|
|
BAD_LABEL: SetLevelErrors + 2,
|
|
BAD_LEVEL: SetLevelErrors + 3,
|
|
APPLY_ERROR: SetLevelErrors + 4,
|
|
LEVEL_CONFLICT: SetLevelErrors + 5,
|
|
},
|
|
|
|
SetMOTD: {
|
|
TOO_LONG: SetMOTDErrors + 1,
|
|
},
|
|
|
|
UnclaimChannel: {
|
|
NOT_OWNED: UnclaimChannelErrors + 1,
|
|
FAKE_OWNER: UnclaimChannelErrors + 2,
|
|
},
|
|
|
|
ChangeColor: {
|
|
INVALID_COLOR: ChangeColorErrors + 1,
|
|
},
|
|
|
|
Emote: {
|
|
MISSING_TEXT: EmoteErrors + 1,
|
|
},
|
|
|
|
Whisper: {
|
|
MISSING_NICK: WhisperErrors + 1,
|
|
NO_REPLY: WhisperErrors + 2,
|
|
},
|
|
|
|
ForceColor: {
|
|
MISSING_NICK: ForceColorErrors + 1,
|
|
},
|
|
|
|
ForceFlairErrors: {
|
|
INVALID_FLAIR: ForceFlairErrors + 1,
|
|
MISSING_NICK: ForceFlairErrors + 2,
|
|
},
|
|
|
|
Users: {
|
|
BAD_HASH_OR_IP: UsersErrors + 1,
|
|
},
|
|
|
|
HackRequest: {
|
|
BAD_PERMS: HackRequest + 1,
|
|
RATELIMIT: HackRequest + 2,
|
|
TOO_LONG: HackRequest + 3,
|
|
BAD_URL: HackRequest + 4,
|
|
},
|
|
|
|
Kick: {
|
|
MISSING_NICK: KickErrors + 1,
|
|
},
|
|
|
|
LockRoom: {
|
|
LEVEL_TOO_HIGH: LockRoomErrors + 1,
|
|
LEVEL_REQUIRED: LockRoomErrors + 2,
|
|
},
|
|
|
|
Wallet: {
|
|
INVALID_AMOUNT: WalletErrors + 1,
|
|
MISSING_AMOUNT: WalletErrors + 2,
|
|
},
|
|
};
|
|
|
|
/* Base Info Ranges */
|
|
const InfoStart = 1000; // Start high to avoid collision
|
|
const AdminInfo = InfoStart + 100;
|
|
const ModInfo = AdminInfo + 100;
|
|
const CoreInfo = ModInfo + 100;
|
|
const CaptchaInfo = CoreInfo + 100;
|
|
const WalletInfo = CaptchaInfo + 100;
|
|
|
|
/**
|
|
* Holds the numeric id values for each info type
|
|
* @typedef {object} Info
|
|
*/
|
|
export const Info = {
|
|
Admin: {
|
|
YOU_ARE_MOD: AdminInfo + 1,
|
|
MOD_ADDED: AdminInfo + 2,
|
|
MOD_ADDED_BROADCAST: AdminInfo + 3,
|
|
BOMB_STATUS: AdminInfo + 4,
|
|
USER_LIST: AdminInfo + 5,
|
|
RELOAD_STATUS: AdminInfo + 6,
|
|
YOU_ARE_USER: AdminInfo + 7,
|
|
MOD_REMOVED: AdminInfo + 8,
|
|
MOD_REMOVED_BROADCAST: AdminInfo + 9,
|
|
CONFIG_SAVED: AdminInfo + 10,
|
|
SHOUT: AdminInfo + 11,
|
|
},
|
|
|
|
Mod: {
|
|
BANNED: ModInfo + 1,
|
|
BANNED_DETAILED: ModInfo + 2,
|
|
MUZZLED_DETAILED: ModInfo + 3,
|
|
KICKED_DETAILED: ModInfo + 4,
|
|
KICKED: ModInfo + 5,
|
|
LOCKED_DETAILED: ModInfo + 6,
|
|
LOCKED_GLOBAL_NOTIFY: ModInfo + 7,
|
|
UNMUZZLED_ALL: ModInfo + 8,
|
|
UNMUZZLED_DETAILED: ModInfo + 9,
|
|
UNBANNED: ModInfo + 10,
|
|
UNBANNED_DETAILED: ModInfo + 11,
|
|
UNBANNED_ALL: ModInfo + 12,
|
|
UNBANNED_ALL_DETAILED: ModInfo + 13,
|
|
UNLOCKED_DETAILED: ModInfo + 14,
|
|
UWUIFY_ENABLED: ModInfo + 15,
|
|
UWUIFY_DISABLED: ModInfo + 16,
|
|
},
|
|
|
|
Core: {
|
|
NICK_CHANGED: CoreInfo + 1,
|
|
MY_HASH: CoreInfo + 2,
|
|
HELP_TEXT: CoreInfo + 3,
|
|
MOTD: CoreInfo + 4,
|
|
STATS_FULL: CoreInfo + 5,
|
|
STATS_BASIC: CoreInfo + 6,
|
|
PURGATORY_QUOTE: CoreInfo + 7,
|
|
PURGATORY_NOTIFY: CoreInfo + 8,
|
|
},
|
|
|
|
Captcha: {
|
|
NOT_ENABLED: CaptchaInfo + 1,
|
|
DISABLED: CaptchaInfo + 2,
|
|
ALREADY_ENABLED: CaptchaInfo + 3,
|
|
ENABLED: CaptchaInfo + 4,
|
|
},
|
|
|
|
Wallet: {
|
|
DISCONNECTED: WalletInfo + 1,
|
|
ADDRESS_REQUESTED: WalletInfo + 2,
|
|
TX_RELAYED: WalletInfo + 3,
|
|
VIEWED: WalletInfo + 4,
|
|
CONNECTED: WalletInfo + 5,
|
|
},
|
|
};
|
|
|
|
/**
|
|
* The settings structure of a default, unowned channel
|
|
* @typedef {object} DefaultChannelSettings
|
|
*/
|
|
export const DefaultChannelSettings = {
|
|
owned: false,
|
|
ownerTrip: '',
|
|
lastAccessed: new Date(),
|
|
claimExpires: new Date(),
|
|
motd: '',
|
|
lockLevel: 0,
|
|
tripLevels: {},
|
|
};
|
|
|
|
/**
|
|
* An array of strings that may be used if the channel motd is empty
|
|
* @typedef {object} SystemMOTDs
|
|
*/
|
|
export const SystemMOTDs = [
|
|
'Protip: Using any hex color code, you can change your name color- for example: /color #FFFFFF',
|
|
'Protip: You can easily change your name with a command: /nick bob',
|
|
'Enjoying hack.chat? Support us: https://patreon.com/marzavec',
|
|
'We have a Twitter for some reason: https://x.com/HackDotChat',
|
|
'Protip: Use a password or add a "#" followed by a secret phrase to get a trip code',
|
|
'Protip: You can claim an unclaimed channel by using /claimchannel',
|
|
'Protip: You can send emotes like: /me does a thing',
|
|
'Protip: The owner of a channel can create moderators: /setlevel <trip> channelModerator',
|
|
'Protip: A moderator can kick people from the room: /kick <name>',
|
|
'Protip: Use /getchannels anytime to see a list of public channels',
|
|
'Protip: You can do ==/help== or ==/help command==',
|
|
'Protip: Privately message with: /whisper @name The message',
|
|
'Protip: A moderator can lock a channel with: /lockroom',
|
|
];
|
|
|
|
/**
|
|
* Maximum length of a channels MOTD string
|
|
* @typedef {object} MaxMOTDLength
|
|
*/
|
|
export const MaxMOTDLength = 500;
|
|
|
|
/**
|
|
* Maximum number of specialized trip levels, per channel
|
|
* @typedef {number} MaxChannelTrips
|
|
*/
|
|
export const MaxChannelTrips = 250;
|
|
|
|
/**
|
|
* How many days until a claim will expire
|
|
* @typedef {number} ClaimExpirationDays
|
|
*/
|
|
export const ClaimExpirationDays = 7;
|
|
|
|
/**
|
|
* Minutes between inactive channel checking
|
|
* @typedef {number} ChannelCheckInterval
|
|
*/
|
|
export const ChannelCheckInterval = 1000 * 60 * 10; // 10 minutes
|
|
|
|
/**
|
|
* How many minutes until a channel is considered inactive
|
|
* @typedef {number} InactiveAfter
|
|
*/
|
|
export const InactiveAfter = 1000 * 60 * 60; // 1 hour
|
|
|
|
export default Errors;
|