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
| package me.centralhardware.znatoki.telegram.statistic.telegram; | |
| import org.telegram.telegrambots.meta.api.objects.Update; | |
| public interface Handler { | |
| void handle(Update update); | |
| boolean isAcceptable(String data); |
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
| private <T extends Handler> boolean processHandler(Update update, List<T> handlers){ | |
| for (var handler : handlers) { | |
| if (handler.isAcceptable(update)) { | |
| handler.handle(update); | |
| return true; | |
| } | |
| } | |
| return false; | |
| } |
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
| public class InlineKeyboardBuilder { | |
| private final List<List<InlineKeyboardButton>> keyboard = new ArrayList<>(); | |
| private String text; | |
| private List<InlineKeyboardButton> row = null; | |
| private InlineKeyboardBuilder() { } | |
| public static InlineKeyboardBuilder create() { | |
| return new InlineKeyboardBuilder(); |
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
| import json | |
| import logging | |
| import os | |
| from json.decoder import JSONDecodeError | |
| from aiohttp import web | |
| from telethon.sync import TelegramClient | |
| def str2bool(boolean_string): |
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": "test" | |
| } |
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
| repositories { | |
| mavenLocal() | |
| mavenCentral() | |
| } | |
| buildscript { | |
| repositories { | |
| mavenLocal() | |
| mavenCentral() | |
| } | |
| dependencies { |
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
| public void saveStatisticOutcome(Object object){ | |
| String chatId; | |
| String text; | |
| if (object instanceof SendMessage sendMessage){ | |
| chatId = sendMessage.getChatId(); | |
| text = sendMessage.getText(); | |
| } else if (object instanceof SendPhoto sendPhoto){ | |
| chatId = sendPhoto.getChatId(); | |
| text = sendPhoto.getCaption(); | |
| } else if (object instanceof DeleteMessage deleteMessage){ |
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
| public void send(Object method, User user){ | |
| limiter.limit(() -> { | |
| try { | |
| telegramUtil.logSend(method); | |
| if (method instanceof BotApiMethodMessage botApiMethodMessage){ | |
| absSender.execute(botApiMethodMessage); | |
| } else if (method instanceof SendPhoto sendPhoto){ | |
| absSender.execute(sendPhoto); | |
| } else if (method instanceof DeleteMessage deleteMessage){ | |
| absSender.execute(deleteMessage); |
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
| var list = listOf( | |
| listOf(1, 2, 3), | |
| listOf(4, 1, 5) | |
| ) | |
| var count = 0 | |
| for (i in 0..list[1].size-1){ | |
| for (j in 0..list.size-1){ | |
| println(list[j][i]) | |
| if (list[j][i] == 1) count = count.inc() |
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
| fun getMetar(icao: String): String{ | |
| val metar = metarService.retrieveFromAirport(icao) | |
| return """ | |
| ${getAirport(metar.airport)} | |
| ${metar.day} ${metar.time} | |
| temp: ${metar.temperature}, dew point: ${metar.dewPoint}, ${if (metar.isNosig == true) "nosig" else ""} | |
| ${getWind(metar.wind)} | |
| ${getVisibility(metar.visibility)} | |
| ${getWeatherConditions(metar.weatherConditions)} | |