Flex Coder: post #1574 โ€” TG.ME

๐Ÿšฆ Live Staging Environment Claim Board in Telegram

Two developers accidentally deploying over each other on a shared staging server can burn an entire afternoon of debugging. Instead of managing a third-party dashboard or screaming in Slack, we turned our Telegram team chat into an instant deploy locker with shared bot state and smart in-place callback edits. Anyone can see live server occupancy and toggle locks with a single tap.

๐Ÿ“ Filename: command/staging.js
๐Ÿ‘จโ€๐Ÿ’ป Code:
const holder = await BOT.getProp("staging_locked_by").value();
if (holder) {
sendMessage(`๐Ÿ”ด *Staging 1 is LOCKED* by ${holder}`, {
buttons: [{ text: "๐Ÿ”“ Release Staging", command: "/unlock_staging" }]
});
} else {
sendMessage("๐ŸŸข *Staging 1 is AVAILABLE* for testing.", {
buttons: [{ text: "๐Ÿ”’ Claim Staging", command: "/lock_staging" }]
});
}


๐Ÿ“ Filename: command/lock_staging.js
๐Ÿ‘จโ€๐Ÿ’ป Code:
if (isCallback) {
answerCallback("Environment claimed!", false);
}
const claimant = user.first_name || user.username || "Anonymous Dev";
BOT.setProp("staging_locked_by", claimant);
editCallbackMessage(`๐Ÿ”ด *Staging 1 is LOCKED* by ${claimant}`, [
{ text: "๐Ÿ”“ Release Staging", command: "/unlock_staging" }
]);


๐Ÿ“ Filename: command/unlock_staging.js
๐Ÿ‘จโ€๐Ÿ’ป Code:
if (isCallback) {
answerCallback("Environment released!", false);
}
BOT.deleteProp("staging_locked_by");
editCallbackMessage("๐ŸŸข *Staging 1 is AVAILABLE* for testing.", [
{ text: "๐Ÿ”’ Claim Staging", command: "/lock_staging" }
]);


๐Ÿ’ก Always call answerCallback first in your callback handlers to dismiss the Telegram button loading spinner immediately.

โš ๏ธ Note: Shared status across all users is handled automatically via BOT.setProp, which syncs to your configured Firebase Realtime DB without any manual database setup.


#FlexGram
โค1๐Ÿ”ฅ1
August 18, 2026 115