thelounge/server/plugins/inputs/topic.ts
Reto Brunner 3d8e96491b topic: display topic when no arguments are given
That's what the help says that we do, so do it.

Fixes: https://github.com/thelounge/thelounge/issues/5026
2026-02-09 08:08:15 +01:00

37 lines
814 B
TypeScript

import {PluginInputHandler} from "./index";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
import {ChanType} from "../../../shared/types/chan";
const commands = ["topic"];
const input: PluginInputHandler = function ({irc}, chan, cmd, args) {
if (chan.type !== ChanType.CHANNEL) {
chan.pushMessage(
this,
new Msg({
type: MessageType.ERROR,
text: `${cmd} command can only be used in channels.`,
})
);
return;
}
const cleanArgs = args.map((s) => s.trim()).filter((s) => s !== "");
if (cleanArgs.length === 0) {
irc.raw("TOPIC", chan.name);
return;
}
// we use the non trimmed args here, the user may have added white space on purpose
irc.setTopic(chan.name, args.join(" "));
return true;
};
export default {
commands,
input,
};