Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

smart-chatbot

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smart-chatbot - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

LICENSE

39

main.js
const axios = require("axios");
const baseURL = "https://api.csycraft.xyz/chatbot";
const baseURL = "https://api.csycraft.xyz/chatbot?";
const version = require('./package.json').version;
const packagename = require('./package.json').name;
class Client {
constructor(secret, botname) {
constructor(secret, botname, logging = false) {
if(logging == true)
console.log(`[${packagename}] Enabling..`);
this.chat = function(json) {
return new Promise((resolve, reject) => {
return new Promise(async(resolve, reject) => {
if(!json.message || typeof json.message !== "string") reject("No message was provided");
if(!json.user || typeof json.user !== "number") json.user = 1;
if(!json.language || typeof json.language !== "string" || (json.language != "tr" && json.language != "en")) json.language = "en";
axios.get(`${baseURL}?message=${encodeURIComponent(json.message)}&user=${encodeURIComponent(json.user)}&botname=${encodeURIComponent(botname)}`, {
let getparams = {
message: json.message,
user: json.user,
language: json.language
};
let params = new URLSearchParams(getparams).toString();
axios.get(String(baseURL) + String(params), {
headers: {
'Authorization': `${secret}`
'Authorization': `${secret}`,
'Version': `${version}`
}

@@ -19,4 +35,7 @@ }).then(x => {

} else {
if(x && x.data && x.data.code && x.data.code == 203) {
resolve("Please Enter Valid Secret Code.")
if (x && x.data && x.data.code && x.data.code == 203) {
resolve("Please Enter Valid Secret Code.");
} else if (x && x.data && x.data.code && x.data.code == 205 && x.data.message) {
console.error(x.data.message);
resolve(x.data.message);
} else {

@@ -29,2 +48,5 @@ reject("No Api message was provided");

}
if(logging == true)
console.log(`[${packagename}] Enabled!`);
}

@@ -34,3 +56,4 @@ }

module.exports = {
Client: Client
Client: Client,
version: version
}
{
"name": "smart-chatbot",
"version": "0.0.4",
"version": "0.0.5",
"description": "Intelligent Chat Bot Api",

@@ -18,6 +18,10 @@ "main": "main.js",

"author": "bucksh0t",
"license": "ISC",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/CsYBot/smart-chatbot/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/CsYBot/smart-chatbot.git"
},
"homepage": "https://github.com/CsYBot/smart-chatbot/issues#readme",

@@ -24,0 +28,0 @@ "dependencies": {

@@ -0,5 +1,8 @@

<p align="center"><a href="https://nodei.co/npm/smart-chatbot"><img src="https://nodei.co/npm/smart-chatbot.png"></a></p>
<p align="center"><img src="https://img.shields.io/npm/v/smart-chatbot?style=for-the-badge"> <img src="https://img.shields.io/github/repo-size/CsYBot/smart-chatbot?style=for-the-badge"> <img src="https://img.shields.io/npm/l/smart-chatbot?style=for-the-badge"> <img src="https://img.shields.io/npm/dt/smart-chatbot?style=for-the-badge"> <img src="https://img.shields.io/github/contributors/CsYBot/smart-chatbot?style=for-the-badge"> <img src="https://img.shields.io/github/package-json/dependency-version/CsYBot/smart-chatbot/axios?style=for-the-badge"> <a href="https://discord.gg/gkmwaAZQBu" target="_blank"> <img alt="Discord" src="https://img.shields.io/badge/CsYBot%20Support-Click%20here-7289d9?style=for-the-badge&logo=discord"> </a></p>
# smart-chatbot
<a href="https://npmjs.com/package/smart-chatbot" rel="nofollow"><img src="https://img.shields.io/npm/dt/smart-chatbot.svg?style=for-the-badge" alt="npm"></a><a href="https://npmjs.com/package/smart-chatbot" rel="nofollow"><img src="https://img.shields.io/npm/v/smart-chatbot.svg?style=for-the-badge" alt="npm"></a>
**Examples:**
**Javascript:**
```js

@@ -9,11 +12,8 @@ const chatbot = require("smart-chatbot");

(async() => {
let reply = await chatclient.chat({
message: "Hello",
user: "1"
});
console.log(reply);
});
chatclient.chat({
message: "Hello",
user: "SECRET USER ID",
language: "tr" // (tr, en)
}).then(answer => console.log);
```
<br>

@@ -20,0 +20,0 @@ **What is SECRET KEY?**

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc