Skip to content

Commit

Permalink
fix: telegram share button functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdzs committed Nov 7, 2024
1 parent 408bde9 commit 8cd2810
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add this to your ~/.gitconfig
[alias]
acp = "!f() { git add . && git commit -m \"$@\" && git push; }; f"
10 changes: 9 additions & 1 deletion src/scenes/GameOver.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class GameOver extends Scene
.setOrigin(0.5);

shareButton.on('pointerdown', () => {
// Use Telegram's share popup
window.Telegram.WebApp.showPopup({
title: 'Share Score',
message: `I scored ${score} points in Coin Clicker!`,
Expand All @@ -32,7 +33,14 @@ export class GameOver extends Scene
]
}, (buttonId) => {
if (buttonId === 'share') {
window.Telegram.WebApp.sendMessage(`I scored ${score} points in Coin Clicker! Try to beat my score!`);
// Use ShareButton API instead of sendMessage
window.Telegram.WebApp.openTelegramLink(
`https://t.me/share/url?` +
new URLSearchParams({
url: window.location.href,
text: `🎮 I scored ${score} points in Coin Clicker! Can you beat my score? Play now!`
}).toString()
);
}
});
});
Expand Down

0 comments on commit 8cd2810

Please sign in to comment.