flash
cf71bab92d
This has been in the works for over a month and might break things because it's a very radical change. If it causes you to be unable to join chat, report it on the forum or try joining using the legacy chat on https://sockchat.flashii.net.
87 lines
2.1 KiB
JavaScript
87 lines
2.1 KiB
JavaScript
#include common.js
|
|
#include rng.js
|
|
#include utility.js
|
|
|
|
const Weeaboo = (function() {
|
|
let kaomoji = [];
|
|
const textSfx = [
|
|
'desu', 'desu wa', 'desu wa ne', 'desu yo',
|
|
'nya', 'nyo', 'nyu', 'nyoron', 'da ze', 'nanodesu',
|
|
'de gozaru', 'desu no',
|
|
];
|
|
const userSfx = new Map;
|
|
const pub = {};
|
|
|
|
pub.init = function() {
|
|
if(kaomoji.length > 0)
|
|
return;
|
|
|
|
$x.get(futami.get('kaomoji'))
|
|
.then(resp => kaomoji = resp.text().split("\n"));
|
|
};
|
|
|
|
pub.getRandomKaomoji = function(allowEmpty, message) {
|
|
if(kaomoji.length < 1)
|
|
return '';
|
|
|
|
if((typeof allowEmpty).toLowerCase() !== 'boolean')
|
|
allowEmpty = true;
|
|
|
|
const rng = new MamiRNG(message.getIdInt() || undefined);
|
|
|
|
if(allowEmpty && rng.next(0, 10000) <= 9000)
|
|
return '';
|
|
|
|
return kaomoji[rng.next() % kaomoji.length];
|
|
};
|
|
|
|
pub.getNameSuffix = function(user) {
|
|
if(typeof user !== 'object' || user === null)
|
|
return '';
|
|
|
|
if(user.perms.rank >= 10)
|
|
return '-sama';
|
|
if(user.perms.rank >= 5)
|
|
return '-sensei';
|
|
if(user.colour.toLowerCase() === '#f02d7d')
|
|
return '-san';
|
|
if(user.colour.toLowerCase() === '#0099ff')
|
|
return '-wan';
|
|
|
|
switch(parseInt(user.id) % 3) {
|
|
default:
|
|
return '-chan';
|
|
case 1:
|
|
return '-tan';
|
|
case 2:
|
|
return '-kun';
|
|
}
|
|
};
|
|
|
|
pub.getTextSuffix = function(user) {
|
|
if(typeof user !== 'object' || user === null)
|
|
return '';
|
|
|
|
const userId = user.id;
|
|
if(userId === '3' || userId === '242')
|
|
return ' de geso';
|
|
|
|
if(!userSfx.has(userId)) {
|
|
const rng = new MamiRNG(0x51DEB00B | parseInt(user.id));
|
|
let str = ' ';
|
|
|
|
str += textSfx[rng.next() % textSfx.length];
|
|
if(rng.next(0, 100) >= 50)
|
|
str += '~';
|
|
|
|
userSfx.set(userId, str);
|
|
|
|
return str;
|
|
}
|
|
|
|
return userSfx.get(userId);
|
|
};
|
|
|
|
return pub;
|
|
})();
|