Coder Social home page Coder Social logo

artofchatbot's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

artofchatbot's Issues

Keep getting "Could not send, waiting 1500." errors

So I run this in the console,

/***********************************
 * StackExchange Chat API version 1.2.0
 * author: ArtOfCode
 * repo: https://github.com/ArtOfCode-/ArtOfChatbot
 ***********************************/

window.chatAPI = {
    injectDependency: function(url, callback) {
        var validator = /^(http|https|ftp):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/;
        var scriptElement = document.createElement("script");
        scriptElement.src = url.match(validator) ? url : "";
        scriptElement.setAttribute("type", "text/javascript");
        scriptElement.addEventListener("load", function() {
            callback();
        });
        document.body.appendChild(scriptElement);
    },

    runChatbot: function() {
        if(!chatbot) {
            throw new Error("Chatbot JS must be loaded first.");
        }
        else {
            chatbot.program.main();
        }
    },

    setChatbotName: function(newName) {
        chatbot.utils.name = newName;
    },

    getChatbotName: function() {
        return chatbot.utils.name;
    },

    getActiveRoomId: function() {
        return chatbot.utils.roomId;
    },

    addChatbotCommand: function(name, action) {
        if(!chatbot) {
            throw new Error("Chatbot JS must be loaded first.");
        }
        else {
            if(typeof(action) === "function") {
                chatbot.commands.commandList[name] = action;
            }
            else {
                throw new TypeError("action must be an invocable function!");
            }
        }
    },

    setCommandPrefix: function(newPrefix) {
        chatbot.utils.commandPrefix = newPrefix;
    },

    getCommandPrefix: function() {
        return chatbot.utils.commandPrefix;
    },

    sendMessage: function(messageText) {
        if(!chatbot || !chatbot.utils.isRunning) {
            throw new Error("Chatbot JS must be loaded and running first.");
        }
        else {
            chatbot.utils.sendMessage(messageText, chatbot.utils.roomId);
        }
    }
};

    chatAPI.injectDependency("http://jenkinsstuff.bl.ee/se.chat/api/bot.js", function() {
        console.log("Chatbot JS is loaded.");
    });

and then this

chatAPI.addChatbotCommand("echo", function(arguments, user) {
    // arguments[0] is the command name. Arguments start at arguments[1].
    if(arguments[1]) {
        chatAPI.sendMessage("@" + user + ": " + arguments[1]);
    }
});

chatAPI.setChatbotName("Tom")

chatAPI.runChatbot()

And it keeps returning this message: "Could not send, waiting 1500."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.