Example #1
0
    def __init__(self, **kwargs):
        from chatterbot.apis.twitter import Twitter

        chatbot = ChatBot()

        if "twitter" in kwargs:
            twitter_bot = Twitter(kwargs["twitter"])

            for mention in twitter_bot.get_mentions():
                '''
                Check to see if the post has been favorited
                We will use this as a check for whether or not to respond to it.
                Only respond to unfavorited mentions.
                '''

                if not mention["favorited"]:
                    screen_name = mention["user"]["screen_name"]
                    text = mention["text"]
                    response = chatbot.get_response(text)

                    print(text)
                    print(response)

                    follow(screen_name)
                    favorite(mention["id"])
                    reply(mention["id"], response)
Example #2
0
    def test_consumer_stored(self):
        TWITTER = {
            "CONSUMER_KEY": "blahblahblah",
            "CONSUMER_SECRET": "nullvoidnullvoidnullvoid"
        }

        chatbot = Twitter(twitter=TWITTER)

        self.assertEqual(TWITTER["CONSUMER_KEY"], chatbot.consumer_key)
        self.assertEqual(TWITTER["CONSUMER_SECRET"], chatbot.consumer_secret)
Example #3
0
app.add_url_rule("/legs/<string:leg_name>/hip/", view_func=Hip.as_view("hip"))
app.add_url_rule("/legs/<string:leg_name>/knee/", view_func=Knee.as_view("knee"))
app.add_url_rule("/legs/<string:leg_name>/ankle/", view_func=Ankle.as_view("ankle"))

app.add_url_rule("/neck/", view_func=Neck.as_view("neck"))
app.add_url_rule("/torso/", view_func=Torso.as_view("torso"))

app.add_url_rule("/api/terminate/",view_func=api.Terminate.as_view("terminate"))
app.add_url_rule("/api/speech/", view_func=api.Speech.as_view("speech"))
app.add_url_rule("/api/writing/", view_func=api.Writing.as_view("writing"))
app.add_url_rule("/api/chat/", view_func=api.Chat.as_view("chat"))
app.add_url_rule("/api/status/", view_func=api.Status.as_view("status"))

if __name__ == "__main__":
    app.config["CHATBOT"] = ChatBot()
    app.config["DATABASE"] = Database("settings.db")
    app.config["DEBUG"] = True
    app.config["SECRET_KEY"] = "development"

    if settings_available:
        if hasattr(settings, "GITHUB"):
            app.config["GITHUB"] = GitHub(settings.GITHUB)
        if hasattr(settings, "TWITTER"):
            app.config["TWITTER"] = Twitter(settings.TWITTER)
        if hasattr(settings, "GOOGLE"):
            app.config["GOOGLE"] = settings.GOOGLE
        if hasattr(settings, "DISQUS"):
            app.config["DISQUS"] = settings.DISQUS

    app.run(host="0.0.0.0", port=8000)