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.bulider
import org.telegram.telegrambots.meta.api.methods.send.SendMessage
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup
import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.InlineKeyboardButton
import org.telegram.telegrambots.meta.api.objects.webapp.WebAppInfo
import kotlin.properties.Delegates
class InlineKeyboardDsl {
16:08:47.254 [DefaultDispatcher-worker-11] WARN ROOT --
dev.inmo.tgbotapi.bot.exceptions.CommonBotException: Something went wrong
at dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor.execute(DefaultKtorRequestsExecutor.kt:103)
at dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor$execute$1.invokeSuspend(DefaultKtorRequestsExecutor.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:28)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:99)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:28)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:99)
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)}
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()
@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);
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){
repositories {
mavenLocal()
mavenCentral()
}
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
import json
import logging
import os
from json.decoder import JSONDecodeError
from aiohttp import web
from telethon.sync import TelegramClient
def str2bool(boolean_string):
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();