Skip to content

Instantly share code, notes, and snippets.

View centralhardware's full-sized avatar

Alexey Fedechkin centralhardware

View GitHub Profile
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);
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;
}
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();
import json
import logging
import os
from json.decoder import JSONDecodeError
from aiohttp import web
from telethon.sync import TelegramClient
def str2bool(boolean_string):
repositories {
mavenLocal()
mavenCentral()
}
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
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){
@centralhardware
centralhardware / sdf.java
Created February 9, 2024 19:01
sdf.java
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);
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()
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)}