Skip to content

Instantly share code, notes, and snippets.

@The0xArchitect
Created February 10, 2024 15:19
Show Gist options
  • Select an option

  • Save The0xArchitect/a79e86fcb0050aca6c9e2f7061985710 to your computer and use it in GitHub Desktop.

Select an option

Save The0xArchitect/a79e86fcb0050aca6c9e2f7061985710 to your computer and use it in GitHub Desktop.
This is a simple code for a Telegram bot to add Inline Keyboard Markup to all the messages specified.
import 'dart:io';
import 'package:televerse/televerse.dart';
final api = RawAPI(Platform.environment['BOT_TOKEN']!);
void main(List<String> args) async {
const id = ChannelID("@thexyprob");
final keys = langMsg.keys.toList();
final keyboard = buildKeyboard();
for (final el in keys) {
final msgId = int.parse(langMsg[el]!.split("/").last);
await api.editMessageReplyMarkup(id, msgId, replyMarkup: keyboard);
}
}
const langMsg = {
"English ๐Ÿ‡ฌ๐Ÿ‡ง": "https://t.me/thexyprob/4",
"Chineese ๐Ÿ‡จ๐Ÿ‡ณ": "https://t.me/thexyprob/21",
"Spanish ๐Ÿ‡ช๐Ÿ‡ธ": "https://t.me/thexyprob/23",
"Arabic ๐Ÿ‡ฆ๐Ÿ‡ช": "https://t.me/thexyprob/25",
"French ๐Ÿ‡ซ๐Ÿ‡ท": "https://t.me/thexyprob/27",
"Hindi ๐Ÿ‡ฎ๐Ÿ‡ณ": "https://t.me/thexyprob/29",
};
InlineKeyboard buildKeyboard() {
final k = InlineKeyboard();
final keys = langMsg.keys.toList();
for (final el in keys) {
final pos = keys.indexOf(el);
k.addUrl(el, langMsg[el]!);
if (pos == 3) {
k.row();
}
}
k
.row()
.addUrl(
"Source 1",
"https://xyproblem.info/",
)
.addUrl(
"Source 2",
"https://mywiki.wooledge.org/XyProblem",
)
.addUrl(
"Source 3",
"https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem",
);
return k;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment