generated from QuantGeekDev/ts-tg-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from QuantGeekDev/feature/contact-sales
Feature/contact sales
- Loading branch information
Showing
14 changed files
with
71 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Composer } from "grammy"; | ||
import type { CustomContext } from "../types/context.js"; | ||
import { notifySalesTeam } from "../services/Admin/notifySalesTeam.js"; | ||
|
||
export const contactSalesController = new Composer<CustomContext>(); | ||
contactSalesController.callbackQuery("contact-sales", async ctx => { | ||
ctx.answerCallbackQuery(""); | ||
ctx.reply( | ||
"Your request has been registered - an agent will contact you shortly" | ||
); | ||
notifySalesTeam(ctx); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { Composer } from "grammy"; | ||
import type { CustomContext } from "../types/context.js"; | ||
import { startMenu } from "../menus/startMenu.js"; | ||
|
||
export const startController = new Composer<CustomContext>(); | ||
startController.command("start", async ctx => { | ||
await ctx.text("start", { | ||
name: ctx.config.user.name, | ||
chatName: ctx.config.chat?.title ?? "PM" | ||
}); | ||
const salisolLogoUrl = | ||
"https://lh3.googleusercontent.com/u/0/drive-viewer/AEYmBYSo6VRezOEbJpP0wzkLbT9JQ_f_HbNJw_MgzN45az99ZU5qvOe3Ad5N7qWGlHg_5iIUrRO-2sb82LOgcd-cOuBt8vNLSg=w2560-h1204"; | ||
await ctx.replyWithPhoto(salisolLogoUrl); | ||
await ctx.reply( | ||
`Hello ${ctx.config.user.name}, welcome to SaliSol☀️🏠 - 30 years developing properties on Spain's Costa Blanca.\nHow can we help you?`, | ||
{ reply_markup: startMenu } | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { InlineKeyboard } from "grammy"; | ||
|
||
const salisolParkWebsiteUrl = "https://salisolpark.com/"; | ||
|
||
export const startMenu = new InlineKeyboard() | ||
.text("🏠 View Developments", "view-developments") | ||
.row() | ||
.text("📞 Contact sales", "contact-sales") | ||
.row() | ||
.url("🌐 Visit website", salisolParkWebsiteUrl); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { CustomContext } from "../../types/context"; | ||
|
||
export const notifySalesTeam = (ctx: CustomContext) => { | ||
const adminGroupId = process.env.ADMIN_GROUP_ID; | ||
const userId = ctx.config.user.userId; | ||
const userName = ctx.config.user.name; | ||
const propertyOfInterest = null; | ||
const userClickable = `[${userName}](tg://user?id=${userId})`; | ||
|
||
const formattedNotificationMessage = `A new client is requesting information:\nName: ${userName}\nUser: @${userClickable}\n${ | ||
propertyOfInterest ? `Interested in ${propertyOfInterest}` : "" | ||
}`; | ||
|
||
ctx.api.sendMessage(adminGroupId, formattedNotificationMessage, { | ||
parse_mode: "MarkdownV2" | ||
}); | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters