本文整理汇总了Java中org.telegram.telegrambots.TelegramBotsApi类的典型用法代码示例。如果您正苦于以下问题:Java TelegramBotsApi类的具体用法?Java TelegramBotsApi怎么用?Java TelegramBotsApi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TelegramBotsApi类属于org.telegram.telegrambots包,在下文中一共展示了TelegramBotsApi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
public static void main(String args[]){
/*
* 創建一個新的telegramAPI 在內存裡面
*/
TelegramBotsApi tgBot = new TelegramBotsApi();
/*
* 初始化telegramAPI的所有函數
*/
ApiContextInitializer.init();
/*
*try{}catch(Exception e) 是一組條件 代表嘗試 如果有程序錯誤 執行catch 如沒有 catch則不會執行
*/
try {
/*
* 把創建出來的telegramAPI與機器人連接
*/
tgBot.registerBot(new TelegramBot());
} catch (TelegramApiException e) {
System.out.println("error");
}
}
示例2: init
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
@PostConstruct
public void init() throws TelegramApiRequestException {
if (properties.getTelegram().getEnabled()) {
LOGGER.info("Initializing Telegram service...");
ApiContextInitializer.init();
TelegramBotsApi botsApi = new TelegramBotsApi();
bot = new FreqTradeTelegramBot(context);
botsApi.registerBot(bot);
} else {
LOGGER.info("Telegram service is disabled");
}
}
示例3: main
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
public static void main(String[] args) {
System.out.println("started");
// Initialize Api Context
ApiContextInitializer.init();
// Instantiate Telegram Bots API
TelegramBotsApi botsApi = new TelegramBotsApi();
// Register our bot
try {
botsApi.registerBot(new SchoolAssistantBot());
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
示例4: main
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
/**
* Fa partire il client.<BR>
* Uso: <code>java TestClient nick debugLevel</code><br>
*/
public static void main(String[] args) {
boolean ldeb;
if (args.length < 2)
misuse();
String nick = args[0];
int aDeb = Integer.parseInt(args[1]);
if (aDeb == 1)
ldeb = true;
else
ldeb = false;
// Initialize Api Context
ApiContextInitializer.init();
// Instantiate Telegram Bots API
TelegramBotsApi botsApi = new TelegramBotsApi();
// Register our bot
try {
botsApi.registerBot(new TelegramIlnBot(nick, ldeb, new LogServer("iln")));
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
示例5: main
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
public static void main(String[] args) throws TelegramApiException {
TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
try {
telegramBotsApi.registerBot(new TelegramLongPollingBot() {
@Override
public String getBotToken() {
return "232561070:AAFxh2DgKa3N21xluXZg565lMAnjh_MmdbQ";
}
@Override
public String getBotUsername() {
return "EsearchBot";
}
@Override
public void onUpdateReceived(Update update) {
logger.info(update.toString());
}
});
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
示例6: GopStop
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
private GopStop() {
LOGGER.info("START Стартуем! Сегодня мы с тобой стартуем.");
final TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
LOGGER.info("Init singletons");
SessionCache.getInstance();
LinesIndexer.getInstance();
WordStressMap.getInstance();
RhymeGraph.getInstance();
LOGGER.info("Singletons inited");
try {
telegramBotsApi.registerBot(new TGBot());
} catch (final TelegramApiException e) {
LOGGER.error("Error while registering bot: " + e.getMessage(), e);
}
}
示例7: createTelegramBotsApi
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
private static TelegramBotsApi createTelegramBotsApi() throws TelegramApiException {
TelegramBotsApi telegramBotsApi;
if (!BuildVars.useWebHook) {
// Default (long polling only)
telegramBotsApi = createLongPollingTelegramBotsApi();
} else if (!BuildVars.pathToCertificatePublicKey.isEmpty()) {
// Filled a path to a pem file ? looks like you're going for the self signed option then, invoke with store and pem file to supply.
telegramBotsApi = createSelfSignedTelegramBotsApi();
telegramBotsApi.registerBot(new WebHookExampleHandlers());
} else {
// Non self signed, make sure you've added private/public and if needed intermediate to your cert-store.
telegramBotsApi = createNoSelfSignedTelegramBotsApi();
telegramBotsApi.registerBot(new WebHookExampleHandlers());
}
return telegramBotsApi;
}
示例8: main
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
ApiContextInitializer.init();
TelegramBotsApi bot = new TelegramBotsApi();
try {
bot.registerBot(new QualisBot(args[0]));
} catch (TelegramApiRequestException e) {
e.printStackTrace();
}
}
示例9: main
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
public static void main(String[] args) {
ApiContextInitializer.init();
TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
try {
EntenBot entenBot = new EntenBot();
telegramBotsApi.registerBot(entenBot);
} catch (TelegramApiException e){
BotLogger.error("LOGTAG", e);
}
}
示例10: registerBots
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
private static void registerBots(){
TelegramBotsApi botsApi = new TelegramBotsApi();
try{
botsApi.registerBot(new Paulette());
System.out.println("Success! BotServer connected to Telegram Server");
} catch (TelegramApiException e) {
System.out.println("Unable to connect to Telegram Server. Please check BotToken and Internet Settings");
}
}
示例11: main
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
public static void main(String[] args) {
ClassifierBot classifierBot = new ClassifierBot();
TelegramBotsApi botsApi = new TelegramBotsApi();
try {
botsApi.registerBot(classifierBot);
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
示例12: main
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
public static void main(String[] args) {
ApiContextInitializer.init();
TelegramBotsApi botsApi = new TelegramBotsApi();
try {
botsApi.registerBot(new TelegramClient());
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
示例13: main
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
public static void main(String... args) {
ApiContextInitializer.init();
TelegramBotsApi api = new TelegramBotsApi();
try {
api.registerBot(new HelloBot());
} catch (TelegramApiRequestException e) {
BotLogger.error("Oops, something went wrong while registering bot", e);
}
}
示例14: main
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
public static void main(String[] args) {
ApiContextInitializer.init();
TelegramBotsApi botsApi = new TelegramBotsApi();
try {
botsApi.registerBot(new QuizBot(new QuizController()));
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
示例15: main
import org.telegram.telegrambots.TelegramBotsApi; //导入依赖的package包/类
public static void main(String[] args) {
// TODO Initialize Api Context
ApiContextInitializer.init();
// TODO Instantiate Telegram Bots API
TelegramBotsApi botsApi = new TelegramBotsApi();
// TODO Register our bot
try {
botsApi.registerBot(new GeoLearnBot());
} catch (TelegramApiException e) {
e.printStackTrace();
}
}