fchat-rising/chat/interfaces.ts

265 lines
8.8 KiB
TypeScript
Raw Permalink Normal View History

2017-09-02 01:50:31 +00:00
//tslint:disable:no-shadowed-variable
2019-01-03 17:38:17 +00:00
import {Connection} from '../fchat';
2017-09-02 01:50:31 +00:00
import {Channel, Character} from '../fchat/interfaces';
2020-03-15 16:23:39 +00:00
import { AdManager } from './ads/ad-manager';
2022-01-01 00:06:08 +00:00
import { SmartFilterSettings } from '../learn/filter/types';
2017-09-02 01:50:31 +00:00
export {Connection, Channel, Character} from '../fchat/interfaces';
2019-01-03 17:38:17 +00:00
export const userStatuses: ReadonlyArray<Character.Status> = ['online', 'looking', 'away', 'busy', 'dnd'];
export const channelModes: ReadonlyArray<Channel.Mode> = ['chat', 'ads', 'both'];
2022-12-25 05:44:55 +00:00
import { Ad } from './ads/ad-center';
2017-09-02 01:50:31 +00:00
export namespace Conversation {
2019-01-03 17:38:17 +00:00
interface BaseMessage {
readonly id: number
readonly type: Message.Type
readonly text: string
2017-09-02 01:50:31 +00:00
readonly time: Date
2019-07-07 01:37:15 +00:00
2019-07-07 21:44:32 +00:00
score: number;
2022-01-01 00:06:08 +00:00
filterMatch: boolean;
2017-09-02 01:50:31 +00:00
}
2019-01-03 17:38:17 +00:00
export interface EventMessage extends BaseMessage {
readonly type: Message.Type.Event
}
export interface BcastMessage extends BaseMessage {
readonly type: Message.Type.Bcast
readonly sender: Character;
}
2019-01-03 17:38:17 +00:00
export interface ChatMessage extends BaseMessage {
2017-09-02 01:50:31 +00:00
readonly isHighlight: boolean
2019-01-03 17:38:17 +00:00
readonly sender: Character
2017-09-02 01:50:31 +00:00
}
export type Message = BcastMessage | EventMessage | ChatMessage;
2017-09-02 01:50:31 +00:00
2019-01-03 17:38:17 +00:00
export interface SFCMessage extends EventMessage {
sfc: Connection.ServerCommands['SFC'] & {confirmed?: true}
}
2017-09-02 01:50:31 +00:00
export namespace Message {
export enum Type {
Message,
Action,
Ad,
Roll,
Warn,
Event,
Bcast
2017-09-02 01:50:31 +00:00
}
}
export type RecentChannelConversation = {readonly channel: string, readonly name: string};
export type RecentPrivateConversation = {readonly character: string};
2017-09-02 01:50:31 +00:00
export type TypingStatus = 'typing' | 'paused' | 'clear';
interface TabConversation extends Conversation {
isPinned: boolean
readonly maxMessageLength: number
2018-01-06 16:14:21 +00:00
close(): Promise<void> | void
sort(newIndex: number): Promise<void>
2017-09-02 01:50:31 +00:00
}
export interface PrivateConversation extends TabConversation {
readonly character: Character
readonly typingStatus: TypingStatus
2024-07-06 03:38:57 +00:00
sendMessageEx(text: string): Promise<void>;
2017-09-02 01:50:31 +00:00
}
export interface ChannelConversation extends TabConversation {
readonly channel: Channel
mode: Channel.Mode
2018-08-10 16:59:37 +00:00
readonly nextAd: number
2017-09-02 01:50:31 +00:00
isSendingAds: boolean
2020-10-20 23:19:43 +00:00
isSendingAutomatedAds(): boolean
toggleAutomatedAds(): void
hasAutomatedAds(): boolean
2019-06-02 23:57:32 +00:00
sendAd(text: string): Promise<void>
2017-09-02 01:50:31 +00:00
}
export function isPrivate(conversation: Conversation): conversation is PrivateConversation {
return (<Partial<PrivateConversation>>conversation).character !== undefined;
}
export function isChannel(conversation: Conversation): conversation is ChannelConversation {
return (<Partial<ChannelConversation>>conversation).channel !== undefined;
}
export interface State {
readonly privateConversations: ReadonlyArray<PrivateConversation>
readonly channelConversations: ReadonlyArray<ChannelConversation>
readonly consoleTab: Conversation
2019-01-03 17:38:17 +00:00
readonly recent: ReadonlyArray<RecentPrivateConversation>
readonly recentChannels: ReadonlyArray<RecentChannelConversation>
2017-09-02 01:50:31 +00:00
readonly selectedConversation: Conversation
2018-01-06 16:14:21 +00:00
readonly hasNew: boolean;
2017-09-02 01:50:31 +00:00
byKey(key: string): Conversation | undefined
getPrivate(character: Character): PrivateConversation;
getPrivate(character: Character, noCreate: boolean): PrivateConversation | undefined;
2017-09-02 01:50:31 +00:00
}
export enum Setting {
True, False, Default
}
export interface Settings {
readonly notify: Setting;
readonly highlight: Setting;
readonly highlightWords: ReadonlyArray<string>;
readonly joinMessages: Setting;
2017-10-18 23:29:28 +00:00
readonly defaultHighlights: boolean;
2019-06-02 23:57:32 +00:00
readonly adSettings: AdSettings;
2017-09-02 01:50:31 +00:00
}
2019-06-02 23:57:32 +00:00
export interface AdSettings {
readonly ads: string[];
2020-12-28 23:07:10 +00:00
readonly randomOrder: boolean;
2022-09-03 18:11:37 +00:00
readonly lastAdTimestamp: number;
2019-06-02 23:57:32 +00:00
}
2017-09-02 01:50:31 +00:00
export const enum UnreadState { None, Unread, Mention }
export interface Conversation {
enteredText: string;
infoText: string;
readonly name: string;
readonly messages: ReadonlyArray<Message>;
readonly reportMessages: ReadonlyArray<Message>;
readonly lastRead: Message | undefined
errorText: string
readonly key: string
readonly unread: UnreadState
settings: Settings
2019-06-07 19:31:42 +00:00
readonly adManager: AdManager;
2018-01-06 16:14:21 +00:00
send(): Promise<void>
clear(): void
2017-09-02 01:50:31 +00:00
loadLastSent(): void
show(): void
2018-08-10 16:59:37 +00:00
loadMore(): boolean
2017-09-02 01:50:31 +00:00
}
}
export type Conversation = Conversation.Conversation;
export namespace Logs {
export type Conversation = {readonly key: string, readonly name: string};
}
2018-03-28 13:51:05 +00:00
export interface Logs {
logMessage(conversation: Conversation, message: Conversation.Message): Promise<void> | void
getBacklog(conversation: Conversation): Promise<ReadonlyArray<Conversation.Message>>
getConversations(character: string): Promise<ReadonlyArray<Logs.Conversation>>
getLogs(character: string, key: string, date: Date): Promise<ReadonlyArray<Conversation.Message>>
getLogDates(character: string, key: string): Promise<ReadonlyArray<Date>>
getAvailableCharacters(): Promise<ReadonlyArray<string>>
2018-04-16 23:14:13 +00:00
canZip: boolean;
2017-09-02 01:50:31 +00:00
}
2020-03-21 21:28:03 +00:00
export type SearchKink = {id: number, name: string, description: string};
2020-10-20 23:19:43 +00:00
export type SearchSpecies = {id: number, name: string, shortName: string, details: string, keywords: string};
2020-03-21 21:28:03 +00:00
export interface SearchData {
kinks: SearchKink[]
genders: string[]
orientations: string[]
languages: string[]
furryprefs: string[]
roles: string[]
positions: string[]
2021-11-28 04:15:33 +00:00
bodytypes: string[]
2020-03-21 21:28:03 +00:00
}
2020-04-11 20:23:53 +00:00
export interface ExtendedSearchData extends SearchData {
species: SearchSpecies[];
}
2020-03-21 21:28:03 +00:00
2017-09-02 01:50:31 +00:00
export namespace Settings {
export type Keys = {
2020-03-21 18:35:22 +00:00
settings: Settings
pinned: {channels: string[], private: string[]}
conversationSettings: {[key: string]: Conversation.Settings | undefined}
modes: {[key: string]: Channel.Mode | undefined}
2019-01-03 17:38:17 +00:00
recent: Conversation.RecentPrivateConversation[]
recentChannels: Conversation.RecentChannelConversation[]
hiddenUsers: string[]
2023-05-30 01:35:04 +00:00
favoriteEIcons: Record<string, boolean>
2020-03-21 18:35:22 +00:00
statusHistory: string[]
2020-04-11 20:23:53 +00:00
searchHistory: (ExtendedSearchData | SearchData)[]
2020-06-18 20:17:00 +00:00
hideNonMatchingAds: boolean
hideProfileComparisonSummary: boolean
2022-12-25 05:44:55 +00:00
ads: Ad[]
2017-09-02 01:50:31 +00:00
};
export interface Store {
get<K extends keyof Keys>(key: K, character?: string): Promise<Keys[K] | undefined>
2018-03-28 13:51:05 +00:00
getAvailableCharacters(): Promise<ReadonlyArray<string>>
2017-09-02 01:50:31 +00:00
set<K extends keyof Keys>(key: K, value: Keys[K]): Promise<void>
}
export interface Settings {
readonly playSound: boolean;
readonly clickOpensMessage: boolean;
readonly disallowedTags: ReadonlyArray<string>;
readonly notifications: boolean;
readonly highlight: boolean;
readonly highlightWords: ReadonlyArray<string>;
readonly showAvatars: boolean;
readonly animatedEicons: boolean;
readonly idleTimer: number;
readonly messageSeparators: boolean;
readonly eventMessages: boolean;
readonly joinMessages: boolean;
readonly alwaysNotify: boolean;
readonly logMessages: boolean;
readonly logAds: boolean;
readonly fontSize: number;
readonly showNeedsReply: boolean;
2018-03-28 13:51:05 +00:00
readonly enterSend: boolean;
readonly colorBookmarks: boolean;
2018-07-20 01:12:26 +00:00
readonly bbCodeBar: boolean;
readonly risingAdScore: boolean;
readonly risingLinkPreview: boolean;
readonly risingAutoCompareKinks: boolean;
2020-10-25 16:55:21 +00:00
readonly risingAutoExpandCustomKinks: boolean;
readonly risingCharacterPreview: boolean;
readonly risingComparisonInUserMenu: boolean;
readonly risingComparisonInSearch: boolean;
2020-11-27 20:58:14 +00:00
readonly risingShowUnreadOfflineCount: boolean;
2020-12-30 04:54:16 +00:00
readonly risingColorblindMode: boolean;
2022-12-10 22:42:15 +00:00
readonly risingShowPortraitNearInput: boolean;
2023-03-30 00:23:54 +00:00
readonly risingShowPortraitInMessage: boolean;
2024-01-29 01:21:09 +00:00
readonly risingShowHighQualityPortraits: boolean;
2022-01-01 00:06:08 +00:00
readonly risingFilter: SmartFilterSettings;
readonly risingCharacterTheme: string | undefined;
2017-09-02 01:50:31 +00:00
}
}
export type Settings = Settings.Settings;
export interface Notifications {
isInBackground: boolean
2018-07-20 01:12:26 +00:00
notify(conversation: Conversation, title: string, body: string, icon: string, sound: string): Promise<void>
2018-08-10 16:59:37 +00:00
playSound(sound: string): void
2018-01-06 16:14:21 +00:00
requestPermission(): Promise<void>
2018-07-20 01:12:26 +00:00
initSounds(sounds: ReadonlyArray<string>): Promise<void>
2017-09-02 01:50:31 +00:00
}
export interface State {
2023-05-30 01:35:04 +00:00
settings: Settings;
hiddenUsers: string[];
favoriteEIcons: Record<string, boolean>;
2020-03-15 16:23:39 +00:00
}