oberknecht-utils
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -6,7 +6,7 @@ "use strict"; | ||
function cleanChannelName(channel) { | ||
if (!channel) | ||
if (!(channel ?? undefined)) | ||
return undefined; | ||
return (0, recreate_1.recreate)(channel).toString().trim().replace(/^#/g, ""); | ||
return (0, recreate_1.recreate)(channel.toString()).trim().replace(/^#/g, ""); | ||
} | ||
exports.cleanChannelName = cleanChannelName; | ||
; |
@@ -1,1 +0,1 @@ | ||
export declare function correctChannelName(channel: string | any): string | undefined; | ||
export declare function correctChannelName<channelinput extends string>(channel: channelinput | undefined): channelinput extends string ? string : string | undefined; |
@@ -1,1 +0,1 @@ | ||
export declare function correctMessage(message: string | any): string | undefined; | ||
export declare function correctMessage(message: string | any): string; |
@@ -6,3 +6,3 @@ "use strict"; | ||
if (!(message ?? undefined)) | ||
return undefined; | ||
return ""; | ||
return message.trim().replace(/\s+/g, " "); | ||
@@ -9,0 +9,0 @@ } |
@@ -1,5 +0,2 @@ | ||
interface BadgesMap { | ||
[key: string]: string; | ||
} | ||
export type BadgesMap = Record<string, string>; | ||
export declare function messageBadges(badges: string): BadgesMap; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.messageBadges = void 0; | ||
; | ||
function messageBadges(badges) { | ||
@@ -6,0 +5,0 @@ let r = {}; |
@@ -1,1 +0,1 @@ | ||
export declare function messageCommand(rawMessage: string | any): string | undefined; | ||
export declare function messageCommand(rawMessage: string | undefined): string; |
@@ -6,3 +6,3 @@ "use strict"; | ||
if (!(rawMessage ?? undefined)) | ||
return undefined; | ||
return ""; | ||
let r = rawMessage.split(" ").filter(a => { return (/^[A-Z]+$/g.test(a)); })[0]; | ||
@@ -9,0 +9,0 @@ if (!r) |
@@ -1,1 +0,1 @@ | ||
export declare function messageContent(rawMessage: string | any): string | undefined; | ||
export declare function messageContent<stringInput extends string>(rawMessage: stringInput | undefined): stringInput extends string ? string : string | undefined; |
@@ -1,1 +0,6 @@ | ||
export declare function messageEmotes(rawEmotes: string): string[]; | ||
export type messageEmote = { | ||
"start": number; | ||
"end": number; | ||
}; | ||
export type messageEmotesReturn = Record<string, messageEmote>; | ||
export declare function messageEmotes(rawEmotes: string): messageEmotesReturn; |
@@ -6,8 +6,15 @@ "use strict"; | ||
if (!(rawEmotes ?? undefined)) | ||
return []; | ||
return rawEmotes.split(",").map(a => { | ||
return a.split(":")[0]; | ||
return {}; | ||
let r = {}; | ||
rawEmotes.split(",").map(a => { | ||
let b = a.split(":"); | ||
let c = b[1].split("-"); | ||
r[b[0]] = { | ||
"start": c[0], | ||
"end": c[1] | ||
}; | ||
}); | ||
return r; | ||
} | ||
exports.messageEmotes = messageEmotes; | ||
; |
@@ -1,1 +0,1 @@ | ||
export declare function messageParameters(rawMessage: string | any): {}; | ||
export declare function messageParameters(rawMessage: string | any): Record<string, string>; |
@@ -1,1 +0,1 @@ | ||
export declare function messagePrefix(rawMessage: string | any): string | undefined; | ||
export declare function messagePrefix(rawMessage: string | any): string; |
@@ -6,6 +6,6 @@ "use strict"; | ||
if (!(rawMessage ?? undefined)) | ||
return undefined; | ||
return rawMessage.split(" ").filter((v, i) => { return i <= 2 && /^:+(\w+\!\w+@\w+\.)*tmi\.twitch\.tv/g.test(v); })[0] || undefined; | ||
return ""; | ||
return rawMessage.split(" ").filter((v, i) => { return i <= 2 && /^:+(\w+\!\w+@\w+\.)*tmi\.twitch\.tv/g.test(v); })[0] ?? ""; | ||
} | ||
exports.messagePrefix = messagePrefix; | ||
; |
@@ -1,1 +0,1 @@ | ||
export declare function messageUser(rawMessage: string | any): string | undefined; | ||
export declare function messageUser<usertype extends string>(rawMessage: usertype | undefined): usertype extends string ? string : string | undefined; |
@@ -1,4 +0,4 @@ | ||
export function correctChannelName(channel: string | any): string | undefined { | ||
export function correctChannelName<channelinput extends string>(channel: channelinput | undefined): channelinput extends string ? string : string | undefined { | ||
if (!(channel ?? undefined)) return undefined; | ||
return `#${channel.toLowerCase().trim().replace(/^#/g, "")}` | ||
}; |
@@ -1,5 +0,5 @@ | ||
export function correctMessage(message: string | any): string | undefined { | ||
if (!(message ?? undefined)) return undefined; | ||
export function correctMessage(message: string | any): string { | ||
if (!(message ?? undefined)) return ""; | ||
return message.trim().replace(/\s+/g, " "); | ||
}; |
@@ -1,2 +0,2 @@ | ||
interface BadgesMap { [key: string]: string; }; | ||
export type BadgesMap = Record<string, string>; | ||
@@ -3,0 +3,0 @@ export function messageBadges(badges: string): BadgesMap { |
@@ -1,3 +0,3 @@ | ||
export function messageCommand(rawMessage: string | any): string | undefined { | ||
if (!(rawMessage ?? undefined)) return undefined; | ||
export function messageCommand(rawMessage: string | undefined): string { | ||
if (!(rawMessage ?? undefined)) return ""; | ||
let r = rawMessage.split(" ").filter(a => { return (/^[A-Z]+$/g.test(a)) })[0]; | ||
@@ -4,0 +4,0 @@ if (!r) r = rawMessage.split(" ").filter(a => { return (/^[0-9]{3}$/g.test(a)) })[0]; |
@@ -1,3 +0,3 @@ | ||
export function messageContent(rawMessage: string | any): string | undefined { | ||
export function messageContent<stringInput extends string>(rawMessage: stringInput | undefined): stringInput extends string ? string : string | undefined { | ||
return rawMessage?.split(" ")?.slice(4)?.join(" ")?.replace(/(^:|^\s|\s$)/g, "")?.replace(/[\s]{2,}/g, " ") ?? undefined; | ||
}; |
@@ -1,6 +0,21 @@ | ||
export function messageEmotes(rawEmotes: string) { | ||
if (!(rawEmotes ?? undefined)) return []; | ||
return rawEmotes.split(",").map(a => { | ||
return a.split(":")[0]; | ||
export type messageEmote = { | ||
"start": number, | ||
"end": number | ||
}; | ||
export type messageEmotesReturn = Record<string, messageEmote>; | ||
export function messageEmotes(rawEmotes: string): messageEmotesReturn { | ||
if (!(rawEmotes ?? undefined)) return {}; | ||
let r = {}; | ||
rawEmotes.split(",").map(a => { | ||
let b = a.split(":"); | ||
let c = b[1].split("-"); | ||
r[b[0]] = { | ||
"start": c[0], | ||
"end": c[1] | ||
}; | ||
}); | ||
return r; | ||
}; |
@@ -1,2 +0,2 @@ | ||
export function messageParameters(rawMessage: string | any): {} { | ||
export function messageParameters(rawMessage: string | any): Record<string, string> { | ||
let parameters = {}; | ||
@@ -3,0 +3,0 @@ if ((rawMessage ?? undefined) && rawMessage.startsWith("@")) rawMessage.split(" ")[0].substring(1).split(";").forEach(a => { return parameters[a.split("=")[0]] = a.split("=")[1] }); |
@@ -1,4 +0,4 @@ | ||
export function messagePrefix(rawMessage: string | any): string | undefined { | ||
if (!(rawMessage ?? undefined)) return undefined; | ||
return rawMessage.split(" ").filter((v, i) => { return i <= 2 && /^:+(\w+\!\w+@\w+\.)*tmi\.twitch\.tv/g.test(v) })[0] || undefined; | ||
export function messagePrefix(rawMessage: string | any): string { | ||
if (!(rawMessage ?? undefined)) return ""; | ||
return rawMessage.split(" ").filter((v, i) => { return i <= 2 && /^:+(\w+\!\w+@\w+\.)*tmi\.twitch\.tv/g.test(v) })[0] ?? ""; | ||
}; |
@@ -1,2 +0,2 @@ | ||
export function messageUser(rawMessage: string | any): string | undefined { | ||
export function messageUser<usertype extends string>(rawMessage: usertype | undefined): usertype extends string ? string : string | undefined { | ||
let match = rawMessage?.match(/(?<=^:)\w+(?=!)/g); | ||
@@ -3,0 +3,0 @@ if (!(rawMessage ?? undefined) || !(match ?? undefined)) return undefined; |
{ | ||
"name": "oberknecht-utils", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Utils for oberknecht packages", | ||
@@ -5,0 +5,0 @@ "main": "./lib-ts/utils/index", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86226
1647
118