Git Product home page Git Product logo

sh-enl-ingress-intel-chat-bot's Introduction

sh-enl-ingress-intel-chat-bot

An ingress chat bot developed by Shanghai Enlightened, based on ingress/intel.

Features:

  • Send welcome message to new players

  • Respond weather queries (China only)

  • Fetch public activities

  • API to query players' activity from fetched data

  • API to query portals' history (capture/ADA/Jarvis events) from fetched data (experimental)

Dependencies

  • MongoDB

  • Node.js

Bootstrap

  1. Clone repository and submodules

    git clone --recursive https://github.com/breeswish/sh-enl-ingress-intel-chat-bot.git
  2. Configure

    1. Copy config.cson.default to config.cson and modify:

      • Auth.CookieRaw The ingress/intel cookie of the account. Notice: The account can be banned at anytime, so don't use your gaming account here.
      • Database.ConnectString If you have modified MongoDB port or auth settings, or want to use a different database name, please modify this field.
      • Mail.* The bot will send mails to notify you when there are something wrong.
    2. Copy ingress-exporter/config.cson.default to ingress-exporter/config.cson and modify:

      • Region The fetching region. See How to generate polygon data via IITC drawtool. Notice: The polygon region data will be finally simplified to a rectangle in the chat bot, so you needn't drawing polygon very carefully.
      • Database.ConnectString Keep consistent with the ConnectString in config.cson.
  3. Enable your desired plugin in src/plugins/faction, as well as their template files in src/templates (copy, rename, and modify templates optionally)

    • xmorose Used by Shanghai Enlightened only. Template: xmorose.cson.
    • welcome Welcome new agents. Template: welcome.cson.
    • hi Respond hi when receiving hi/hello. Template: hi.cson.
    • ping Respond pong when receiving ping. Template: ping.cson.
    • weather Respond weather forecast and air quality (China only). Template: weather.air.cson, weather.cson.
    • train Train bot. Train Syntax: @bot_name train RegExPattern ResponseString. Cancel Syntax: @bot_name train RegExPattern. Template: train.fail.cson, train.ok.cson, train.remove.cson.
    • fallback Some fallback response (Chinese). Template: none.
    • auth (experimental).
  4. Install modules and compile files

    npm install -g grunt-cli
    npm install
    grunt
    cd ingress-exporter
    npm install
    grunt
    # cd ..

    Notice: You need to run grunt everytime you made changes (enable/disable plugin, modify template, modify config.cson)

  5. Run

    node build/app.js

    Options:

    --auth false         Disable authentication when accessing APIs
    --debug true         Enable debug mode. In debug mode, messages won't be send
                         to real players
    

API

[
    {
        "method": "get",
        "path": "/manage/auth/tokens",
        "desciption": "List all tokens",
        "min_access_level": "LEVEL_ROOT"
    },
    {
        "method": "put",
        "path": "/manage/auth/:player/:level",
        "desciption": "Set access-level of all tokens of an agent",
        "min_access_level": "LEVEL_ROOT"
    },
    {
        "method": "post",
        "path": "/auth/token/:player",
        "desciption": "Generate a new token",
        "min_access_level": "LEVEL_GUEST"
    },
    {
        "method": "get",
        "path": "/auth/token/:token",
        "desciption": "Get detail of a token",
        "min_access_level": "LEVEL_GUEST"
    },
    {
        "method": "get",
        "path": "/help",
        "desciption": "Show help messages",
        "min_access_level": "LEVEL_GUEST"
    },
    {
        "method": "get",
        "path": "/portalhistory/:guid/:mintimestampms",
        "desciption": "Fetch the history of a protal",
        "min_access_level": "LEVEL_TRUSTED"
    },
    {
        "method": "post",
        "path": "/query/:collection",
        "desciption": "Query database",
        "min_access_level": "LEVEL_TRUSTED"
    },
    {
        "method": "get",
        "path": "/tracker/:player/:mintimestampms/:maxtimestampms",
        "desciption": "Track a player",
        "min_access_level": "LEVEL_TRUSTED"
    },
    {
        "method": "get",
        "path": "/tracker/:player/:page",
        "desciption": "Track a player",
        "min_access_level": "LEVEL_TRUSTED"
    }
]

License

The MIT License (MIT)

Copyright (c) 2014 Breezewish

sh-enl-ingress-intel-chat-bot's People

Contributors

breezewish avatar

Watchers

James Cloos avatar  avatar

sh-enl-ingress-intel-chat-bot's Issues

Separation of templates and source code

Feature request:

Separate pattern/response templates and source code. Better to make it possible to update a productive instance to latest version simply by git pull.

BTW I think it is even better to put all pattern/response templates in database, along with privilege control mechanism on create/list/update/delete templates.

Thank you!
MEMEDA

"train" command priority

The "train" command (as well as other commands to be added in the future) should have a higher priority than internal match patterns defined by templates.

e.g.

someone: @bot train testhello 你好
bot: @someone Hi! (ノ*゚ー゚)ノ // or other "你好" responses

Chatbot Crash

Happened 2 times so far, with the same exception.

$ tail -n 20 nohup.out 
2014-07-17T22:34:18.697Z - info: [Broadcasts] Created 1 tasks (all 1 tasks).
2014-07-17T22:34:18.702Z - info: [Broadcasts] Begin requesting...
2014-07-17T22:34:19.580Z - info: [Broadcasts] [Jul 17th, 22:32:17 - Jul 17th, 22:34:18] 100% [1/1] [1/1]    Received 0 (all 0)
2014-07-17T22:34:47.555Z - info: [Faction] Created 1 tasks (all 1 tasks).
2014-07-17T22:34:47.560Z - info: [Faction] Begin requesting...
2014-07-17T22:34:48.409Z - info: [Faction] [Jul 17th, 22:34:15 - Jul 17th, 22:34:47] 100% [1/1] [1/1]   Received 0 (all 0)
2014-07-17T22:35:19.041Z - info: [Faction] Created 1 tasks (all 1 tasks).
2014-07-17T22:35:19.046Z - info: [Faction] Begin requesting...
2014-07-17T22:35:19.993Z - info: [Faction] [Jul 17th, 22:34:47 - Jul 17th, 22:35:19] 100% [1/1] [1/1]   Received 0 (all 0)

child_process.js:945
    throw errnoException(process._errno, 'spawn');
          ^
Error: spawn ENOMEM
    at errnoException (child_process.js:998:11)
    at ChildProcess.spawn (child_process.js:945:11)
    at Object.exports.spawn (child_process.js:733:9)
    at Object.GLOBAL.Bot.exec (/home/pro/sh-enl-ingress-intel-chat-bot/build/lib/bot.js:182:31)
    at GLOBAL.FactionListener.start [as _onTimeout] (/home/pro/sh-enl-ingress-intel-chat-bot/build/lib/faction.js:58:18)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Infinite call loop

When trained with recursive pattern and response, the bot gets itself stuck in infinite call loop.

e.g.

@someone: @bot train @bot @bot
@bot: success!
@someone: @bot @bot
@bot: @someone @bot
@bot: @bot *fallback response*
@bot: @bot *fallback response*
@bot: @bot *fallback response*
...

Cool Idea!

One feature I thought of is forwarding unknown commands to the bot to several players, so if new players talk to the bot thinking that it is a real person, that real people can see the alert.

In-game teaching

Feature request: teaching the chatbot to respond to specific words/patterns with given strings.

bw juju memeda

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.