alpha-bot-simple 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/chat.js +79 -0
  2. package/package.json +21 -0
package/chat.js ADDED
@@ -0,0 +1,79 @@
1
+
2
+
3
+ class ChatBot {
4
+ constructor(name) {
5
+ this.name = name || "ChatBot";
6
+
7
+ // Default responses
8
+ this.responses = {
9
+ greeting: [
10
+ "Hello!",
11
+ "Hi there!",
12
+ "Greetings!",
13
+ "Hey! How can I help?"
14
+ ],
15
+ farewell: [
16
+ "Goodbye!",
17
+ "See you later!",
18
+ "Bye! Take care!"
19
+ ],
20
+ default: [
21
+ "Interesting!",
22
+ "Tell me more.",
23
+ "I see.",
24
+ "Can you explain further?"
25
+ ]
26
+ };
27
+ }
28
+
29
+ /**
30
+ * Return a random response from a category
31
+ */
32
+ randomResponse(category) {
33
+ const options = this.responses[category] || this.responses.default;
34
+ const index = Math.floor(Math.random() * options.length);
35
+ return options[index];
36
+ }
37
+
38
+ /**
39
+ * Greet a user
40
+ */
41
+ greet(userName) {
42
+ return `${this.randomResponse('greeting')} ${userName || ''}`.trim();
43
+ }
44
+
45
+ /**
46
+ * Farewell message
47
+ */
48
+ farewell(userName) {
49
+ return `${this.randomResponse('farewell')} ${userName || ''}`.trim();
50
+ }
51
+
52
+ /**
53
+ * Respond to a user's message
54
+ */
55
+ ask(message) {
56
+ // You can extend this with AI/NLP logic later
57
+ const lower = message.toLowerCase();
58
+ if (lower.includes('hello') || lower.includes('hi')) {
59
+ return this.randomResponse('greeting');
60
+ } else if (lower.includes('bye') || lower.includes('goodbye')) {
61
+ return this.randomResponse('farewell');
62
+ } else {
63
+ return this.randomResponse('default');
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Add new custom responses
69
+ */
70
+ addResponses(category, responsesArray) {
71
+ if (!this.responses[category]) this.responses[category] = [];
72
+ this.responses[category] = this.responses[category].concat(responsesArray);
73
+ }
74
+ }
75
+
76
+ // Export the chatbot
77
+ module.exports = ChatBot;
78
+
79
+
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "alpha-bot-simple",
3
+ "version": "1.0.0",
4
+ "description": "A simple and customizable ChatBot class for interactive conversations",
5
+ "main": "chat.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": ["chatbot", "chat", "bot", "conversation"],
10
+ "author": "Your Name <your.email@example.com>",
11
+ "license": "ISC",
12
+ "type": "commonjs",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/yourusername/alpha-bot"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/yourusername/alpha-bot/issues"
19
+ },
20
+ "homepage": "https://github.com/yourusername/alpha-bot#readme"
21
+ }