@@ -99,6 +99,14 @@ const locationHeader = (ctx: RequestContext): string => {
9999 return `${ flag ( ctx . country ) } ${ place } ` ;
100100} ;
101101
102+ const sessionHistoryUrl = ( sessionId : string ) : string =>
103+ `https://glua.dev/?session=${ encodeURIComponent ( sessionId ) } ` ;
104+
105+ const networkFields = ( ctx : RequestContext ) : DiscordEmbedField [ ] => [
106+ { name : "IP" , value : ipLink ( ctx . ip ) , inline : true } ,
107+ { name : "Network" , value : ispLink ( ctx ) , inline : true } ,
108+ ] ;
109+
102110const contextSubtext = ( ctx : RequestContext | undefined ) : string | undefined => {
103111 if ( ! ctx ) return undefined ;
104112
@@ -128,25 +136,26 @@ export function buildSessionStartedEmbed(e: SessionStartedEvent): DiscordEmbed {
128136
129137 const lines : string [ ] = [
130138 `### ${ locationHeader ( ctx ) } ` ,
131- `New \`${ label } \` session from ${ ipLink ( ctx . ip ) } ` ,
132- sub ( `${ ispLink ( ctx ) } · started ${ relativeTimestamp ( ) } ${ ctx . colo ? ` · edge ${ code ( ctx . colo ) } ` : "" } ` ) ,
139+ sub ( `started ${ relativeTimestamp ( ) } ${ ctx . colo ? ` · edge ${ code ( ctx . colo ) } ` : "" } ` ) ,
133140 ] ;
134141
135142 const fields : DiscordEmbedField [ ] = [
136143 { name : "Session" , value : code ( truncate ( e . sessionId , 100 ) ) , inline : true } ,
137- { name : "Branch" , value : `${ emoji } ${ label } ` , inline : true } ,
144+ { name : "Branch" , value : `${ emoji } ${ code ( label ) } ` , inline : true } ,
145+ ...networkFields ( ctx ) ,
138146 ] ;
139147
140148 if ( ctx . userAgent ) {
141149 fields . push ( {
142150 name : "User-Agent" ,
143- value : "> " + truncate ( ctx . userAgent , LIMIT_UA_INLINE ) ,
151+ value : "```\n " + truncate ( ctx . userAgent , LIMIT_UA_INLINE ) + "\n```" ,
144152 inline : false ,
145153 } ) ;
146154 }
147155
148156 return {
149- title : `${ emoji } Session started · ${ label } ` ,
157+ title : "🚀 Session started" ,
158+ url : sessionHistoryUrl ( e . sessionId ) ,
150159 description : truncate ( lines . join ( "\n" ) , LIMIT_DESCRIPTION ) ,
151160 color : COLORS . sessionStart ,
152161 timestamp : new Date ( ) . toISOString ( ) ,
@@ -158,31 +167,30 @@ export function buildSessionStartedEmbed(e: SessionStartedEvent): DiscordEmbed {
158167export function buildSessionEndedEmbed ( e : SessionEndedEvent ) : DiscordEmbed {
159168 const { emoji, label } = branchMeta ( e . branch ) ;
160169 const reason = CLOSE_REASON_DISPLAY [ e . reason ] ;
161-
170+ const ctx = e . context ;
162171 const durationMs = e . startedAt !== undefined ? e . endedAt - e . startedAt : undefined ;
163- const historyUrl = `https://glua.dev/?session=${ encodeURIComponent ( e . sessionId ) } ` ;
164172
165173 const lines : string [ ] = [
166- `### 🏁 ${ label } session ended` ,
167- durationMs !== undefined
168- ? `Ran for **${ duration ( durationMs ) } ** · ${ link ( "📜 View history" , historyUrl ) } `
169- : link ( "📜 View history" , historyUrl ) ,
170- code ( truncate ( e . sessionId , 100 ) ) ,
174+ `### ${ ctx ? locationHeader ( ctx ) : "🌐 Unknown location" } ` ,
175+ sub ( `ended ${ relativeTimestamp ( ) } ${ durationMs !== undefined ? ` · ran for **${ duration ( durationMs ) } **` : "" } ` ) ,
171176 ] ;
172177
173- const subtext = contextSubtext ( e . context ) ;
174- if ( subtext ) lines . push ( subtext ) ;
175-
176178 const fields : DiscordEmbedField [ ] = [
177- { name : "Close reason" , value : ansi ( reason . ansiCode , `${ reason . icon } ${ reason . label } ` ) , inline : false } ,
178- { name : "Scripts" , value : String ( e . scriptCount ) , inline : true } ,
179- { name : "Log lines" , value : String ( e . logLineCount ) , inline : true } ,
180- { name : "Extended" , value : e . extensionGranted ? "yes" : "no" , inline : true } ,
179+ { name : "Session" , value : code ( truncate ( e . sessionId , 100 ) ) , inline : true } ,
180+ { name : "Branch" , value : `${ emoji } ${ code ( label ) } ` , inline : true } ,
181181 ] ;
182+ if ( ctx ) fields . push ( ...networkFields ( ctx ) ) ;
183+
184+ fields . push (
185+ { name : "Close reason" , value : ansi ( reason . ansiCode , `${ reason . icon } ${ reason . label } ` ) , inline : false } ,
186+ { name : "Scripts" , value : code ( String ( e . scriptCount ) ) , inline : true } ,
187+ { name : "Log lines" , value : code ( String ( e . logLineCount ) ) , inline : true } ,
188+ { name : "Extended" , value : e . extensionGranted ? "✅" : "❌" , inline : true } ,
189+ ) ;
182190
183191 return {
184- title : `${ emoji } Session ended · ${ label } · ${ reason . label } ` ,
185- url : historyUrl ,
192+ title : `🏁 Session ended · ${ reason . label } ` ,
193+ url : sessionHistoryUrl ( e . sessionId ) ,
186194 description : truncate ( lines . join ( "\n" ) , LIMIT_DESCRIPTION ) ,
187195 color : reason . color ,
188196 timestamp : new Date ( e . endedAt ) . toISOString ( ) ,
0 commit comments