mirror of
https://github.com/aNNiMON/ffmpegbot
synced 2024-09-19 22:54:20 +03:00
Add note if user is not allowed to use the bot
This commit is contained in:
parent
bc4e3af5bc
commit
3335720b61
@ -41,7 +41,7 @@ public class MainBotHandler extends BotHandler {
|
||||
commands.registerBundle(new InputParametersBundle(sessions));
|
||||
commands.registerBundle(new YtDlpCommandBundle(sessions));
|
||||
commands.registerBundle(new AdminCommandBundle(sessions));
|
||||
commands.register(new HelpCommand());
|
||||
commands.register(new HelpCommand(permissions));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.annimon.ffmpegbot.commands;
|
||||
|
||||
import com.annimon.ffmpegbot.Permissions;
|
||||
import com.annimon.tgbotsmodule.commands.TextCommand;
|
||||
import com.annimon.tgbotsmodule.commands.authority.For;
|
||||
import com.annimon.tgbotsmodule.commands.context.MessageContext;
|
||||
@ -9,6 +10,11 @@ import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class HelpCommand implements TextCommand {
|
||||
private final Permissions permissions;
|
||||
|
||||
public HelpCommand(Permissions permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String command() {
|
||||
@ -28,8 +34,17 @@ public class HelpCommand implements TextCommand {
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull MessageContext ctx) {
|
||||
boolean hasRights = permissions.hasRights(ctx.sender, ctx.update(), ctx.user(), EnumSet.of(For.USER));
|
||||
String rightsText = "";
|
||||
if (!hasRights) {
|
||||
rightsText = """
|
||||
<i>Note: You are not in the list of allowed users.
|
||||
This bot is for personal use only, consider setting up your own instance:</i>
|
||||
https://github.com/aNNiMON/ffmpegbot
|
||||
""".stripIndent() + "\n\n";
|
||||
}
|
||||
ctx.replyToMessage("""
|
||||
<b>Media processing</b>
|
||||
%s<b>Media processing</b>
|
||||
Send any media to start processing.
|
||||
|
||||
<b>Input parameters</b> (in reply to media processing message)
|
||||
@ -41,6 +56,6 @@ public class HelpCommand implements TextCommand {
|
||||
/dl link [format] — download a media using yt-dlp
|
||||
<code>link</code> — a link to download (it must be supported by yt-dlp)
|
||||
<code>format</code> — (optional) a download format. Can be "best", "audio", "240", "360", "480", "720" or "1080"
|
||||
""".stripIndent()).enableHtml().callAsync(ctx.sender);
|
||||
""".stripIndent().formatted(rightsText)).enableHtml().disableWebPagePreview().callAsync(ctx.sender);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user