rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.78k stars 1.22k forks source link

ALL, ADMIN cannot be resolved to a variable [AbilityBot] #521

Open ganduras381 opened 6 years ago

ganduras381 commented 6 years ago

Code written in Eclipse:

import org.telegram.abilitybots.api.bot.AbilityBot;
import org.telegram.abilitybots.api.objects.Ability;
import org.telegram.abilitybots.api.objects.Ability.AbilityBuilder;
import org.telegram.telegrambots.bots.DefaultBotOptions;
import org.telegram.abilitybots.api.objects.Locality;
import org.telegram.abilitybots.api.objects.Privacy;

public class Bot extends AbilityBot {

protected Bot(String botToken, String botUsername) {
    super(botToken, botUsername);
}

public int creatorId() {
    return 555;
}

public Ability hello() {
    return Ability.builder()
            .name("test")
            .info("hello bot")
            .locality(ALL)  // ALL cannot be resolved to a variable
            .privacy(ADMIN)  // ADMIN cannot be resolved to a variable
            .action(ctx -> silent.send("hello!", ctx.chatId()))
            .build();
}
}

screenshot from 2018-09-09 23-59-34 Why?

addo47 commented 6 years ago

ALL and ADMIN are enum objects from Locality and Privacy. Import them!

mymike00 commented 5 years ago

something like

import static org.telegram.abilitybots.api.objects.Locality.*;
import static org.telegram.abilitybots.api.objects.Privacy.*;