1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00

Added event channel

This commit is contained in:
marzavec 2020-10-10 00:34:59 -05:00
parent 6a1a9df096
commit 866fa9bcff
27 changed files with 90 additions and 1 deletions

View File

@ -368,6 +368,11 @@ var COMMANDS = {
info: function (args) {
args.nick = '*';
pushMessage(args);
},
emote: function (args) {
args.nick = '*';
pushMessage(args);
},
warn: function (args) {

View File

@ -28,6 +28,7 @@ export async function run({
server.send({
cmd: 'info',
text: 'You are now a mod.',
channel: newMod[i].channel, // @todo Multichannel
}, newMod[i]);
}
}
@ -36,12 +37,14 @@ export async function run({
server.reply({
cmd: 'info',
text: `Added mod trip: ${payload.trip}, remember to run 'saveconfig' to make it permanent`,
channel: socket.channel, // @todo Multichannel
}, socket);
// notify all mods
server.broadcast({
cmd: 'info',
text: `Added mod: ${payload.trip}`,
channel: false, // @todo Multichannel, false for global info
}, { level: UAC.isModerator });
return true;

View File

@ -42,6 +42,7 @@ export async function run({ server, socket }) {
server.reply({
cmd: 'info',
text: lines.join('\n'),
channel: socket.channel, // @todo Multichannel
}, socket);
return true;

View File

@ -36,6 +36,7 @@ export async function run({
server.broadcast({
cmd: 'info',
text: loadResult,
channel: false, // @todo Multichannel, false for global
}, { level: UAC.isModerator });
return true;

View File

@ -29,6 +29,7 @@ export async function run({
server.send({
cmd: 'info',
text: 'You are now a user.',
channel: targetMod[i].channel, // @todo Multichannel
}, targetMod[i]);
}
}
@ -39,12 +40,14 @@ export async function run({
text: `Removed mod trip: ${
payload.trip
}, remember to run 'saveconfig' to make it permanent`,
channel: socket.channel, // @todo Multichannel
}, socket);
// notify all mods
server.broadcast({
cmd: 'info',
text: `Removed mod: ${payload.trip}`,
channel: false, // @todo Multichannel, false for global
}, { level: UAC.isModerator });
return true;

View File

@ -16,6 +16,7 @@ export async function run({ core, server, socket }) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Failed to save config, check logs.',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -23,6 +24,7 @@ export async function run({ core, server, socket }) {
server.broadcast({
cmd: 'info',
text: 'Config saved!',
channel: false, // @todo Multichannel
}, { level: UAC.isModerator });
return true;

View File

@ -15,6 +15,7 @@ export async function run({ server, socket, payload }) {
server.broadcast({
cmd: 'info',
text: `Server Notice: ${payload.text}`,
channel: false, // @todo Multichannel, false for global
}, {});
return true;

View File

@ -14,6 +14,7 @@ export async function run({
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are changing nicknames too fast. Wait a moment before trying again.',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -30,6 +31,7 @@ export async function run({
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Nickname must consist of up to 24 letters, numbers, and underscores',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -41,6 +43,7 @@ export async function run({
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are not the admin, liar!',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -48,6 +51,7 @@ export async function run({
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You already have that name',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -65,6 +69,7 @@ export async function run({
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Nickname taken',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -74,6 +79,7 @@ export async function run({
const leaveNotice = {
cmd: 'onlineRemove',
nick: socket.nick,
channel: socket.channel, // @todo Multichannel
};
const joinNotice = {
@ -81,6 +87,7 @@ export async function run({
nick: newNick,
trip: socket.trip || 'null',
hash: socket.hash,
channel: socket.channel, // @todo Multichannel
};
// broadcast remove event and join event with new name, this is to support legacy clients and bots
@ -91,6 +98,7 @@ export async function run({
server.broadcast({
cmd: 'info',
text: `${socket.nick} is now ${newNick}`,
channel: socket.channel, // @todo Multichannel
}, { channel: socket.channel });
// commit change to nickname
@ -120,6 +128,7 @@ export function nickCheck({
server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Refer to `/help nick` for instructions on how to use this command.',
channel: socket.channel, // @todo Multichannel
}, socket);
return false;

View File

@ -39,6 +39,7 @@ export async function run({
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -88,6 +89,7 @@ export function commandCheckIn({ server, socket, payload }) {
server.reply({
cmd: 'info',
text: `Your hash: ${socket.hash}`,
channel: socket.channel, // @todo Multichannel
}, socket);
return false;
@ -114,6 +116,7 @@ export function finalCmdCheck({ server, socket, payload }) {
server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: `Unknown command: ${payload.text}`,
channel: socket.channel, // @todo Multichannel
}, socket);
return false;

View File

@ -35,6 +35,7 @@ export async function run({ server, socket, payload }) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -47,6 +48,7 @@ export async function run({ server, socket, payload }) {
nick: socket.nick,
userid: socket.userid,
text: `@${socket.nick}${text}`,
channel: socket.channel, // @todo Multichannel
};
if (socket.trip) {
@ -80,6 +82,7 @@ export function emoteCheck({
server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Refer to `/help emote` for instructions on how to use this command.',
channel: socket.channel, // @todo Multichannel
}, socket);
return false;

View File

@ -11,6 +11,7 @@ export async function run({
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -54,6 +55,7 @@ export async function run({
server.reply({
cmd: 'info',
text: reply,
channel: socket.channel, // @todo Multichannel
}, socket);
return true;

View File

@ -36,6 +36,7 @@ export async function run({
cmd: 'warn',
text: 'You are sending invites too fast. Wait a moment before trying again.',
id: Errors.Invite.RATELIMIT,
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -59,6 +60,7 @@ export async function run({
cmd: 'warn',
text: 'Could not find user in that channel',
id: Errors.Global.UNKNOWN_USER,
channel: socket.channel, // @todo Multichannel
}, socket);
}

View File

@ -29,6 +29,7 @@ export async function run({
cmd: 'warn',
text: 'You are joining channels too fast. Wait a moment and try again.',
id: Errors.Join.RATELIMIT,
channel: false, // @todo Multichannel, false for global event
}, socket);
}
@ -47,6 +48,7 @@ export async function run({
cmd: 'warn',
text: 'You may not join that channel.',
id: mayJoin,
channel: false, // @todo Multichannel, false for global event
}, socket);
}
@ -57,6 +59,7 @@ export async function run({
cmd: 'warn', // @todo Remove this
text: 'Joining more than one channel is not currently supported',
id: Errors.Join.ALREADY_JOINED,
channel: false, // @todo Multichannel, false for global event
}, socket);
}
// end todo
@ -68,6 +71,7 @@ export async function run({
cmd: 'warn',
text: 'Nickname must consist of up to 24 letters, numbers, and underscores',
id: Errors.Join.INVALID_NICK,
channel: false, // @todo Multichannel, false for global event
}, socket);
}
@ -103,6 +107,7 @@ export async function run({
cmd: 'warn',
text: 'Nickname taken',
id: Errors.Join.NAME_TAKEN,
channel: false, // @todo Multichannel, false for global event
}, socket);
}
@ -146,6 +151,7 @@ export async function run({
cmd: 'onlineSet',
nicks, /* @legacy */
users,
channel, // @todo Multichannel (?)
}, socket);
// stats are fun

View File

@ -51,6 +51,7 @@ export async function run({ core, server, socket }) {
users-kicked: ${(core.stats.get('users-kicked') || 0)}
stats-requested: ${(core.stats.get('stats-requested') || 0)}
server-uptime: ${formatTime(process.hrtime(core.stats.get('start-time')))}`,
channel: socket.channel, // @todo Multichannel
}, socket);
// stats are fun

View File

@ -10,6 +10,7 @@ export async function run({ server, socket, payload }) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are changing channels too fast. Wait a moment before trying again.',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -22,6 +23,7 @@ export async function run({ server, socket, payload }) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Cannot move to an empty channel.',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -50,12 +52,14 @@ export async function run({ server, socket, payload }) {
server.reply({
cmd: 'onlineRemove',
nick: peerList[i].nick,
channel: socket.channel, // @todo Multichannel
}, socket);
if (socket.nick !== peerList[i].nick) {
server.reply({
cmd: 'onlineRemove',
nick: socket.nick,
channel: socket.channel, // @todo Multichannel
}, peerList[i]);
}
}
@ -83,6 +87,7 @@ export async function run({ server, socket, payload }) {
server.reply({
cmd: 'onlineSet',
nicks,
channel: socket.channel, // @todo Multichannel (!)
}, socket);
// commit change
@ -111,6 +116,7 @@ export function moveCheck({
server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Refer to `/help move` for instructions on how to use this command.',
channel: socket.channel, // @todo Multichannel
}, socket);
return false;

View File

@ -25,6 +25,7 @@ export async function run({ core, server, socket }) {
server.reply({
cmd: 'info',
text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels`,
channel: socket.channel, // @todo Multichannel
}, socket);
// stats are fun

View File

@ -40,6 +40,7 @@ export async function run({ server, socket, payload }) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -55,6 +56,7 @@ export async function run({ server, socket, payload }) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Could not find user in channel',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -66,6 +68,7 @@ export async function run({ server, socket, payload }) {
from: socket.nick,
trip: socket.trip || 'null',
text: `${socket.nick} whispered: ${text}`,
channel: socket.channel, // @todo Multichannel
}, targetClient);
targetClient.whisperReply = socket.nick;
@ -74,6 +77,7 @@ export async function run({ server, socket, payload }) {
cmd: 'info',
type: 'whisper',
text: `You whispered to @${targetNick}: ${text}`,
channel: socket.channel, // @todo Multichannel
}, socket);
return true;
@ -100,6 +104,7 @@ export function whisperCheck({
server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Refer to `/help whisper` for instructions on how to use this command.',
channel: socket.channel, // @todo Multichannel
}, socket);
return false;
@ -128,6 +133,7 @@ export function whisperCheck({
server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Cannot reply to nobody',
channel: socket.channel, // @todo Multichannel
}, socket);
return false;

View File

@ -16,6 +16,7 @@ export async function run({ server, socket, payload }) {
cmd: 'onlineRemove',
userid: socket.userid,
nick: socket.nick, /* @legacy */
channel: socket.channel, // @todo Multichannel
}, { channel: socket.channel });
}

View File

@ -13,6 +13,7 @@ export async function run({ server, socket, payload }) {
server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: payload.text,
channel: socket.channel || false, // @todo Multichannel
}, socket);
return true;

View File

@ -38,6 +38,7 @@ export async function run({
cmd: 'warn',
text: 'Could not find user in that channel',
id: Errors.Global.UNKNOWN_USER,
channel: socket.channel, // @todo Multichannel
}, socket);
}
const targetNick = targetUser.nick;
@ -48,6 +49,7 @@ export async function run({
cmd: 'warn',
text: 'Cannot ban other users of the same level, how rude',
id: Errors.Global.PERMISSION,
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -61,13 +63,15 @@ export async function run({
cmd: 'info',
text: `Banned ${targetNick}`,
user: UAC.getUserDetails(targetUser),
channel: socket.channel, // @todo Multichannel
}, { channel: socket.channel, level: (level) => level < UAC.levels.moderator });
// notify mods
server.broadcast({
cmd: 'info',
text: `${socket.nick}#${socket.trip} banned ${targetNick} in ${payload.channel}, userhash: ${targetUser.hash}`,
channel: payload.channel,
channel: socket.channel, // @todo Multichannel
inChannel: payload.channel,
user: UAC.getUserDetails(targetUser),
banner: UAC.getUserDetails(socket),
}, { level: UAC.isModerator });

View File

@ -48,6 +48,7 @@ export async function run({
cmd: 'warn',
text: 'Could not find user in that channel',
id: Errors.Global.UNKNOWN_USER,
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -57,6 +58,7 @@ export async function run({
cmd: 'warn',
text: 'This trick wont work on users of the same level',
id: Errors.Global.PERMISSION,
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -74,6 +76,7 @@ export async function run({
server.broadcast({
cmd: 'info',
text: `${socket.nick}#${socket.trip} muzzled ${targetUser.nick} in ${payload.channel}, userhash: ${targetUser.hash}`,
channel: false, // @todo Multichannel, false for global
}, { level: UAC.isModerator });
return true;
@ -100,6 +103,7 @@ export function chatCheck({
cmd: 'chat',
nick: socket.nick,
text: payload.text,
channel: socket.channel, // @todo Multichannel
};
if (socket.trip) {
@ -142,6 +146,7 @@ export function inviteCheck({ core, socket, payload }) {
server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: nickValid,
channel: socket.channel, // @todo Multichannel
}, socket);
return false;
}
@ -177,6 +182,7 @@ export function whisperCheck({
cmd: 'info',
type: 'whisper',
text: `You whispered to @${targetNick}: ${payload.text}`,
channel: socket.channel, // @todo Multichannel
}, socket);
// blanket "spam" protection, may expose the ratelimiting lines from

View File

@ -44,6 +44,7 @@ export async function run({
cmd: 'warn',
text: 'Could not find user(s) in that channel',
id: Errors.Global.UNKNOWN_USER,
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -55,6 +56,7 @@ export async function run({
cmd: 'warn',
text: 'Cannot kick other users with the same level, how rude',
id: Errors.Global.PERMISSION,
channel: socket.channel, // @todo Multichannel
}, socket);
} else {
kicked.push(badClients[i]);
@ -95,6 +97,7 @@ export async function run({
server.broadcast({
cmd: 'info',
text: `${kicked[i].nick} was banished to ?${destChannel}`,
channel: socket.channel, // @todo Multichannel
}, { channel: socket.channel, level: UAC.isModerator });
console.log(`${socket.nick} [${socket.trip}] kicked ${kicked[i].nick} in ${socket.channel} to ${destChannel} `);
@ -106,6 +109,7 @@ export async function run({
cmd: 'onlineRemove',
userid: kicked[i].userid,
nick: kicked[i].nick,
channel: socket.channel, // @todo Multichannel
}, { channel: socket.channel });
}
@ -113,6 +117,7 @@ export async function run({
server.broadcast({
cmd: 'info',
text: `Kicked ${kicked.map((k) => k.nick).join(', ')}`,
channel: socket.channel, // @todo Multichannel
}, { channel: socket.channel, level: (level) => level < UAC.levels.moderator });
// stats are fun

View File

@ -28,6 +28,7 @@ export async function run({ server, socket, payload }) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Could not find user in channel',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -37,6 +38,7 @@ export async function run({ server, socket, payload }) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'Cannot move other users of the same level, how rude',
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -58,12 +60,14 @@ export async function run({ server, socket, payload }) {
server.reply({
cmd: 'onlineRemove',
nick: peerList[i].nick,
channel: socket.channel, // @todo Multichannel
}, badClient);
if (badClient.nick !== peerList[i].nick) {
server.reply({
cmd: 'onlineRemove',
nick: badClient.nick,
channel: socket.channel, // @todo Multichannel
}, peerList[i]);
}
}
@ -89,6 +93,7 @@ export async function run({ server, socket, payload }) {
server.reply({
cmd: 'onlineSet',
nicks,
channel: socket.channel, // @todo Multichannel (!)
}, badClient);
badClient.channel = payload.channel;
@ -96,6 +101,7 @@ export async function run({ server, socket, payload }) {
server.broadcast({
cmd: 'info',
text: `${badClient.nick} was moved into ?${payload.channel}`,
channel: socket.channel, // @todo Multichannel
}, { channel: payload.channel });
return true;

View File

@ -28,6 +28,7 @@ export async function run({
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: "hash:'targethash' or ip:'1.2.3.4' is required",
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -38,6 +39,7 @@ export async function run({
return server.broadcast({
cmd: 'info',
text: `${socket.nick} unmuzzled all users`,
channel: false, // @todo Multichannel, false for global
}, { level: UAC.isModerator });
}
} else if (payload.hash === '*') {
@ -46,6 +48,7 @@ export async function run({
return server.broadcast({
cmd: 'info',
text: `${socket.nick} unmuzzled all users`,
channel: false, // @todo Multichannel, false for global
}, { level: UAC.isModerator });
}
@ -63,6 +66,7 @@ export async function run({
server.broadcast({
cmd: 'info',
text: `${socket.nick}#${socket.trip} unmuzzled : ${target}`,
channel: false, // @todo Multichannel, false for global
}, { level: UAC.isModerator });
return true;

View File

@ -20,6 +20,7 @@ export async function run({
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: "hash:'targethash' or ip:'1.2.3.4' is required",
channel: socket.channel, // @todo Multichannel
}, socket);
}
@ -47,12 +48,14 @@ export async function run({
server.reply({
cmd: 'info',
text: `Unbanned ${target}`,
channel: socket.channel, // @todo Multichannel
}, socket);
// notify mods
server.broadcast({
cmd: 'info',
text: `${socket.nick}#${socket.trip} unbanned: ${target}`,
channel: false, // @todo Multichannel, false for global
}, { level: UAC.isModerator });
// stats are fun

View File

@ -24,12 +24,14 @@ export async function run({ core, server, socket }) {
server.reply({
cmd: 'info',
text: 'Unbanned all ip addresses',
channel: socket.channel, // @todo Multichannel
}, socket);
// notify mods
server.broadcast({
cmd: 'info',
text: `${socket.nick}#${socket.trip} unbanned all ip addresses`,
channel: false, // @todo Multichannel, false for global
}, { level: UAC.isModerator });
return true;

View File

@ -67,6 +67,7 @@ export function legacyInviteOut(payload, nick) {
type: 'invite',
from: nick,
text: `${nick} invited you to ?${payload.inviteChannel}`,
channel: payload.channel, // @todo Multichannel
},
};
}
@ -85,6 +86,7 @@ export function legacyInviteReply(payload, nick) {
type: 'invite',
from: '',
text: `You invited ${nick} to ?${payload.inviteChannel}`,
channel: payload.channel, // @todo Multichannel
},
};
}