Skip to content

Commit

Permalink
feat(core): added clarification to ban messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed May 2, 2023
1 parent ca4ca9f commit 81743a3
Show file tree
Hide file tree
Showing 32 changed files with 82 additions and 53 deletions.
23 changes: 20 additions & 3 deletions core/webroutes/player/checkJoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default async function PlayerCheckJoin(ctx: Context) {
try {
// If ban checking enabled
if (playerDatabase.config.onJoinCheckBan) {
const result = checkBan(validIdsArray, validHwidsArray);
const result = checkBan(validIdsArray, validIdsObject, validHwidsArray);
if (!result.allow) return sendTypedResp(result);
}

Expand Down Expand Up @@ -147,7 +147,11 @@ export default async function PlayerCheckJoin(ctx: Context) {
/**
* Checks if the player is banned
*/
function checkBan(validIdsArray: string[], validHwidsArray: string[]): AllowRespType | DenyRespType {
function checkBan(
validIdsArray: string[],
validIdsObject: PlayerIdsObjectType,
validHwidsArray: string[]
): AllowRespType | DenyRespType {
const playerDatabase = (globals.playerDatabase as PlayerDatabase);
const translator = (globals.translator as Translator);

Expand All @@ -164,6 +168,7 @@ function checkBan(validIdsArray: string[], validHwidsArray: string[]): AllowResp
if (activeBans.length) {
const ban = activeBans[0];

//Translation keys
const textKeys = {
title_permanent: translator.t('ban_messages.reject.title_permanent'),
title_temporary: translator.t('ban_messages.reject.title_temporary'),
Expand All @@ -173,9 +178,11 @@ function checkBan(validIdsArray: string[], validHwidsArray: string[]): AllowResp
label_reason: translator.t('ban_messages.reject.label_reason'),
label_id: translator.t('ban_messages.reject.label_id'),
note_multiple_bans: translator.t('ban_messages.reject.note_multiple_bans'),
note_diff_license: translator.t('ban_messages.reject.note_diff_license'),
};
const language = translator.t('$meta.humanizer_language');

//Ban data
let title;
let expLine = '';
if (ban.expiration) {
Expand All @@ -194,8 +201,18 @@ function checkBan(validIdsArray: string[], validHwidsArray: string[]): AllowResp
translator.canonical,
{ dateStyle: 'medium', timeStyle: 'medium' }
)
const note = (activeBans.length > 1) ? `<br>${textKeys.note_multiple_bans}` : '';

//Informational notes
let note = '';
if (activeBans.length > 1) {
note += `<br>${textKeys.note_multiple_bans}`;
}
const bannedLicense = ban.ids.find(id => id.startsWith('license:'));
if (bannedLicense && validIdsObject.license && bannedLicense.substring(8) !== validIdsObject.license) {
note += `<br>${textKeys.note_diff_license}`;
}

//Prepare rejection message
const reason = rejectMessageTemplate(
title,
`${expLine}
Expand Down
1 change: 1 addition & 0 deletions docs/dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
- [x] save player hwids + ban with hwid + check join using hwid as well
- [x] rename `action[].identifiers` to `action[].ids`
- [x] add settings page option to configure the required hwid matches
- [x] add ban message clarification if its from another license
- [ ] add an option to wipe all hwids from the database
- [ ] start tracking the ban search duration
- [ ] Update discord.js... AGAIN!
Expand Down
3 changes: 2 additions & 1 deletion locale/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Gebannt von",
"label_reason": "Grund",
"label_id": "Bann-ID",
"note_multiple_bans": "Es gibt mehr als einen aktiven Bann für diesen Identifier"
"note_multiple_bans": "Es gibt mehr als einen aktiven Bann für diesen Identifier",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Expulsado por",
"label_reason": "Razón de la expulsión",
"label_id": "Ban ID",
"note_multiple_bans": "Nota: tiene más de una prohibición activa en sus identificadores."
"note_multiple_bans": "Nota: tiene más de una prohibición activa en sus identificadores.",
"note_diff_license": "Nota: el baneo de arriba fue aplicado para otra <code>license</code>, lo que significa que alguno de tus IDs/HWIDs coinciden con los del baneo asociado."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Keelustaja",
"label_reason": "Keelustuse põhjus",
"label_id": "Keelustuse ID",
"note_multiple_bans": "Märkus. Teil on oma identifikaatoritele rohkem kui üks aktiivne keelustus."
"note_multiple_bans": "Märkus. Teil on oma identifikaatoritele rohkem kui üks aktiivne keelustus.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Porttikiellon antanut",
"label_reason": "Porttikiellon syy",
"label_id": "Porttikiellon ID",
"note_multiple_bans": "Huom: you have more than one active ban on your identifiers."
"note_multiple_bans": "Huom: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banni par",
"label_reason": "Raison du bannissement",
"label_id": "ID de sanction",
"note_multiple_bans": "Note : vous avez plus d'un bannissement sur votre identifiant."
"note_multiple_bans": "Note : vous avez plus d'un bannissement sur votre identifiant.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Kitiltó neve",
"label_reason": "Kitiltás indoka",
"label_id": "Ban ID",
"note_multiple_bans": "Figyelem: Több mint egy aktív kitiltásod van ezen a fiókon."
"note_multiple_bans": "Figyelem: Több mint egy aktív kitiltásod van ezen a fiókon.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Bannato da",
"label_reason": "Motivo Ban",
"label_id": "ID Ban",
"note_multiple_bans": "Nota: hai piu di un ban sui tuoi identificativi."
"note_multiple_bans": "Nota: hai piu di un ban sui tuoi identificativi.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/lt.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Tave užblokavo",
"label_reason": "Užblokavimo priežastis",
"label_id": "Užblokavimo ID",
"note_multiple_bans": "P.S. Tu turi daugiau nei vieną užblokavimą ant savo identifikatorių"
"note_multiple_bans": "P.S. Tu turi daugiau nei vieną užblokavimą ant savo identifikatorių",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/lv.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Gebanned Door",
"label_reason": "Ban Reden",
"label_id": "Ban ID",
"note_multiple_bans": "Opmerking: U hebt meer dan één actieve ban op uw Identifiers."
"note_multiple_bans": "Opmerking: U hebt meer dan één actieve ban op uw Identifiers.",
"note_diff_license": "Opmerking: de bovenstaande ban werd toegepast voor een andere <code>license</code>, wat betekent dat sommige van jouw IDs/HWIDs matchen met degene die zijn geassocieerd met die ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Zbanowany przez",
"label_reason": "Powód bana",
"label_id": "Identyfikator bana",
"note_multiple_bans": "Uwaga: masz więcej niż jedną aktywną blokadę na swoje identyfikatory."
"note_multiple_bans": "Uwaga: masz więcej niż jedną aktywną blokadę na swoje identyfikatory.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Autor",
"label_reason": "Motivo",
"label_id": "ID do ban",
"note_multiple_bans": "Nota: você tem mais de um ban ativo em seus ids."
"note_multiple_bans": "Nota: você tem mais de um ban ativo em seus ids.",
"note_diff_license": "Nota: o ban acima foi aplicado em outra <code>license</code>, o que significa que um de seus IDs/HWIDs condiz com algum deste ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Забанил",
"label_reason": "Причина бана",
"label_id": "Бан ID",
"note_multiple_bans": "Примечание: у вас более одного активного запрета на ваши идентификаторы."
"note_multiple_bans": "Примечание: у вас более одного активного запрета на ваши идентификаторы.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Bannlyst av ",
"label_reason": "Bannlysnings anledning",
"label_id": "Bannlysnings ID",
"note_multiple_bans": "OBS Du kan vara bannlyst på flera identifikationer."
"note_multiple_bans": "OBS Du kan vara bannlyst på flera identifikationer.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Banned by",
"label_reason": "Ban Reason",
"label_id": "Ban ID",
"note_multiple_bans": "Note: you have more than one active ban on your identifiers."
"note_multiple_bans": "Note: you have more than one active ban on your identifiers.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Yasaklayan",
"label_reason": "Yasaklanma Sebebi",
"label_id": "Ban ID",
"note_multiple_bans": "Not: Tanımlayıcılarınız üzerinde birden fazla aktif yasağınız var."
"note_multiple_bans": "Not: Tanımlayıcılarınız üzerinde birden fazla aktif yasağınız var.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "Cấm bởi",
"label_reason": "Lý do cấm",
"label_id": "ID cấm",
"note_multiple_bans": "Lưu ý: bạn có nhiều hơn một lệnh cấm hoạt động đối với tài khoản của mình."
"note_multiple_bans": "Lưu ý: bạn có nhiều hơn một lệnh cấm hoạt động đối với tài khoản của mình.",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
3 changes: 2 additions & 1 deletion locale/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"label_author": "操作人",
"label_reason": "封禁原因",
"label_id": "封禁ID",
"note_multiple_bans": "提示:您还有其他激活的封禁。"
"note_multiple_bans": "提示:您还有其他激活的封禁。",
"note_diff_license": "Note: the ban above was applied for another <code>license</code>, which means some of your IDs/HWIDs match the ones associated with that ban."
}
},
"whitelist_messages": {
Expand Down
Loading

0 comments on commit 81743a3

Please sign in to comment.