当前位置: 首页>>代码示例>>Java>>正文


Java TelegramBotsApi类代码示例

本文整理汇总了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");
      }
}
 
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:22,代码来源:Example.java

示例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");
    }
}
 
开发者ID:jeperon,项目名称:freqtrade-java,代码行数:17,代码来源:TelegramServiceImpl.java

示例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();
        }
        
	}
 
开发者ID:calmyourtities,项目名称:school-assistant,代码行数:19,代码来源:Main.java

示例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();
	}
}
 
开发者ID:alex321v,项目名称:iln,代码行数:29,代码来源:TelegramClient.java

示例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);
        }
    }
 
开发者ID:marozau,项目名称:expresso,代码行数:25,代码来源:BotApplication.java

示例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);
        }
    }
 
开发者ID:SammyVimes,项目名称:gopstopbot,代码行数:22,代码来源:GopStop.java

示例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;
}
 
开发者ID:rubenlagus,项目名称:TelegramBotsExample,代码行数:17,代码来源:Main.java

示例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();
	}

}
 
开发者ID:InsightLab,项目名称:telegram-bots,代码行数:12,代码来源:App.java

示例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);
	}
}
 
开发者ID:Bergiu,项目名称:TelegramEntenBot,代码行数:11,代码来源:Main.java

示例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");
    }
}
 
开发者ID:franziheck,项目名称:Paulette,代码行数:11,代码来源:Main.java

示例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();
	}
}
 
开发者ID:jesuino,项目名称:java-ml-projects,代码行数:10,代码来源:Main.java

示例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();
	}
}
 
开发者ID:alexNeto,项目名称:smart-home-bot,代码行数:13,代码来源:Main.java

示例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);
    }
}
 
开发者ID:addo37,项目名称:ExampleBots,代码行数:11,代码来源:Application.java

示例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();
        }
    }
 
开发者ID:argo2445,项目名称:QBot,代码行数:13,代码来源:Main.java

示例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();
		}
	}
 
开发者ID:Zabamund,项目名称:geoLearnBot,代码行数:16,代码来源:Main.java


注:本文中的org.telegram.telegrambots.TelegramBotsApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。