1- import type { EventHandlerMap , NotificationUserBeaconOnEpicCommentCreated , TicketMessageCreated } from '@roll-stack/queue'
1+ import type { EventHandlerMap , FlowItemCreated , NotificationUserBeaconOnEpicCommentCreated , TicketMessageCreated } from '@roll-stack/queue'
22import { db } from '@roll-stack/database'
33import { queue } from '@roll-stack/queue'
44import { useAtriumBot } from '../telegram/atrium-bot'
@@ -10,6 +10,7 @@ export async function setupConsumers() {
1010 return queue . consume < EventHandlerMap > ( queue . telegram . name , {
1111 ticketMessageCreated : handleTicketMessageCreated ,
1212 notificationUserBeaconOnEpicCommentCreated : handleUserBeaconOnEpicCommentCreated ,
13+ flowItemCreated : handleFlowItemCreated ,
1314 } )
1415}
1516
@@ -59,3 +60,31 @@ async function handleUserBeaconOnEpicCommentCreated(data: NotificationUserBeacon
5960 return false
6061 }
6162}
63+
64+ async function handleFlowItemCreated ( data : FlowItemCreated [ 'data' ] ) : Promise < boolean > {
65+ try {
66+ const separator = 'zzzzz'
67+ const startAppData = `flow${ separator } ${ data . itemId } `
68+
69+ // Get first words
70+ const messageIntro = data . description . split ( ' ' ) . slice ( 0 , 45 ) . join ( ' ' )
71+ const preparedMessage = `${ messageIntro } ...\n\nОстальное в Атриуме 🙃`
72+
73+ await useAtriumBot ( ) . api . sendMessage ( telegram . teamGroupId , preparedMessage , {
74+ link_preview_options : {
75+ is_disabled : true ,
76+ } ,
77+ reply_markup : {
78+ inline_keyboard : [ [ {
79+ text : '👉 Открыть Атриум' ,
80+ url : `https://t.me/sushi_atrium_bot/app?startapp=${ startAppData } ` ,
81+ } ] ] ,
82+ } ,
83+ } )
84+
85+ return true
86+ } catch ( error ) {
87+ console . error ( error )
88+ return false
89+ }
90+ }
0 commit comments