2020-02-04 21:31:55 +01:00
|
|
|
<template>
|
|
|
|
<span class="content">
|
|
|
|
<ParsedMessage :network="network" :message="message" :text="errorMessage" />
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
2022-06-19 02:25:21 +02:00
|
|
|
<script lang="ts">
|
2020-02-04 21:31:55 +01:00
|
|
|
import ParsedMessage from "../ParsedMessage.vue";
|
2022-06-19 02:25:21 +02:00
|
|
|
import {computed, defineComponent, PropType} from "vue";
|
|
|
|
import {ClientNetwork, ClientMessage} from "../../js/types";
|
2020-02-04 21:31:55 +01:00
|
|
|
|
2022-06-19 02:25:21 +02:00
|
|
|
export default defineComponent({
|
2020-02-04 21:31:55 +01:00
|
|
|
name: "MessageTypeError",
|
|
|
|
components: {
|
|
|
|
ParsedMessage,
|
|
|
|
},
|
|
|
|
props: {
|
2022-06-19 02:25:21 +02:00
|
|
|
network: {
|
|
|
|
type: Object as PropType<ClientNetwork>,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
message: {
|
|
|
|
type: Object as PropType<ClientMessage>,
|
|
|
|
required: true,
|
|
|
|
},
|
2020-02-04 21:31:55 +01:00
|
|
|
},
|
2022-06-19 02:25:21 +02:00
|
|
|
setup(props) {
|
|
|
|
const errorMessage = computed(() => {
|
2024-04-21 14:36:41 +02:00
|
|
|
// TODO: enforce chan and nick fields so that we can get rid of that
|
|
|
|
const chan = props.message.channel || "!UNKNOWN_CHAN";
|
|
|
|
const nick = props.message.nick || "!UNKNOWN_NICK";
|
|
|
|
|
2022-06-19 02:25:21 +02:00
|
|
|
switch (props.message.error) {
|
2020-02-04 21:31:55 +01:00
|
|
|
case "bad_channel_key":
|
2024-04-21 14:36:41 +02:00
|
|
|
return `Cannot join ${chan} - Bad channel key.`;
|
2020-02-04 21:31:55 +01:00
|
|
|
case "banned_from_channel":
|
2024-04-21 14:36:41 +02:00
|
|
|
return `Cannot join ${chan} - You have been banned from the channel.`;
|
2020-02-04 21:31:55 +01:00
|
|
|
case "cannot_send_to_channel":
|
2024-04-21 14:36:41 +02:00
|
|
|
return `Cannot send to channel ${chan}`;
|
2020-02-04 21:31:55 +01:00
|
|
|
case "channel_is_full":
|
2024-04-21 14:36:41 +02:00
|
|
|
return `Cannot join ${chan} - Channel is full.`;
|
2020-02-04 21:31:55 +01:00
|
|
|
case "chanop_privs_needed":
|
|
|
|
return "Cannot perform action: You're not a channel operator.";
|
|
|
|
case "invite_only_channel":
|
2024-04-21 14:36:41 +02:00
|
|
|
return `Cannot join ${chan} - Channel is invite only.`;
|
2020-02-04 21:31:55 +01:00
|
|
|
case "no_such_nick":
|
2024-04-21 14:36:41 +02:00
|
|
|
return `User ${nick} hasn't logged in or does not exist.`;
|
2020-02-04 21:31:55 +01:00
|
|
|
case "not_on_channel":
|
|
|
|
return "Cannot perform action: You're not on the channel.";
|
|
|
|
case "password_mismatch":
|
|
|
|
return "Password mismatch.";
|
|
|
|
case "too_many_channels":
|
2024-04-21 14:36:41 +02:00
|
|
|
return `Cannot join ${chan} - You've already reached the maximum number of channels allowed.`;
|
2020-02-04 21:31:55 +01:00
|
|
|
case "unknown_command":
|
2024-04-21 14:36:41 +02:00
|
|
|
// TODO: not having message.command should never happen, so force existence
|
|
|
|
return `Unknown command: ${props.message.command || "!UNDEFINED_COMMAND_BUG"}`;
|
2020-02-04 21:31:55 +01:00
|
|
|
case "user_not_in_channel":
|
2024-04-21 14:36:41 +02:00
|
|
|
return `User ${nick} is not on the channel.`;
|
2020-02-04 21:31:55 +01:00
|
|
|
case "user_on_channel":
|
2024-04-21 14:36:41 +02:00
|
|
|
return `User ${nick} is already on the channel.`;
|
2020-02-04 21:31:55 +01:00
|
|
|
default:
|
2022-06-19 02:25:21 +02:00
|
|
|
if (props.message.reason) {
|
2024-04-21 14:36:41 +02:00
|
|
|
return `${props.message.reason} (${
|
|
|
|
props.message.error || "!UNDEFINED_ERR"
|
|
|
|
})`;
|
2020-02-04 21:31:55 +01:00
|
|
|
}
|
|
|
|
|
2022-06-19 02:25:21 +02:00
|
|
|
return props.message.error;
|
2020-02-04 21:31:55 +01:00
|
|
|
}
|
2022-06-19 02:25:21 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
errorMessage,
|
|
|
|
};
|
2020-02-04 21:31:55 +01:00
|
|
|
},
|
2022-06-19 02:25:21 +02:00
|
|
|
});
|
2020-02-04 21:31:55 +01:00
|
|
|
</script>
|