This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use your own chatId, from Update object or your saved IDs | |
long chatId = 34; | |
// Get invite link of group | |
ExportChatInviteLink link = new ExportChatInviteLink(chatId); | |
// Execute and capture value (URL) | |
String groupUrl = null; | |
try { | |
groupUrl = execute(link); | |
} catch (TelegramApiException e) { | |
e.printStackTrace(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get invite link of group | |
ExportChatInviteLink link = new ExportChatInviteLink(ctx.chatId()); | |
// Execute and capture value (URL) | |
String groupUrl = silent.execute(link).orElseThrow(RuntimeException::new); | |
// For this demonstration, we just need one button for the link | |
InlineKeyboardButton btn = new InlineKeyboardButton("LINK").setUrl(groupUrl); | |
// Quick creation of a keyboard | |
InlineKeyboardMarkup kb = new InlineKeyboardMarkup(Arrays.asList(Arrays.asList(btn))); | |
// Send KB with a SendMessage object | |
silent.execute(new SendMessage().setText("This is an awesome button.").setReplyMarkup(kb).setChatId(ctx.chatId())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testReturnCodesTime() { | |
StopWatch watch = new StopWatch(); | |
watch.start(); | |
for (int i = 0; i <= 1000000; i++) { | |
if (doSomethingCodes(i) == -1) | |
watch.stop(); | |
} | |
long returnCodesTime = watch.getLastTaskTimeMillis(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calendar calendar = Calendar.getInstance(); | |
calendar.set(2017, Calendar.APRIL, 17, 6, 27, 0); | |
long desiredDelay = calendar.toInstant().getEpochSecond() - TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()); | |
Executors.newSingleThreadScheduledExecutor() | |
.schedule(() -> {/* your logic here */}, desiredDelay, TimeUnit.SECONDS); |