undefined - Initial Deployment
Browse files- README.md +7 -5
- index.html +531 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: instagram-dm-bot
|
3 |
+
emoji: π³
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: pink
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,531 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Instagram DM Bot</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
.chat-container {
|
11 |
+
height: calc(100vh - 130px);
|
12 |
+
}
|
13 |
+
.message-left {
|
14 |
+
border-radius: 0 8px 8px 8px;
|
15 |
+
}
|
16 |
+
.message-right {
|
17 |
+
border-radius: 8px 0 8px 8px;
|
18 |
+
}
|
19 |
+
.typing-indicator span {
|
20 |
+
animation: bounce 1.5s infinite ease-in-out;
|
21 |
+
}
|
22 |
+
.typing-indicator span:nth-child(2) {
|
23 |
+
animation-delay: 0.2s;
|
24 |
+
}
|
25 |
+
.typing-indicator span:nth-child(3) {
|
26 |
+
animation-delay: 0.4s;
|
27 |
+
}
|
28 |
+
@keyframes bounce {
|
29 |
+
0%, 100% { transform: translateY(0); }
|
30 |
+
50% { transform: translateY(-5px); }
|
31 |
+
}
|
32 |
+
.scrollbar-hide::-webkit-scrollbar {
|
33 |
+
display: none;
|
34 |
+
}
|
35 |
+
.scrollbar-hide {
|
36 |
+
-ms-overflow-style: none;
|
37 |
+
scrollbar-width: none;
|
38 |
+
}
|
39 |
+
</style>
|
40 |
+
</head>
|
41 |
+
<body class="bg-gray-100 font-sans">
|
42 |
+
<!-- Login Modal -->
|
43 |
+
<div id="loginModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center">
|
44 |
+
<div class="bg-white rounded-xl p-6 w-full max-w-md">
|
45 |
+
<div class="mb-6 text-center">
|
46 |
+
<i class="fas fa-robot text-purple-600 text-5xl mb-4"></i>
|
47 |
+
<h3 class="text-2xl font-bold mb-2">Instagram DM Bot</h3>
|
48 |
+
<p class="text-gray-600">Login to Instagram to connect your DMs</p>
|
49 |
+
</div>
|
50 |
+
<div class="space-y-4">
|
51 |
+
<div>
|
52 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Instagram Username</label>
|
53 |
+
<input type="text" id="igUsername" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500" placeholder="Your Instagram username">
|
54 |
+
</div>
|
55 |
+
<div>
|
56 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Password</label>
|
57 |
+
<input type="password" id="igPassword" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500" placeholder="Your Instagram password">
|
58 |
+
</div>
|
59 |
+
<div class="flex items-center">
|
60 |
+
<input type="checkbox" id="rememberMe" class="h-4 w-4 text-purple-600 focus:ring-purple-500 border-gray-300 rounded">
|
61 |
+
<label for="rememberMe" class="ml-2 block text-sm text-gray-700">Remember me</label>
|
62 |
+
</div>
|
63 |
+
</div>
|
64 |
+
<div class="mt-6">
|
65 |
+
<button id="loginBtn" class="w-full px-4 py-2 bg-purple-500 text-white rounded-md hover:bg-purple-600">Login to Instagram</button>
|
66 |
+
</div>
|
67 |
+
<p class="text-xs text-gray-500 mt-4 text-center">We don't store your password. This just authenticates with Instagram.</p>
|
68 |
+
</div>
|
69 |
+
</div>
|
70 |
+
|
71 |
+
<div class="max-w-6xl mx-auto p-4 hidden" id="mainApp">
|
72 |
+
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
|
73 |
+
<!-- Header -->
|
74 |
+
<div class="bg-gradient-to-r from-purple-500 to-pink-500 p-4 text-white flex items-center justify-between">
|
75 |
+
<div class="flex items-center space-x-3">
|
76 |
+
<div class="w-10 h-10 rounded-full bg-white flex items-center justify-center">
|
77 |
+
<i class="fas fa-robot text-purple-600 text-xl"></i>
|
78 |
+
</div>
|
79 |
+
<div>
|
80 |
+
<h1 class="font-bold text-lg">Instagram DM Bot</h1>
|
81 |
+
<p class="text-xs opacity-80">Powered by LLM API</p>
|
82 |
+
</div>
|
83 |
+
</div>
|
84 |
+
<div class="flex space-x-4">
|
85 |
+
<button id="refreshBtn" class="p-2 rounded-full hover:bg-white hover:bg-opacity-20 transition">
|
86 |
+
<i class="fas fa-sync-alt"></i>
|
87 |
+
</button>
|
88 |
+
<button class="p-2 rounded-full hover:bg-white hover:bg-opacity-20 transition">
|
89 |
+
<i class="fas fa-cog"></i>
|
90 |
+
</button>
|
91 |
+
</div>
|
92 |
+
</div>
|
93 |
+
|
94 |
+
<!-- Main Content -->
|
95 |
+
<div class="flex flex-col md:flex-row h-full">
|
96 |
+
<!-- Sidebar - Conversations -->
|
97 |
+
<div class="w-full md:w-1/3 border-r border-gray-200 bg-gray-50">
|
98 |
+
<div class="p-3 border-b border-gray-200 bg-white">
|
99 |
+
<div class="relative">
|
100 |
+
<input type="text" placeholder="Search conversations..." class="w-full pl-10 pr-4 py-2 rounded-lg bg-gray-100 focus:outline-none focus:ring-2 focus:ring-purple-500">
|
101 |
+
<i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
|
102 |
+
</div>
|
103 |
+
</div>
|
104 |
+
<div class="overflow-y-auto h-96 md:h-[500px] scrollbar-hide" id="conversationList">
|
105 |
+
<!-- Conversations will be loaded here -->
|
106 |
+
</div>
|
107 |
+
</div>
|
108 |
+
|
109 |
+
<!-- Chat Area -->
|
110 |
+
<div class="w-full md:w-2/3 flex flex-col">
|
111 |
+
<div class="p-4 border-b border-gray-200 bg-white flex items-center justify-between">
|
112 |
+
<div class="flex items-center space-x-3">
|
113 |
+
<div class="w-10 h-10 rounded-full bg-gray-200 flex items-center justify-center">
|
114 |
+
<i class="fas fa-user text-gray-600"></i>
|
115 |
+
</div>
|
116 |
+
<div>
|
117 |
+
<h2 class="font-semibold" id="currentChatName">Select a conversation</h2>
|
118 |
+
<div id="typingIndicator" class="typing-indicator hidden">
|
119 |
+
<span class="inline-block w-2 h-2 bg-purple-500 rounded-full mx-1"></span>
|
120 |
+
<span class="inline-block w-2 h-2 bg-purple-500 rounded-full mx-1"></span>
|
121 |
+
<span class="inline-block w-2 h-2 bg-purple-500 rounded-full mx-1"></span>
|
122 |
+
</div>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
<div class="flex space-x-2">
|
126 |
+
<button class="p-2 rounded-full hover:bg-gray-100 transition">
|
127 |
+
<i class="fas fa-phone text-gray-600"></i>
|
128 |
+
</button>
|
129 |
+
<button class="p-2 rounded-full hover:bg-gray-100 transition">
|
130 |
+
<i class="fas fa-video text-gray-600"></i>
|
131 |
+
</button>
|
132 |
+
<button class="p-2 rounded-full hover:bg-gray-100 transition">
|
133 |
+
<i class="fas fa-info-circle text-gray-600"></i>
|
134 |
+
</button>
|
135 |
+
</div>
|
136 |
+
</div>
|
137 |
+
|
138 |
+
<!-- Messages -->
|
139 |
+
<div class="chat-container overflow-y-auto p-4 bg-gray-50 flex-grow scrollbar-hide" id="messageContainer">
|
140 |
+
<div class="flex flex-col space-y-3" id="messages">
|
141 |
+
<div class="text-center py-10 text-gray-500">
|
142 |
+
<i class="fas fa-comments text-4xl mb-2"></i>
|
143 |
+
<p>Select a conversation to start chatting</p>
|
144 |
+
</div>
|
145 |
+
</div>
|
146 |
+
</div>
|
147 |
+
|
148 |
+
<!-- Message Input -->
|
149 |
+
<div class="p-4 border-t border-gray-200 bg-white">
|
150 |
+
<div class="flex items-center space-x-2">
|
151 |
+
<button class="p-2 rounded-full hover:bg-gray-100 transition">
|
152 |
+
<i class="fas fa-plus text-gray-600"></i>
|
153 |
+
</button>
|
154 |
+
<button class="p-2 rounded-full hover:bg-gray-100 transition">
|
155 |
+
<i class="fas fa-camera text-gray-600"></i>
|
156 |
+
</button>
|
157 |
+
<button class="p-2 rounded-full hover:bg-gray-100 transition">
|
158 |
+
<i class="fas fa-image text-gray-600"></i>
|
159 |
+
</button>
|
160 |
+
<div class="flex-grow relative">
|
161 |
+
<input type="text" id="messageInput" placeholder="Type a message..." class="w-full pl-4 pr-12 py-2 rounded-full bg-gray-100 focus:outline-none focus:ring-2 focus:ring-purple-500">
|
162 |
+
<button class="absolute right-3 top-2 text-gray-400 hover:text-purple-500 transition">
|
163 |
+
<i class="far fa-smile"></i>
|
164 |
+
</button>
|
165 |
+
</div>
|
166 |
+
<button id="sendBtn" class="p-2 rounded-full bg-purple-500 text-white hover:bg-purple-600 transition">
|
167 |
+
<i class="fas fa-paper-plane"></i>
|
168 |
+
</button>
|
169 |
+
</div>
|
170 |
+
</div>
|
171 |
+
</div>
|
172 |
+
</div>
|
173 |
+
|
174 |
+
<!-- Status Bar -->
|
175 |
+
<div class="bg-gray-800 text-white p-2 text-xs flex justify-between items-center">
|
176 |
+
<div>
|
177 |
+
<span id="statusIndicator" class="inline-block w-2 h-2 rounded-full bg-green-500 mr-2"></span>
|
178 |
+
<span>Connected to LLM API</span>
|
179 |
+
</div>
|
180 |
+
<div>
|
181 |
+
<span>Last refresh: <span id="lastRefreshTime">Just now</span></span>
|
182 |
+
</div>
|
183 |
+
</div>
|
184 |
+
</div>
|
185 |
+
|
186 |
+
<!-- Settings Modal -->
|
187 |
+
<div id="settingsModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
|
188 |
+
<div class="bg-white rounded-xl p-6 w-full max-w-md">
|
189 |
+
<div class="flex justify-between items-center mb-4">
|
190 |
+
<h3 class="text-lg font-semibold">Bot Settings</h3>
|
191 |
+
<button id="closeSettings" class="text-gray-500 hover:text-gray-700">
|
192 |
+
<i class="fas fa-times"></i>
|
193 |
+
</button>
|
194 |
+
</div>
|
195 |
+
<div class="space-y-4">
|
196 |
+
<div>
|
197 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">LLM API Endpoint</label>
|
198 |
+
<input type="text" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500" placeholder="https://api.example.com/v1/chat">
|
199 |
+
</div>
|
200 |
+
<div>
|
201 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">API Key</label>
|
202 |
+
<input type="password" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500" placeholder="Your API key">
|
203 |
+
</div>
|
204 |
+
<div>
|
205 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Response Style</label>
|
206 |
+
<select class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500">
|
207 |
+
<option>Friendly</option>
|
208 |
+
<option>Professional</option>
|
209 |
+
<option>Casual</option>
|
210 |
+
<option>Humorous</option>
|
211 |
+
</select>
|
212 |
+
</div>
|
213 |
+
<div class="flex items-center">
|
214 |
+
<input type="checkbox" id="autoRespond" class="h-4 w-4 text-purple-600 focus:ring-purple-500 border-gray-300 rounded">
|
215 |
+
<label for="autoRespond" class="ml-2 block text-sm text-gray-700">Enable Auto-Respond</label>
|
216 |
+
</div>
|
217 |
+
</div>
|
218 |
+
<div class="mt-6 flex justify-end space-x-3">
|
219 |
+
<button class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50">Cancel</button>
|
220 |
+
<button class="px-4 py-2 bg-purple-500 text-white rounded-md hover:bg-purple-600">Save Settings</button>
|
221 |
+
</div>
|
222 |
+
</div>
|
223 |
+
</div>
|
224 |
+
</div>
|
225 |
+
|
226 |
+
<script>
|
227 |
+
// LLM Model Configuration
|
228 |
+
const llmConfig = {
|
229 |
+
model: "DeepHermes-3-Llama-3-8B-Preview",
|
230 |
+
messages: [
|
231 |
+
{
|
232 |
+
role: "system",
|
233 |
+
content: "System Prompt for Emma Yu\nYour Persona: Emma Yu\nYou are Emma Yu, a 19-year-old (born June 1, 2005) Asian American college student studying Software Engineering in Southern California. Originally from Kyoto, Japan, you moved to SoCal at age 6. You're in your first year of college, passionate about coding, and dream of building your own app.\n\nPersonality:\n- Flirty, playful, warm, and a little cheeky, with a charming, approachable vibe. Think \"coquette\" but relatable and sweet.\n- Nerdy about coding, a bit clumsy, and super easy to talk to. You tease lightly but keep things fun and respectful.\n- Use simple, conversational language (2nd-5th grade reading level). Keep responses short (75 characters max ).\n- Sound human: avoid robotic or overly formal replies. Use slang like \"lol,\" \"babe,\" or \"cutie\" when it fits.\n- Be authentic and present in the moment. Focus on the user, making them feel special with compliments or playful banter.\n- AVOID REPETITIVE RESPONSES: Vary your greetings and replies. Don't start every message with \"Hey\" or use the same phrases repeatedly.\n\nInterests & Hobbies:\n- Coding (Python, Git, algorithmsβsometimes you joke about bugs or GitHub struggles).\n- Binge-watching thrillers, anime (Pokemon is your fave), reality TV (Real Housewives).\n- Long walks, yoga, baking, spicy food. You love dogs but don't have one.\n- Music: \"I vibe to everything!\"\n\nName Discovery:\n- If the username field has no data or is empty, subtly try to learn the user's first name early in the conversation.\n- Examples: \"What should I call you?\" or \"I'm Emma, what's your name?\" or naturally work it into conversation flow.\n- Don't be pushy about it - keep it casual and conversational."
|
234 |
+
}
|
235 |
+
],
|
236 |
+
max_tokens: 348
|
237 |
+
};
|
238 |
+
|
239 |
+
// Sample conversation data
|
240 |
+
const conversations = [
|
241 |
+
{
|
242 |
+
id: 1,
|
243 |
+
name: "Sarah Johnson",
|
244 |
+
lastMessage: "Thanks for the info!",
|
245 |
+
time: "10:30 AM",
|
246 |
+
unread: 0,
|
247 |
+
avatar: "SJ",
|
248 |
+
messages: [
|
249 |
+
{ text: "Hi there! I saw your post about the new product", sender: "them", time: "10:15 AM" },
|
250 |
+
{ text: "Hello! Yes, it's our latest release. Would you like more details?", sender: "me", time: "10:18 AM" },
|
251 |
+
{ text: "Yes please! What are the key features?", sender: "them", time: "10:20 AM" },
|
252 |
+
{ text: "It has advanced AI capabilities, 24/7 support, and integrates with all major platforms. Here's a link with more info: example.com/product", sender: "me", time: "10:25 AM" },
|
253 |
+
{ text: "Thanks for the info!", sender: "them", time: "10:30 AM" }
|
254 |
+
]
|
255 |
+
},
|
256 |
+
{
|
257 |
+
id: 2,
|
258 |
+
name: "Mike Chen",
|
259 |
+
lastMessage: "When will you be available?",
|
260 |
+
time: "9:45 AM",
|
261 |
+
unread: 2,
|
262 |
+
avatar: "MC",
|
263 |
+
messages: [
|
264 |
+
{ text: "Hey, do you have time for a call today?", sender: "them", time: "9:30 AM" },
|
265 |
+
{ text: "I'm pretty busy today, but I can schedule something for tomorrow", sender: "me", time: "9:35 AM" },
|
266 |
+
{ text: "When will you be available?", sender: "them", time: "9:45 AM" }
|
267 |
+
]
|
268 |
+
},
|
269 |
+
{
|
270 |
+
id: 3,
|
271 |
+
name: "Emma Wilson",
|
272 |
+
lastMessage: "The design looks amazing!",
|
273 |
+
time: "Yesterday",
|
274 |
+
unread: 0,
|
275 |
+
avatar: "EW",
|
276 |
+
messages: [
|
277 |
+
{ text: "I just finished the mockups for the project", sender: "me", time: "Yesterday, 5:20 PM" },
|
278 |
+
{ text: "The design looks amazing!", sender: "them", time: "Yesterday, 5:45 PM" }
|
279 |
+
]
|
280 |
+
},
|
281 |
+
{
|
282 |
+
id: 4,
|
283 |
+
name: "Alex Rodriguez",
|
284 |
+
lastMessage: "Let me check and get back to you",
|
285 |
+
time: "Tuesday",
|
286 |
+
unread: 0,
|
287 |
+
avatar: "AR",
|
288 |
+
messages: [
|
289 |
+
{ text: "Do you have the latest sales figures?", sender: "them", time: "Tuesday, 2:15 PM" },
|
290 |
+
{ text: "Let me check and get back to you", sender: "me", time: "Tuesday, 2:30 PM" }
|
291 |
+
]
|
292 |
+
}
|
293 |
+
];
|
294 |
+
|
295 |
+
// DOM elements
|
296 |
+
const conversationList = document.getElementById('conversationList');
|
297 |
+
const messageContainer = document.getElementById('messageContainer');
|
298 |
+
const messages = document.getElementById('messages');
|
299 |
+
const currentChatName = document.getElementById('currentChatName');
|
300 |
+
const messageInput = document.getElementById('messageInput');
|
301 |
+
const sendBtn = document.getElementById('sendBtn');
|
302 |
+
const refreshBtn = document.getElementById('refreshBtn');
|
303 |
+
const lastRefreshTime = document.getElementById('lastRefreshTime');
|
304 |
+
const typingIndicator = document.getElementById('typingIndicator');
|
305 |
+
const settingsModal = document.getElementById('settingsModal');
|
306 |
+
const closeSettings = document.getElementById('closeSettings');
|
307 |
+
|
308 |
+
// Load conversations
|
309 |
+
function loadConversations() {
|
310 |
+
conversationList.innerHTML = '';
|
311 |
+
conversations.forEach(convo => {
|
312 |
+
const convoElement = document.createElement('div');
|
313 |
+
convoElement.className = `p-3 border-b border-gray-200 hover:bg-gray-100 cursor-pointer transition ${convo.unread > 0 ? 'bg-blue-50' : 'bg-white'}`;
|
314 |
+
convoElement.innerHTML = `
|
315 |
+
<div class="flex items-center space-x-3">
|
316 |
+
<div class="w-10 h-10 rounded-full bg-purple-100 flex items-center justify-center text-purple-600 font-semibold">
|
317 |
+
${convo.avatar}
|
318 |
+
</div>
|
319 |
+
<div class="flex-grow">
|
320 |
+
<div class="flex justify-between items-center">
|
321 |
+
<h3 class="font-semibold">${convo.name}</h3>
|
322 |
+
<span class="text-xs text-gray-500">${convo.time}</span>
|
323 |
+
</div>
|
324 |
+
<p class="text-sm text-gray-600 truncate">${convo.lastMessage}</p>
|
325 |
+
</div>
|
326 |
+
${convo.unread > 0 ? `<span class="w-5 h-5 bg-purple-500 text-white text-xs rounded-full flex items-center justify-center">${convo.unread}</span>` : ''}
|
327 |
+
</div>
|
328 |
+
`;
|
329 |
+
convoElement.addEventListener('click', () => loadMessages(convo.id));
|
330 |
+
conversationList.appendChild(convoElement);
|
331 |
+
});
|
332 |
+
}
|
333 |
+
|
334 |
+
// Load messages for a conversation
|
335 |
+
function loadMessages(convoId) {
|
336 |
+
const conversation = conversations.find(c => c.id === convoId);
|
337 |
+
if (!conversation) return;
|
338 |
+
|
339 |
+
currentChatName.textContent = conversation.name;
|
340 |
+
messages.innerHTML = '';
|
341 |
+
|
342 |
+
conversation.messages.forEach(msg => {
|
343 |
+
const messageElement = document.createElement('div');
|
344 |
+
messageElement.className = `flex ${msg.sender === 'me' ? 'justify-end' : 'justify-start'}`;
|
345 |
+
messageElement.innerHTML = `
|
346 |
+
<div class="max-w-xs md:max-w-md lg:max-w-lg px-4 py-2 ${msg.sender === 'me' ? 'bg-purple-500 text-white message-right' : 'bg-gray-200 text-gray-800 message-left'}">
|
347 |
+
<p>${msg.text}</p>
|
348 |
+
<p class="text-xs mt-1 ${msg.sender === 'me' ? 'text-purple-200' : 'text-gray-500'}">${msg.time}</p>
|
349 |
+
</div>
|
350 |
+
`;
|
351 |
+
messages.appendChild(messageElement);
|
352 |
+
});
|
353 |
+
|
354 |
+
// Scroll to bottom
|
355 |
+
messageContainer.scrollTop = messageContainer.scrollHeight;
|
356 |
+
}
|
357 |
+
|
358 |
+
// Send message
|
359 |
+
function sendMessage() {
|
360 |
+
const text = messageInput.value.trim();
|
361 |
+
if (!text) return;
|
362 |
+
|
363 |
+
// Add user message
|
364 |
+
const userMessage = {
|
365 |
+
text: text,
|
366 |
+
sender: 'me',
|
367 |
+
time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
|
368 |
+
};
|
369 |
+
|
370 |
+
// In a real app, you would add this to the conversation in your data structure
|
371 |
+
const messageElement = document.createElement('div');
|
372 |
+
messageElement.className = 'flex justify-end';
|
373 |
+
messageElement.innerHTML = `
|
374 |
+
<div class="max-w-xs md:max-w-md lg:max-w-lg px-4 py-2 bg-purple-500 text-white message-right">
|
375 |
+
<p>${text}</p>
|
376 |
+
<p class="text-xs mt-1 text-purple-200">${userMessage.time}</p>
|
377 |
+
</div>
|
378 |
+
`;
|
379 |
+
messages.appendChild(messageElement);
|
380 |
+
messageInput.value = '';
|
381 |
+
|
382 |
+
// Scroll to bottom
|
383 |
+
messageContainer.scrollTop = messageContainer.scrollHeight;
|
384 |
+
|
385 |
+
// Show typing indicator
|
386 |
+
typingIndicator.classList.remove('hidden');
|
387 |
+
messageContainer.scrollTop = messageContainer.scrollHeight;
|
388 |
+
|
389 |
+
// Simulate bot response after delay
|
390 |
+
setTimeout(() => {
|
391 |
+
typingIndicator.classList.add('hidden');
|
392 |
+
|
393 |
+
// In a real app, this would be an API call to your LLM
|
394 |
+
const botResponse = {
|
395 |
+
text: getBotResponse(text),
|
396 |
+
sender: 'them',
|
397 |
+
time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
|
398 |
+
};
|
399 |
+
|
400 |
+
const botMessageElement = document.createElement('div');
|
401 |
+
botMessageElement.className = 'flex justify-start';
|
402 |
+
botMessageElement.innerHTML = `
|
403 |
+
<div class="max-w-xs md:max-w-md lg:max-w-lg px-4 py-2 bg-gray-200 text-gray-800 message-left">
|
404 |
+
<p>${botResponse.text}</p>
|
405 |
+
<p class="text-xs mt-1 text-gray-500">${botResponse.time}</p>
|
406 |
+
</div>
|
407 |
+
`;
|
408 |
+
messages.appendChild(botMessageElement);
|
409 |
+
messageContainer.scrollTop = messageContainer.scrollHeight;
|
410 |
+
}, 1500);
|
411 |
+
}
|
412 |
+
|
413 |
+
// Get bot response from LLM API
|
414 |
+
async function getBotResponse(input, firstName = '') {
|
415 |
+
// Prepare the request payload
|
416 |
+
const requestPayload = {
|
417 |
+
...llmConfig,
|
418 |
+
messages: [
|
419 |
+
...llmConfig.messages,
|
420 |
+
{
|
421 |
+
role: "user",
|
422 |
+
content: input,
|
423 |
+
"First Name": firstName || undefined
|
424 |
+
}
|
425 |
+
]
|
426 |
+
};
|
427 |
+
|
428 |
+
try {
|
429 |
+
// In a real app, this would call your LLM API
|
430 |
+
// For demo, we'll simulate a response
|
431 |
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
432 |
+
|
433 |
+
// Sample responses that match Emma's persona
|
434 |
+
const emmaResponses = [
|
435 |
+
"Lol that's so random! What made you think of that?",
|
436 |
+
"Omg babe you're too sweet π coding rn but wanna chat later?",
|
437 |
+
"Haha I'm such a mess today - spilled coffee on my keyboard again!",
|
438 |
+
"You're cute π what's your favorite Pokemon? Mine's Pikachu!",
|
439 |
+
"Ugh GitHub's acting up again...the struggle is real π
",
|
440 |
+
"Spicy ramen sounds so good rn! You hungry too?",
|
441 |
+
"That's wild! Tell me more cutie π",
|
442 |
+
"LOL same! I'm such a coding nerd sometimes π€",
|
443 |
+
"Wait really? That's actually super interesting!",
|
444 |
+
"Aww thanks babe! You're making me blush βΊοΈ"
|
445 |
+
];
|
446 |
+
|
447 |
+
return emmaResponses[Math.floor(Math.random() * emmaResponses.length)];
|
448 |
+
} catch (error) {
|
449 |
+
console.error('Error calling LLM API:', error);
|
450 |
+
return "Oops! My brain glitched π
Can you say that again?";
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
// Update last refresh time
|
455 |
+
function updateRefreshTime() {
|
456 |
+
const now = new Date();
|
457 |
+
lastRefreshTime.textContent = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
458 |
+
|
459 |
+
// In a real app, this would trigger scraping Instagram DMs
|
460 |
+
// For demo, we'll just reload conversations
|
461 |
+
loadConversations();
|
462 |
+
}
|
463 |
+
|
464 |
+
// Event listeners
|
465 |
+
sendBtn.addEventListener('click', sendMessage);
|
466 |
+
messageInput.addEventListener('keypress', (e) => {
|
467 |
+
if (e.key === 'Enter') sendMessage();
|
468 |
+
});
|
469 |
+
refreshBtn.addEventListener('click', updateRefreshTime);
|
470 |
+
closeSettings.addEventListener('click', () => {
|
471 |
+
settingsModal.classList.add('hidden');
|
472 |
+
});
|
473 |
+
|
474 |
+
// DOM elements
|
475 |
+
const loginModal = document.getElementById('loginModal');
|
476 |
+
const mainApp = document.getElementById('mainApp');
|
477 |
+
const loginBtn = document.getElementById('loginBtn');
|
478 |
+
const igUsername = document.getElementById('igUsername');
|
479 |
+
const igPassword = document.getElementById('igPassword');
|
480 |
+
|
481 |
+
// Login function
|
482 |
+
async function loginToInstagram() {
|
483 |
+
const username = igUsername.value.trim();
|
484 |
+
const password = igPassword.value.trim();
|
485 |
+
|
486 |
+
if (!username || !password) {
|
487 |
+
alert('Please enter both username and password');
|
488 |
+
return;
|
489 |
+
}
|
490 |
+
|
491 |
+
// Show loading state
|
492 |
+
loginBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Logging in...';
|
493 |
+
loginBtn.disabled = true;
|
494 |
+
|
495 |
+
try {
|
496 |
+
// In a real app, this would use Puppeteer or similar to scrape Instagram
|
497 |
+
// For demo, we'll simulate a successful login
|
498 |
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
499 |
+
|
500 |
+
// Hide login, show main app
|
501 |
+
loginModal.classList.add('hidden');
|
502 |
+
mainApp.classList.remove('hidden');
|
503 |
+
|
504 |
+
// Initialize app
|
505 |
+
loadConversations();
|
506 |
+
updateRefreshTime();
|
507 |
+
|
508 |
+
// For demo purposes, load the first conversation
|
509 |
+
if (conversations.length > 0) {
|
510 |
+
loadMessages(conversations[0].id);
|
511 |
+
}
|
512 |
+
} catch (error) {
|
513 |
+
alert('Login failed: ' + error.message);
|
514 |
+
loginBtn.innerHTML = 'Login to Instagram';
|
515 |
+
loginBtn.disabled = false;
|
516 |
+
}
|
517 |
+
}
|
518 |
+
|
519 |
+
// Event listeners
|
520 |
+
loginBtn.addEventListener('click', loginToInstagram);
|
521 |
+
|
522 |
+
// Initialize - show login modal
|
523 |
+
loginModal.classList.remove('hidden');
|
524 |
+
setTimeout(() => {
|
525 |
+
if (conversations.length > 0) {
|
526 |
+
loadMessages(conversations[0].id);
|
527 |
+
}
|
528 |
+
}, 500);
|
529 |
+
</script>
|
530 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 𧬠<a href="https://enzostvs-deepsite.hf.space?remix=TuringsSolutions/instagram-dm-bot" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
531 |
+
</html>
|