IntriguingTiles / cleverbot-free

Simple package to interact with the same API that the Cleverbot website uses for free.
MIT License
37 stars 10 forks source link

use yarn and add typings #6

Closed Milo123459 closed 3 years ago

Milo123459 commented 4 years ago

Hello! This is a pull request that add's typings and uses yarn.lock instead of package-lock.json This is mainly focused on typings, but yarn can be seen as a "helpful" addition.

Milo123459 commented 4 years ago

@IntriguingTiles bump

TheEpicFace007 commented 3 years ago

bump. I want this this be added @IntriguingTiles

Milo123459 commented 3 years ago

at least someone cares hahah

TheEpicFace007 commented 3 years ago

@Milo123459 for now what i do is setting the flag allowJs to true on the tsc config file to afterward load the module from a js file. it's far from perfect but it does the job. here is how i do it: ./cleverbot-handler.js:

const cleverbot = require("cleverbot-free")

const CleverBotConvoHistory = [];
const SHOULD_USE_CONVO_HISTORY = true;

async function chat_clever(msg) {

  const answer = await cleverbot(msg, CleverBotConvoHistory);

  if (SHOULD_USE_CONVO_HISTORY)
  {
    CleverBotConvoHistory.push(msg);
    CleverBotConvoHistory.push(answer);
  }

  return answer;
}

export default chat_clever;

index.ts:


import { chat_clever } from "./cleverbo-handler.js";
chat_clever("Hello!").then(console.log)