chore: merge dev
to main
#181
1 changed files with 16 additions and 6 deletions
|
@ -46,13 +46,23 @@ export type dbReminder = {
|
||||||
* @returns An object with the time and the option
|
* @returns An object with the time and the option
|
||||||
*/
|
*/
|
||||||
export const splitTime = (time: string) => {
|
export const splitTime = (time: string) => {
|
||||||
if (time?.endsWith("@")) {
|
const mapping = {
|
||||||
return { time: time.slice(0, -1), option: OptionReminder.Mention };
|
[OptionReminder.DirectMessage]: "p",
|
||||||
} else if (time?.toLowerCase().endsWith("p")) {
|
[OptionReminder.Mention]: "@",
|
||||||
return { time: time.slice(0, -1), option: OptionReminder.DirectMessage };
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
const lowered = time.toLowerCase();
|
||||||
|
const trimmed = lowered.replaceAll(new RegExp(Object.values(mapping).join("|"), "g"), "");
|
||||||
|
|
||||||
|
// Depending of the last character of the string
|
||||||
|
switch (lowered.slice(-1)) {
|
||||||
|
case mapping[OptionReminder.Mention]:
|
||||||
|
return { time: trimmed, option: OptionReminder.Mention };
|
||||||
|
case mapping[OptionReminder.DirectMessage]:
|
||||||
|
return { time: trimmed, option: OptionReminder.DirectMessage };
|
||||||
|
default:
|
||||||
return { time: time, option: OptionReminder.Nothing };
|
return { time: time, option: OptionReminder.Nothing };
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue