Skip to content

Commit

Permalink
Use helper function in replacement
Browse files Browse the repository at this point in the history
jedenastka committed Feb 18, 2024
1 parent 8cd00a3 commit a4d91fb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/plugins/ircColors/index.ts
Original file line number Diff line number Diff line change
@@ -28,12 +28,15 @@ export default definePlugin({
find: "=\"SYSTEM_TAG\"",
replacement: {
match: /(?<=className:\i\.username,style:.{0,50}:void 0,)/,
replace: "style:{color:$self.calculateNameColor(BigInt(arguments[0].message.author.id))}"
replace: "style:{color:$self.calculateNameColorForContext(arguments[0])}"
},
},
],
// Calculate a CSS color string based on the user ID
calculateNameColor(id: bigint) {
calculateNameColorForContext(context: any) {
return this.calculateNameColorForUser(BigInt(context.message.author.id));
},
calculateNameColorForUser(id: bigint) {
// Compute a 64-bit FNV-1a hash of the passed data
function hash(data: ArrayBuffer) {
const fnvPrime = 1099511628211n;

0 comments on commit a4d91fb

Please sign in to comment.