1
0
Fork 0
mirror of https://github.com/1disk/edp445.git synced 2024-08-14 22:47:02 +00:00

Changed alot of things.

This commit is contained in:
koelo 2022-12-03 05:44:44 +00:00
parent a5a0523e5a
commit 3513d5390c
2016 changed files with 336930 additions and 9 deletions

33
node_modules/cleverbot-free/.eslintrc.json generated vendored Normal file
View file

@ -0,0 +1,33 @@
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017
},
"rules": {
"brace-style": "error",
"linebreak-style": [
"error",
"windows"
],
"no-var": "error",
"prefer-const": "error",
"no-console": "off",
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
"yoda": "error",
"eqeqeq": [
"error",
"smart"
]
}
}

View file

@ -0,0 +1,29 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test

21
node_modules/cleverbot-free/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 IntriguingTiles
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

18
node_modules/cleverbot-free/README.md generated vendored Normal file
View file

@ -0,0 +1,18 @@
# cleverbot-free
Simple unofficial package to interact with the same API that the Cleverbot website uses for free.
## **Please use the official Cleverbot API as the Cleverbot developers can easily break this package at any time.**
# Usage
```js
const cleverbot = require("cleverbot-free");
// Without context
cleverbot("Hello.").then(response => /*...*/);
// With context
// Please note that context should include messages sent to Cleverbot as well as the responses
cleverbot("Bad.", ["Hi.", "How are you?"]).then(response => /*...*/);
```
**Typings included**

22
node_modules/cleverbot-free/example.js generated vendored Normal file
View file

@ -0,0 +1,22 @@
const cb = require("./index.js");
const rl = require("readline").createInterface({
input: process.stdin,
output: process.stdout
});
const context = [];
rl.on("line", async line => {
try {
const response = await cb(line, context);
context.push(line);
context.push(response);
console.log(response);
} catch (err) {
console.log(err);
console.log("Failed to get a response!");
}
rl.prompt();
});
rl.prompt();

2
node_modules/cleverbot-free/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,2 @@
declare function cleverbot(stimlus: string, context?: string[], language?: string): Promise<string>;
export default cleverbot;

72
node_modules/cleverbot-free/index.js generated vendored Normal file
View file

@ -0,0 +1,72 @@
const superagent = require("superagent");
const md5 = require("md5");
const userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36";
let cookies;
let cbsid;
let xai;
let lastResponse;
let lastCookieUpdate = 0;
/**
* Sends a mesasage to Cleverbot
* @param {string} stimulus The message to be sent
* @param {string[]?} context An array of previous messages and responses
* @param {string?} language The language of the message (null for auto detect)
* @returns {Promise<string>} The response
*/
module.exports = async (stimulus, context = [], language) => {
const _context = context.slice(); // clone array to prevent subsequent calls from modifying it
if (cookies == null || Date.now() - lastCookieUpdate >= 86400000) {
// we must get the XVIS cookie before we can make requests to the API
const date = new Date();
const req = await superagent.get(`https://www.cleverbot.com/extras/conversation-social-min.js?${date.getFullYear()}${date.getMonth().toString().padStart(2, "0")}${date.getDate().toString().padStart(2, "0")}`).set("User-Agent", userAgent);
cookies = req.header["set-cookie"]; // eslint-disable-line require-atomic-updates
lastCookieUpdate = Date.now();
}
// why, cleverbot, why do you do need me to do this
let payload = `stimulus=${escape(stimulus).includes("%u") ? escape(escape(stimulus).replace(/%u/g, "|")) : escape(stimulus)}&`;
// we're going to assume that the first item in the array is the first message sent
const reverseContext = _context.reverse();
for (let i = 0; i < _context.length; i++) {
// we're going to assume that the context hasn't been escaped
payload += `vText${i + 2}=${escape(reverseContext[i]).includes("%u") ? escape(escape(reverseContext[i]).replace(/%u/g, "|")) : escape(reverseContext[i])}&`;
}
payload += `${language ? `cb_settings_language=${language}&` : ""}cb_settings_scripting=no&islearning=1&icognoid=wsf&icognocheck=`;
payload += md5(payload.substring(7, 33));
for (let i = 0; i < 15; i++) {
try {
const req = await superagent.post(`https://www.cleverbot.com/webservicemin?uc=UseOfficialCleverbotAPI${cbsid ? `&out=${encodeURIComponent(lastResponse)}&in=${encodeURIComponent(stimulus)}&bot=c&cbsid=${cbsid}&xai=${xai}&ns=2&al=&dl=&flag=&user=&mode=1&alt=0&reac=&emo=&sou=website&xed=&` : ""}`)
.timeout({
response: 10000,
deadline: 60000,
})
.set("Cookie", `${cookies[0].split(";")[0]}; _cbsid=-1`)
.set("User-Agent", userAgent)
.type("text/plain")
.send(payload);
cbsid = req.text.split("\r")[1];
xai = `${cbsid.substring(0, 3)},${req.text.split("\r")[2]}`;
lastResponse = req.text.split("\r")[0];
return lastResponse;
} catch (err) {
if (err.status === 503) {
// retry after a bit
await new Promise(resolve => setTimeout(resolve, 1000));
} else {
throw err;
}
}
}
throw "Failed to get a response after 15 tries";
};

30
node_modules/cleverbot-free/package.json generated vendored Normal file
View file

@ -0,0 +1,30 @@
{
"name": "cleverbot-free",
"version": "1.1.11",
"description": "Simple package to interact with the same API that the Cleverbot website uses for free.",
"main": "index.js",
"scripts": {
"test": "node test.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/IntriguingTiles/cleverbot-free.git"
},
"keywords": [
"cleverbot"
],
"author": "IntriguingTiles",
"license": "MIT",
"bugs": {
"url": "https://github.com/IntriguingTiles/cleverbot-free/issues"
},
"homepage": "https://github.com/IntriguingTiles/cleverbot-free#readme",
"dependencies": {
"md5": "^2.3.0",
"superagent": "^7.1.1"
},
"devDependencies": {
"eslint": "^8.10.0"
},
"typings": "index.d.ts"
}

9
node_modules/cleverbot-free/test.js generated vendored Normal file
View file

@ -0,0 +1,9 @@
const cleverbot = require("./index.js");
cleverbot("Hi").then(response => {
console.log(`Response: ${response}`);
process.exit((response) ? 0 : 1);
}).catch(error => {
console.error(error);
process.exit(1);
});