Compare commits

..

No commits in common. "2f1bf8a2fe87660a37cf92a179f590c8493ee983" and "8ff1cd83179b8c00cd892581322e92d9d5a8b70d" have entirely different histories.

6 changed files with 46 additions and 86 deletions

View file

@ -53,7 +53,6 @@ function markServerBufferUnread(app) {
}
const join = {
name: "join",
usage: "<name> [password]",
description: "Join a channel",
execute: (app, args) => {
@ -70,7 +69,6 @@ const join = {
};
const kick = {
name: "kick",
usage: "<nick> [comment]",
description: "Remove a user from the channel",
execute: (app, args) => {
@ -85,7 +83,6 @@ const kick = {
};
const ban = {
name: "ban",
usage: "[nick]",
description: "Ban a user from the channel, or display the current ban list",
execute: (app, args) => {
@ -114,9 +111,8 @@ function givemode(app, args, mode) {
});
}
const commands = [
{
name: "away",
export default {
"away": {
usage: "[message]",
description: "Set away message",
execute: (app, args) => {
@ -127,9 +123,8 @@ const commands = [
getActiveClient(app).send({command: "AWAY", params});
},
},
ban,
{
name: "buffer",
"ban": ban,
"buffer": {
usage: "<name>",
description: "Switch to a buffer",
execute: (app, args) => {
@ -143,8 +138,7 @@ const commands = [
throw new Error("Unknown buffer");
},
},
{
name: "close",
"close": {
description: "Close the current buffer",
execute: (app, args) => {
let activeBuffer = app.state.buffers.get(app.state.activeBuffer);
@ -154,34 +148,29 @@ const commands = [
app.close(activeBuffer.id);
},
},
{
name: "deop",
"deop": {
usage: "<nick>",
description: "Remove operator status for a user on this channel",
execute: (app, args) => givemode(app, args, "-o"),
},
{
name: "devoice",
"devoice": {
usage: "<nick>",
description: "Remove voiced status for a user on this channel",
execute: (app, args) => givemode(app, args, "-v"),
},
{
name: "disconnect",
"disconnect": {
description: "Disconnect from the server",
execute: (app, args) => {
app.disconnect();
},
},
{
name: "help",
"help": {
description: "Show help menu",
execute: (app, args) => {
app.openHelp();
},
},
{
name: "invite",
"invite": {
usage: "<nick>",
description: "Invite a user to the channel",
execute: (app, args) => {
@ -195,11 +184,10 @@ const commands = [
]});
},
},
{ ...join, name: "j" },
join,
kick,
{
name: "kickban",
"j": join,
"join": join,
"kick": kick,
"kickban": {
usage: "<target>",
description: "Ban a user and removes them from the channel",
execute: (app, args) => {
@ -207,8 +195,7 @@ const commands = [
ban.execute(app, args);
},
},
{
name: "lusers",
"lusers": {
usage: "[<mask> [<target>]]",
description: "Request user statistics about the network",
execute: (app, args) => {
@ -216,8 +203,7 @@ const commands = [
markServerBufferUnread(app);
},
},
{
name: "me",
"me": {
usage: "<action>",
description: "Send an action message to the current buffer",
execute: (app, args) => {
@ -227,8 +213,7 @@ const commands = [
app.privmsg(target, text);
},
},
{
name: "mode",
"mode": {
usage: "[target] [modes] [mode args...]",
description: "Query or change a channel or user mode",
execute: (app, args) => {
@ -240,8 +225,7 @@ const commands = [
getActiveClient(app).send({ command: "MODE", params: args });
},
},
{
name: "motd",
"motd": {
usage: "[server]",
description: "Get the Message Of The Day",
execute: (app, args) => {
@ -249,8 +233,7 @@ const commands = [
markServerBufferUnread(app);
},
},
{
name: "msg",
"msg": {
usage: "<target> <message>",
description: "Send a message to a nickname or a channel",
execute: (app, args) => {
@ -259,8 +242,7 @@ const commands = [
getActiveClient(app).send({ command: "PRIVMSG", params: [target, text] });
},
},
{
name: "nick",
"nick": {
usage: "<nick>",
description: "Change current nickname",
execute: (app, args) => {
@ -268,8 +250,7 @@ const commands = [
getActiveClient(app).send({ command: "NICK", params: [newNick] });
},
},
{
name: "notice",
"notice": {
usage: "<target> <message>",
description: "Send a notice to a nickname or a channel",
execute: (app, args) => {
@ -278,14 +259,12 @@ const commands = [
getActiveClient(app).send({ command: "NOTICE", params: [target, text] });
},
},
{
name: "op",
"op": {
usage: "<nick>",
description: "Give a user operator status on this channel",
execute: (app, args) => givemode(app, args, "+o"),
},
{
name: "part",
"part": {
usage: "[reason]",
description: "Leave a channel",
execute: (app, args) => {
@ -298,8 +277,7 @@ const commands = [
getActiveClient(app).send({ command: "PART", params });
},
},
{
name: "query",
"query": {
usage: "<nick> [message]",
description: "Open a buffer to send messages to a nickname",
execute: (app, args) => {
@ -315,8 +293,7 @@ const commands = [
}
},
},
{
name: "quiet",
"quiet": {
usage: "[nick]",
description: "Quiet a user in the channel, or display the current quiet list",
execute: (app, args) => {
@ -330,15 +307,13 @@ const commands = [
}
},
},
{
name: "quit",
"quit": {
description: "Quit",
execute: (app, args) => {
app.close({ name: SERVER_BUFFER });
},
},
{
name: "quote",
"quote": {
usage: "<command>",
description: "Send a raw IRC command to the server",
execute: (app, args) => {
@ -351,15 +326,13 @@ const commands = [
getActiveClient(app).send(msg);
},
},
{
name: "reconnect",
"reconnect": {
description: "Reconnect to the server",
execute: (app, args) => {
app.reconnect();
},
},
{
name: "setname",
"setname": {
usage: "<realname>",
description: "Change current realname",
execute: (app, args) => {
@ -372,8 +345,7 @@ const commands = [
// TODO: save to local storage
},
},
{
name: "stats",
"stats": {
usage: "<query> [server]",
description: "Request server statistics",
execute: (app, args) => {
@ -389,8 +361,7 @@ const commands = [
markServerBufferUnread(app);
},
},
{
name: "topic",
"topic": {
usage: "<topic>",
description: "Change the topic of the current channel",
execute: (app, args) => {
@ -402,30 +373,26 @@ const commands = [
getActiveClient(app).send({ command: "TOPIC", params });
},
},
{
name: "unban",
"unban": {
usage: "<nick>",
description: "Remove a user from the ban list",
execute: (app, args) => {
return setUserHostMode(app, args, "-b");
},
},
{
name: "unquiet",
"unquiet": {
usage: "<nick>",
description: "Remove a user from the quiet list",
execute: (app, args) => {
return setUserHostMode(app, args, "-q");
},
},
{
name: "voice",
"voice": {
usage: "<nick>",
description: "Give a user voiced status on this channel",
execute: (app, args) => givemode(app, args, "+v"),
},
{
name: "who",
"who": {
usage: "<mask>",
description: "Retrieve a list of users",
execute: (app, args) => {
@ -433,8 +400,7 @@ const commands = [
markServerBufferUnread(app);
},
},
{
name: "whois",
"whois": {
usage: "<nick>",
description: "Retrieve information about a user",
execute: (app, args) => {
@ -446,8 +412,7 @@ const commands = [
markServerBufferUnread(app);
},
},
{
name: "whowas",
"whowas": {
usage: "<nick> [count]",
description: "Retrieve information about an offline user",
execute: (app, args) => {
@ -458,8 +423,7 @@ const commands = [
markServerBufferUnread(app);
},
},
{
name: "list",
"list": {
usage: "[filter]",
description: "Retrieve a list of channels from a network",
execute: (app, args) => {
@ -467,6 +431,4 @@ const commands = [
markServerBufferUnread(app);
},
},
];
export default new Map(commands.map((cmd) => [cmd.name, cmd]));
};

View file

@ -515,7 +515,7 @@ export default class App extends Component {
this.setState((state) => {
let updated;
[id, updated] = State.createBuffer(state, name, serverID, client);
isNew = Boolean(updated);
isNew = !!updated;
return updated;
});
if (isNew) {
@ -1583,7 +1583,7 @@ export default class App extends Component {
let name = parts[0].toLowerCase().slice(1);
let args = parts.slice(1);
let cmd = commands.get(name);
let cmd = commands[name];
if (!cmd) {
this.showError(`Unknown command "${name}" (run "/help" to get a command list)`);
return;
@ -1715,7 +1715,7 @@ export default class App extends Component {
}
if (prefix.startsWith("/")) {
let repl = fromList([...commands.keys()], prefix.slice(1));
let repl = fromList(Object.keys(commands), prefix.slice(1));
return repl.map((cmd) => "/" + cmd);
}

View file

@ -26,8 +26,6 @@ export default [
"eqeqeq": "error",
"no-invalid-this": "error",
"prefer-arrow-callback": "error",
"no-implicit-coercion": "warn",
"object-shorthand": "warn",
"@stylistic/js/indent": ["warn", "tab"],
"@stylistic/js/quotes": ["warn", "double"],
"@stylistic/js/semi": "warn",

View file

@ -121,7 +121,7 @@ export function setup(app) {
return;
}
candidates = candidates.filter((binding) => {
return Boolean(binding.altKey) === event.altKey && Boolean(binding.ctrlKey) === event.ctrlKey;
return !!binding.altKey === event.altKey && !!binding.ctrlKey === event.ctrlKey;
});
if (candidates.length !== 1) {
return;

View file

@ -853,7 +853,7 @@ export default class Client extends EventTarget {
}
let msg = {
command: "JOIN",
params,
params: params,
};
return this.roundtrip(msg, (msg) => {
switch (msg.command) {
@ -940,7 +940,7 @@ export default class Client extends EventTarget {
}
if (messages.length >= max) {
// There are still more messages to fetch
after = { ...after, time: messages[messages.length - 1].tags.time };
after.time = messages[messages.length - 1].tags.time;
return await this.fetchHistoryBetween(target, after, before, limit);
}
return { messages };

View file

@ -634,7 +634,7 @@ export const State = {
return updateUser(msg.prefix.name, { account });
case "AWAY":
let awayMessage = msg.params[0];
return updateUser(msg.prefix.name, { away: Boolean(awayMessage) });
return updateUser(msg.prefix.name, { away: !!awayMessage });
case "TOPIC":
channel = msg.params[0];
topic = msg.params[1];