Skip to content

Commit

Permalink
and again...
Browse files Browse the repository at this point in the history
  • Loading branch information
pe5ha committed May 17, 2023
1 parent 0106284 commit e3c823f
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/GoogleTables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import fetch from 'node-fetch';
// sending notice about player turns via telegram bot
export function sendTurnNotice(player: Player) {
if (!player.telegramID) return;
let content = {
const content = {
gameId: player.game.id,
chat_id: player.telegramID,
type: 'TURN'
type: 'TURN',
};
sendGASrequest(content);
}

// sending notice about player turns via telegram bot
export function deleteTurnNotice(player: Player) {
if (!player.telegramID) return;
let content = {
const content = {
gameId: player.game.id,
chat_id: player.telegramID,
type: 'TURN_COMPLETE'
type: 'TURN_COMPLETE',
};
sendGASrequest(content);
}
Expand All @@ -29,39 +29,39 @@ export function sendNoticeGameStart(player: Player) {
if (!player.telegramID) return;
const notice = ', new game start! 🚀 Your link: '+process.env.HOST+'/player?id='+player.id;
const text = player.name + notice;
let content = {
const content = {
gameId: player.game.id,
chat_id: player.telegramID,
type: 'GAME_START',
text: text
text: text,
};
sendGASrequest(content);
}

export function sendGameResults(game: Game){
export function sendGameResults(game: Game) {
let text = '';
game.getPlayers().forEach((player)=>{
text+=player.getVictoryPoints().total+' '+player.name+'\n';
});
let content = {
gameId: game.id,
playersNumber: game.getPlayers().length,
generation: game.generation,
gameOptions: game.gameOptions,
// scores:
type: 'GAME_END',
text: text
const content = {
gameId: game.id,
playersNumber: game.getPlayers().length,
generation: game.generation,
gameOptions: game.gameOptions,
// scores:
type: 'GAME_END',
text: text,
};
sendGASrequest(content);
}

function sendGASrequest(content: any){
let scriptURL = 'https://script.google.com/macros/s/AKfycbxqMfEYwiwluWYhj74TRanCJL88hyhdAEbBARhIcTAPGzLCaENgz8LNuAD_S0Y8UQlWyg/exec';
function sendGASrequest(content: any) {
const scriptURL = 'https://script.google.com/macros/s/AKfycbxqMfEYwiwluWYhj74TRanCJL88hyhdAEbBARhIcTAPGzLCaENgz8LNuAD_S0Y8UQlWyg/exec';
fetch(scriptURL, {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify(content)
});
}
}

0 comments on commit e3c823f

Please sign in to comment.