diff --git a/websites/L/Le Chat/Le Chat.json b/websites/L/Le Chat/Le Chat.json new file mode 100644 index 000000000000..b89dc1614b14 --- /dev/null +++ b/websites/L/Le Chat/Le Chat.json @@ -0,0 +1,18 @@ +{ + "leChat.startingPrompt": { + "description": "Displayed when the user is on the page to start a new prompt.", + "message": "Phrasing a new prompt..." + }, + "leChat.talkingWithAi": { + "description": "Displayed when the user is engaging in a conversation with the AI and the Chat title is not shown", + "message": "Talking with AI about something" + }, + "leChat.readingResponse": { + "description": "Displayed when the user is reading the response of the AI.", + "message": "Reading the AI's response" + }, + "leChat.askingQuestion": { + "description": "Displayed when the user is asking a question.", + "message": "Asking a question..." + } +} diff --git a/websites/L/Le Chat/metadata.json b/websites/L/Le Chat/metadata.json new file mode 100644 index 000000000000..8a222264f76d --- /dev/null +++ b/websites/L/Le Chat/metadata.json @@ -0,0 +1,37 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.13", + "apiVersion": 1, + "author": { + "id": "1167417152664522764", + "name": "kaktuswerk" + }, + "service": "Le Chat", + "description": { + "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." + }, + "url": "chat.mistral.ai", + "version": "1.0.0", + "logo": "https://i.imgur.com/CzKaHyo.png", + "thumbnail": "https://i.imgur.com/GYS9A0f.png", + "color": "#fc7703", + "category": "other", + "tags": [ + "lechat", + "mistral", + "ai", + "chat", + "conversations" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "showTitle", + "title": "Show chat title", + "icon": "fa-solid fa-message-quote", + "value": true + } + ] +} diff --git a/websites/L/Le Chat/presence.ts b/websites/L/Le Chat/presence.ts new file mode 100644 index 000000000000..2921de3e9432 --- /dev/null +++ b/websites/L/Le Chat/presence.ts @@ -0,0 +1,61 @@ +const presence = new Presence({ + clientId: '1338859356497641503', +}) +async function getStrings() { + return presence.getStrings({ + play: 'presence.playback.playing', + pause: 'presence.playback.paused', + newPrompt: 'leChat.startingPrompt', + talkingWithAi: 'leChat.talkingWithAi', + readingResponse: 'leChat.readingResponse', + askingQuestion: 'leChat.askingQuestion', + }) +} +const browsingTimestamp = Math.floor(Date.now() / 1000) + +enum Assets { + Logo = 'https://i.imgur.com/CzKaHyo.png', +} + +presence.on('UpdateData', async () => { + const { pathname } = document.location + const showTitle = await presence.getSetting('showTitle') + + let presenceDetail: string, presenceState: string + + const strings = await getStrings() + + if (pathname === '/chat') { + presenceDetail = strings.newPrompt + } + else if (pathname.includes('/chat/')) { + presenceDetail = showTitle + ? document.querySelector('a[aria-label="Open chat"]>div').textContent + : strings.talkingWithAi + } + else { + presenceDetail = strings.talkingWithAi + } + + // Checking if the user is currently typing a question + if (document.querySelector('textarea').textContent !== '') { + presenceState = strings.askingQuestion + } + else if ( + document.querySelector( + 'div[class=\'flex h-fit w-full flex-col\'] > div:last-child[style*=\'transform:none\']', + ) + ) { + presenceState = strings.readingResponse + } + else { + presenceState = null + } + + presence.setActivity({ + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + details: presenceDetail, + state: presenceState, + }) +})