本文整理汇总了Java中pro.zackpollard.telegrambot.api.TelegramBot.login方法的典型用法代码示例。如果您正苦于以下问题:Java TelegramBot.login方法的具体用法?Java TelegramBot.login怎么用?Java TelegramBot.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pro.zackpollard.telegrambot.api.TelegramBot
的用法示例。
在下文中一共展示了TelegramBot.login方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ReddigramBot
import pro.zackpollard.telegrambot.api.TelegramBot; //导入方法依赖的package包/类
ReddigramBot() throws Exception {
timer = new Timer();
config = BotConfig.configFromFile(new File("config.json"));
dataFile = DataFile.load(this);
client = new RedditClient(UserAgent.of("server", "xyz.mkotb.reddigram", "1.0", config.redditUsername()));
telegramBot = TelegramBot.login(config.botApiKey());
liveManager = new LiveManager(this);
telegramBot.getEventsManager().register(new InlineListener(this));
telegramBot.getEventsManager().register(new CommandListener(this));
telegramBot.startUpdates(true);
log("Successfully logged in");
timer.scheduleAtFixedRate(new OAuthTask(this), 0L, 3500000L); // every 58 minutes reauth.
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (dataFile != null) {
dataFile.save();
}
}
}, 0L, 600000L); // every 10m save data file
}
示例2: EchoBot
import pro.zackpollard.telegrambot.api.TelegramBot; //导入方法依赖的package包/类
public EchoBot() {
//This returns a logged in TelegramBot instance or null if the API key was invalid.
telegramBot = TelegramBot.login(API_KEY);
//This registers the EchoListener Listener to this bot.
telegramBot.getEventsManager().register(new EchoListener(telegramBot));
//This method starts the retrieval of updates.
//The boolean it accepts is to specify whether to retrieve messages
//which were sent before the bot was started but after the bot was last turned off.
telegramBot.startUpdates(false);
//The following while(true) loop is simply for keeping the java application alive.
//You can do this however you like, but none of the above methods are blocking and
//so without this code the bot would simply boot then exit.
while (true) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
示例3: InlineTranslationBot
import pro.zackpollard.telegrambot.api.TelegramBot; //导入方法依赖的package包/类
public InlineTranslationBot() {
//This returns a logged in TelegramBot instance or null if the API key was invalid.
telegramBot = TelegramBot.login(API_KEY);
//This registers the FormattingListener Listener to this bot.
telegramBot.getEventsManager().register(new InlineTranslationListener(telegramBot));
//This method starts the retrieval of updates.
//The boolean it accepts is to specify whether to retrieve messages
//which were sent before the bot was started but after the bot was last turned off.
telegramBot.startUpdates(false);
//The following while(true) loop is simply for keeping the java application alive.
//You can do this however you like, but none of the above methods are blocking and
//so without this code the bot would simply boot then exit.
while (true) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
示例4: InlineSpoilerBot
import pro.zackpollard.telegrambot.api.TelegramBot; //导入方法依赖的package包/类
public InlineSpoilerBot() {
instance = this;
//This returns a logged in TelegramBot instance or null if the API key was invalid.
telegramBot = TelegramBot.login(API_KEY);
//This registers the SpoilerListener Listener to this bot.
initSpoilerManager();
telegramBot.getEventsManager().register(listener);
//This method starts the retrieval of updates.
//The boolean it accepts is to specify whether to retrieve messages
//which were sent before the bot was started but after the bot was last turned off.
telegramBot.startUpdates(false);
//The following while(true) loop is simply for keeping the java application alive.
//You can do this however you like, but none of the above methods are blocking and
//so without this code the bot would simply boot then exit.
while (true) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
示例5: FormattingBot
import pro.zackpollard.telegrambot.api.TelegramBot; //导入方法依赖的package包/类
public FormattingBot() {
//This returns a logged in TelegramBot instance or null if the API key was invalid.
telegramBot = TelegramBot.login(API_KEY);
//This registers the FormattingListener Listener to this bot.
telegramBot.getEventsManager().register(new FormattingListener(telegramBot));
//This method starts the retrieval of updates.
//The boolean it accepts is to specify whether to retrieve messages
//which were sent before the bot was started but after the bot was last turned off.
telegramBot.startUpdates(false);
//The following while(true) loop is simply for keeping the java application alive.
//You can do this however you like, but none of the above methods are blocking and
//so without this code the bot would simply boot then exit.
while (true) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
示例6: RemindMeBot
import pro.zackpollard.telegrambot.api.TelegramBot; //导入方法依赖的package包/类
private RemindMeBot(String key) {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
instance = this;
this.bot = TelegramBot.login(key);
bot.getEventsManager().register(new RemindMeBotListener());
bot.startUpdates(false);
storageHook = new StorageHook();
reminderManager = new ReminderManager();
//Save reminder map on shutdown to ensure persistence of reminders
Runtime.getRuntime().addShutdownHook(new Thread(storageHook::save));
this.debug("Bot started!");
}
示例7: WhatIsBot
import pro.zackpollard.telegrambot.api.TelegramBot; //导入方法依赖的package包/类
public WhatIsBot(String key) {
System.out.println("Initialising bot");
bot = TelegramBot.login(key);
if (bot == null) {
System.out.println("Failed to login! Faulty API key?");
System.exit(1);
}
System.out.println("Registering events");
bot.getEventsManager().register(new WhatIsBotListener(this));
bot.startUpdates(false);
System.out.println("Bot initialised!");
}
示例8: TelegramHook
import pro.zackpollard.telegrambot.api.TelegramBot; //导入方法依赖的package包/类
public TelegramHook(String authKey, RedditLiveBot instance) {
this.instance = instance;
bot = TelegramBot.login(authKey);
bot.startUpdates(false);
bot.getEventsManager().register(new TelegramEventHandler());
JenkinsUpdateHandler.UpdateInformation updateInformation = instance.getJenkinsUpdateHandler().getLastUpdate();
if (updateInformation == null || updateInformation.getGitCommitAuthors() == null || updateInformation.getGitCommitAuthors().isEmpty()) {
Lang.sendAdmin("*RedditLiveBot has connected.\n\n No build information available...*");
} else {
Lang.sendAdmin("*RedditLiveBot has connected (Build %d).*\n\n" +
"*Last commit information:*\n" +
"*Description:* %s\n" +
"*Author:* %s\n" +
"*Commit ID:* %s\n",
updateInformation.getBuildNumber(),
updateInformation.getGitCommitMessages().get(0),
updateInformation.getGitCommitAuthors().get(0),
"[" + updateInformation.getGitCommitIds().get(0) + "]" +
"(https://github.com/stuntguy3000/RedditLiveBot/commit/"
+ updateInformation.getGitCommitIds().get(0) + ")");
}
redditLiveChat = TelegramHook.getBot().getChat("@RedditLive");
}
示例9: TopKekBot
import pro.zackpollard.telegrambot.api.TelegramBot; //导入方法依赖的package包/类
private TopKekBot(String authToken) {
instance = this;
this.bot = TelegramBot.login(authToken);
this.lastCommand = new HashMap<>();
System.out.println("Bot logged in: " + this.bot.toString());
}