-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_tooltips.sh
More file actions
executable file
·146 lines (136 loc) · 7.24 KB
/
Copy pathgenerate_tooltips.sh
File metadata and controls
executable file
·146 lines (136 loc) · 7.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash
# generate_tooltips.sh — Full overwrite of data/tooltips.json with the 15 approved tooltips.
#
# Run manually during deployment or any time the tooltip set needs to be reset.
# Always performs a FULL OVERWRITE — no skip guard, no merge, no append.
# Writes [PROMO_BUTTON] literally — never resolves the placeholder (that happens at render time).
#
# Usage:
# ./generate_tooltips.sh [--dry-run]
# --dry-run Print the JSON that would be written without making any changes.
set -euo pipefail
info() { echo "[generate_tooltips] INFO: $*"; }
warn() { echo "[generate_tooltips] WARN: $*" >&2; }
error() { echo "[generate_tooltips] ERROR: $*" >&2; exit 1; }
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
APP_DIR="${RUNEWAGER_DIR:-$SCRIPT_DIR}"
DATA_DIR="$APP_DIR/data"
TOOLTIPS_FILE="$DATA_DIR/tooltips.json"
TMP_FILE="$TOOLTIPS_FILE.tmp.$$"
DRY_RUN=false
for arg in "$@"; do
case "$arg" in
--dry-run) DRY_RUN=true ;;
*) error "Unknown option: $arg. Usage: ./generate_tooltips.sh [--dry-run]" ;;
esac
done
# ── Tooltip content ───────────────────────────────────────────────────────────
# Format: single-line text with inline button syntax appended.
# Buttons: [Label - URL] && [Label2 - URL2]
# [PROMO_BUTTON] is a runtime placeholder — resolved by the bot at delivery time.
# DO NOT resolve [PROMO_BUTTON] here.
# shellcheck disable=SC2016
read -r -d '' TOOLTIP_JSON << 'ENDJSON' || true
[
{
"id": 1,
"text": "🔥 <b>Runewager Sports & Rewards</b> — free\u2011to\u2011play daily action, real boosts, and real prize redemptions. Get in now. [Play Now - https://t.me/RuneWager_bot/Play] && [Join Channel - https://t.me/GambleCodezDrops] && [Join Group - https://t.me/GambleCodezPrizeHub]",
"enabled": true
},
{
"id": 2,
"text": "⚡ The full <b>Runewager Mini App</b> is live — play, manage your profile, and track your progress all in one place. Tap in. [Play - https://t.me/RuneWager_bot/Play] && [Profile - https://t.me/RuneWager_bot/profile]",
"enabled": true
},
{
"id": 3,
"text": "💰 Verified? Your promos and bonuses are ready. Hit the <b>Claim</b> page now and collect. [Open Claim Page - https://t.me/RuneWager_bot/claim]",
"enabled": true
},
{
"id": 4,
"text": "📣 Never miss a drop — the Channel delivers announcements, the Group runs live community action. Join both now. [Join Channel - https://t.me/GambleCodezDrops] && [Join Group - https://t.me/GambleCodezPrizeHub]",
"enabled": true
},
{
"id": 5,
"text": "🎁 Enter code <b>SPORTS3.5</b> and claim <b>3.5 SC</b> free — unlocks immediately after verification. Don't leave it sitting. [Claim - https://t.me/RuneWager_bot/claim] && [Play - https://t.me/RuneWager_bot/Play]",
"enabled": true
},
{
"id": 6,
"text": "🔥 The <b>Prize Hub</b> is where the action lives — real\u2011time reactions, community energy, and every drop as it lands. [Join Group - https://t.me/GambleCodezPrizeHub] && [Join Channel - https://t.me/GambleCodezDrops]",
"enabled": true
},
{
"id": 7,
"text": "🎯 The official <b>Runewager Discord</b> is your hub for account verification, live updates, and direct support. Join now. [Join Discord - https://discord.gg/runewagers] && [Support - https://discord.com/channels/1100486422395355197/1249182067296567338]",
"enabled": true
},
{
"id": 8,
"text": "🔑 Complete Discord verification and unlock full Runewager access — takes just a few minutes. [Verify Channel - https://discord.com/channels/1100486422395355197/1249181934811349052] && [Join Discord - https://discord.gg/runewagers]",
"enabled": true
},
{
"id": 9,
"text": "🏆 Feeling lost? Every core feature is one tap from the main menu — jump straight back in. [Play - https://t.me/RuneWager_bot/Play] && [Profile - https://t.me/RuneWager_bot/profile]",
"enabled": true
},
{
"id": 10,
"text": "⚙️ Your setup progress is saved automatically — pick up exactly where you left off, zero repeats. [Profile - https://t.me/RuneWager_bot/profile]",
"enabled": true
},
{
"id": 11,
"text": "💬 Stuck on verification, promos, or access? Get fast answers in the official <b>Runewager Discord</b> support channel. [Join Discord - https://discord.gg/runewagers] && [Support - https://discord.com/channels/1100486422395355197/1249182067296567338]",
"enabled": true
},
{
"id": 12,
"text": "📌 This promo is capped at <b>600</b> claims total — once they're gone, they're gone. Claim yours now. [Claim - https://t.me/RuneWager_bot/claim] && [Play - https://t.me/RuneWager_bot/Play]",
"enabled": true
},
{
"id": 13,
"text": "🌐 Runewager spans <b>Telegram</b> + <b>Discord</b> — play in the mini app, catch every drop, and get support on Discord. Both matter. [Play - https://t.me/RuneWager_bot/Play] && [Join Discord - https://discord.gg/runewagers]",
"enabled": true
},
{
"id": 14,
"text": "📣 The channel drops. The group runs live. Stay in both and never miss an announcement, event, or prize window. [Join Channel - https://t.me/GambleCodezDrops] && [Join Group - https://t.me/GambleCodezPrizeHub]",
"enabled": true
},
{
"id": 15,
"text": "🔄 Telegram runs the play. Discord handles the support. Keep both active for the full <b>Runewager</b> experience. [Play - https://t.me/RuneWager_bot/Play] && [Profile - https://t.me/RuneWager_bot/profile]",
"enabled": true
}
]
ENDJSON
# ── Dry-run mode ─────────────────────────────────────────────────────────────
if $DRY_RUN; then
info "DRY-RUN — no files will be written."
info "Would write to: $TOOLTIPS_FILE"
echo "$TOOLTIP_JSON" | python3 -m json.tool --indent 2 \
|| error "Tooltip JSON is invalid — check content above."
info "JSON valid. Dry-run complete."
exit 0
fi
# ── Ensure data dir exists ────────────────────────────────────────────────────
mkdir -p "$DATA_DIR" || error "Cannot create data directory: $DATA_DIR"
[ -w "$DATA_DIR" ] || error "No write permission for $DATA_DIR"
# ── Atomic write: temp → validate → move ─────────────────────────────────────
trap 'rm -f "${TMP_FILE:-}"' EXIT INT TERM
printf '%s\n' "$TOOLTIP_JSON" > "$TMP_FILE"
# Validate JSON before replacing live file
node -e "
var d = JSON.parse(require('fs').readFileSync('$TMP_FILE','utf8'));
if (!Array.isArray(d) || d.length !== 15) throw new Error('Expected 15 tooltip entries, got ' + (Array.isArray(d) ? d.length : 'non-array'));
" 2>/dev/null || error "Generated JSON failed validation — aborting write."
mv "$TMP_FILE" "$TOOLTIPS_FILE"
COUNT=$(node -e "console.log(JSON.parse(require('fs').readFileSync('$TOOLTIPS_FILE','utf8')).length)" 2>/dev/null || echo "?")
info "Wrote $COUNT tooltips to $TOOLTIPS_FILE"
info "Run: systemctl restart runewager (or restart the bot) to pick up changes."
info "=== generate_tooltips.sh complete ==="