Skip to content

Instantly share code, notes, and snippets.

@HeySreelal
Created February 10, 2024 15:19
Show Gist options
  • Save HeySreelal/a79e86fcb0050aca6c9e2f7061985710 to your computer and use it in GitHub Desktop.
Save HeySreelal/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