functional ttv-obfuscated-names
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { NameConfigInstance, ignoreMod } from './options'
|
||||
import { getRandomName, getStoredUser, setStoredUser } from './storage'
|
||||
import { ChatMessage } from './util'
|
||||
|
||||
export function obfuscator(
|
||||
chatMessage: ChatMessage
|
||||
): NameConfigInstance | null {
|
||||
if (ignoreMod && chatMessage.isMod) {
|
||||
return null
|
||||
}
|
||||
|
||||
chatMessage.username = chatMessage.username.toLowerCase()
|
||||
|
||||
// return stored data
|
||||
const userData = getStoredUser(chatMessage.username)
|
||||
if (userData !== null) {
|
||||
return userData
|
||||
}
|
||||
|
||||
// store new data
|
||||
const newName = getRandomName()
|
||||
setStoredUser(chatMessage.username, newName)
|
||||
|
||||
return newName
|
||||
}
|
||||
Reference in New Issue
Block a user