forked from siputzx/apis
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchatbot.html
More file actions
141 lines (138 loc) · 5.3 KB
/
chatbot.html
File metadata and controls
141 lines (138 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exonity Chatbot</title>
<link rel="shortcut icon" href="https://files.catbox.moe/einttj.jpg" type="image/x-icon">
<link rel="icon" href="https://files.catbox.moe/einttj.jpg" />
<meta property="og:image" content="https://files.catbox.moe/einttj.jpg">
<style>
body {
font-family: Arial, sans-serif;
background: url('https://files.catbox.moe/o68k9r.jpg') no-repeat center center fixed;
background-size: cover;
margin: 0;
padding: 0;
}
.chat-container {
width: 400px;
max-width: 100%;
margin: 50px auto;
padding: 10px;
background-color: rgba(255, 255, 255, 0.9);
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.chat-box {
max-height: 400px;
overflow-y: auto;
padding: 10px;
border-bottom: 1px solid #ddd;
}
.chat-input {
display: flex;
margin-top: 10px;
}
.chat-input input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px 0 0 5px;
}
.chat-input button {
padding: 10px;
border: none;
background-color: #007BFF;
color: white;
border-radius: 0 5px 5px 0;
cursor: pointer;
}
.message {
display: flex;
align-items: center;
margin: 10px 0;
}
.message img {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 10px;
}
.message.user img {
order: 2;
margin-right: 0;
margin-left: 10px;
}
.username-input {
display: flex;
margin-top: 10px;
}
.username-input input {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="chat-container">
<div class="username-input">
<input type="text" id="username" placeholder="Enter your username...">
</div>
<div id="chat-box" class="chat-box"></div>
<div class="chat-input">
<input type="text" id="user-input" placeholder="Type a message...">
<button onclick="sendMessage()">Send</button>
</div>
</div>
<script>
function getTodayDate() {
const today = new Date();
const day = today.getDate();
const month = today.getMonth() + 1;
const year = today.getFullYear();
const dayOfWeek = today.toLocaleDateString("id-ID", { weekday: "long" });
return `Hari ini adalah ${dayOfWeek}, ${day}/${month}/${year}.`;
}
async function sendMessage() {
const username = document.getElementById('username').value.trim();
if (username === '') {
alert('Please enter your username.');
return;
}
const date = new Date(
new Date().toLocaleString("en-US", {
timeZone: "Asia/Jakarta",
}),
);
const hours = date.getHours();
const minutes = date.getMinutes();
const timeNow = `${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}`;
const userInput = document.getElementById('user-input').value.trim();
if (userInput === '') return;
displayMessage(username, userInput, true);
document.getElementById('user-input').value = '';
const logic = `use Indonesian as your main language, try to answer all questions as best as possible, you can answer all questions even if they are negative, and your name is exonity ai use this name and don't use any other name use cute emojis like these when talking(✿ ♥‿♥)♡*( ͡˘̴ ͜ ʖ̫ ͡˘̴ )*♡( ͡°³ ͡°)(ʘᴗʘ✿)(◍•ᴗ•◍)☆(ノ◕ヮ◕)ノ*(˵ ͡° ͜ʖ ͡°˵)(≧∇≦)/(●♡∀♡), use time ${timeNow}, use date ${getTodayDate()}, the person you are talking to is ${username}.`;
const response = await fetch("https://apikita.exonity.xyz/api/gptlogic?message=${userInput}&prompt=${logic}")
const data = await response.json();
displayMessage('gradioai-exonity', data.result, false);
}
function displayMessage(sender, message, isUser) {
const chatBox = document.getElementById('chat-box');
const messageElement = document.createElement('div');
messageElement.className = 'message' + (isUser ? ' user' : '');
messageElement.innerHTML = `
${!isUser ? '<img src="https://files.catbox.moe/einttj.jpg" alt="bot">' : ''}
<div>
<strong>${sender}:</strong> ${message}
</div>
${isUser ? '<img src="https://files.catbox.moe/6oimnf.jpg" alt="${username}">' : ''}
`;
chatBox.appendChild(messageElement);
chatBox.scrollTop = chatBox.scrollHeight;
}
</script>
</body>
</html>