Skip to content

Commit 9719eee

Browse files
tschoggetheusafTimeraaBas950
authored
feat(Le Chat): Add new presence (#9271)
* fix(package-lock-version): upgraded cli version in package-lock.json * feat(lechat): added new presence * fix(lechat): formatted * fix(deepseek): fixed newline * fix(lechat): changed tab * fix(lechat): fixxed all the linting issues * fix(lechat): removed name from tags * fix(lechat): changed null to "" * fix(lechat): removed possible null * fix(lechat): fix quotes * fix(lechat): possible null * fix(lechat): possible null * fix(lechat): possible null * fix(lechat): possible null * fix(lechat): possible null --------- Co-authored-by: Daniel Lau <32113157+theusaf@users.noreply.github.com> Co-authored-by: Florian Metz <me@timeraa.dev> Co-authored-by: Bas van Zanten <me@bas950.com>
1 parent a26ad60 commit 9719eee

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

websites/L/Le Chat/Le Chat.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"leChat.startingPrompt": {
3+
"description": "Displayed when the user is on the page to start a new prompt.",
4+
"message": "Phrasing a new prompt..."
5+
},
6+
"leChat.talkingWithAi": {
7+
"description": "Displayed when the user is engaging in a conversation with the AI and the Chat title is not shown",
8+
"message": "Talking with AI about something"
9+
},
10+
"leChat.readingResponse": {
11+
"description": "Displayed when the user is reading the response of the AI.",
12+
"message": "Reading the AI's response"
13+
},
14+
"leChat.askingQuestion": {
15+
"description": "Displayed when the user is asking a question.",
16+
"message": "Asking a question..."
17+
}
18+
}

websites/L/Le Chat/metadata.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"$schema": "https://schemas.premid.app/metadata/1.13",
3+
"apiVersion": 1,
4+
"author": {
5+
"id": "1167417152664522764",
6+
"name": "kaktuswerk"
7+
},
8+
"service": "Le Chat",
9+
"description": {
10+
"en": "Le Chat is a conversational entry point to interact with the various models from Mistral AI. It offers a pedagogical and fun way to explore Mistral AI’s technology."
11+
},
12+
"url": "chat.mistral.ai",
13+
"version": "1.0.0",
14+
"logo": "https://i.imgur.com/CzKaHyo.png",
15+
"thumbnail": "https://i.imgur.com/GYS9A0f.png",
16+
"color": "#fc7703",
17+
"category": "other",
18+
"tags": [
19+
"mistral",
20+
"ai",
21+
"conversations"
22+
],
23+
"settings": [
24+
{
25+
"id": "lang",
26+
"multiLanguage": true
27+
},
28+
{
29+
"id": "showTitle",
30+
"title": "Show chat title",
31+
"icon": "fa-solid fa-message-quote",
32+
"value": true
33+
}
34+
]
35+
}

websites/L/Le Chat/presence.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const presence = new Presence({
2+
clientId: '1338859356497641503',
3+
})
4+
async function getStrings() {
5+
return presence.getStrings({
6+
play: 'presence.playback.playing',
7+
pause: 'presence.playback.paused',
8+
newPrompt: 'leChat.startingPrompt',
9+
talkingWithAi: 'leChat.talkingWithAi',
10+
readingResponse: 'leChat.readingResponse',
11+
askingQuestion: 'leChat.askingQuestion',
12+
})
13+
}
14+
const browsingTimestamp = Math.floor(Date.now() / 1000)
15+
16+
enum Assets {
17+
Logo = 'https://i.imgur.com/CzKaHyo.png',
18+
}
19+
20+
presence.on('UpdateData', async () => {
21+
const { pathname } = document.location
22+
const showTitle = await presence.getSetting<boolean>('showTitle')
23+
24+
let presenceDetail: string, presenceState: string
25+
26+
const strings = await getStrings()
27+
28+
if (pathname === '/chat') {
29+
presenceDetail = strings?.newPrompt ?? ''
30+
}
31+
else if (pathname.includes('/chat/')) {
32+
presenceDetail = (showTitle
33+
? document.querySelector('a[aria-label="Open chat"]>div')?.textContent
34+
: strings?.talkingWithAi) ?? ''
35+
}
36+
else {
37+
presenceDetail = strings.talkingWithAi
38+
}
39+
40+
// Checking if the user is currently typing a question
41+
if (document.querySelector('textarea')?.textContent !== '') {
42+
presenceState = strings.askingQuestion
43+
}
44+
else if (
45+
document.querySelector(
46+
'div[class=\'flex h-fit w-full flex-col\'] > div:last-child[style*=\'transform:none\']',
47+
)
48+
) {
49+
presenceState = strings.readingResponse
50+
}
51+
else {
52+
presenceState = ''
53+
}
54+
55+
presence.setActivity({
56+
largeImageKey: Assets.Logo,
57+
startTimestamp: browsingTimestamp,
58+
details: presenceDetail,
59+
state: presenceState,
60+
})
61+
})

0 commit comments

Comments
 (0)