icanhazcode

Like to code?

Latest: join the CodeChallenge group: https://www.icanhazchat.com/group/codechallenge.


Write a bot

There are two different methods for writing a bot - a client-bot that uses the ICHC WebAPI, and a javascript bot that runs in your browser.


Recommended: the ICHC WebAPI

Learn more about it here! https://www.icanhazchat.com/posts/codechallenge/IbpQc/ICHC_Web_API_Information



Older/deprecated: In-browser javascript bot-API for writing in-chat games, etc

You can right-click and save this file to your local drive, to create/debug your own bot: https://www.icanhazchat.com/unittest_game_api.htm

What a bot must implement (required)

    var bot_name
    a global string that describes the bot
    var bot_active
    a global boolean that indicates when the bot is running
    function botStart()
    called when the bot is started. Initialize your data and start interacting with the room here
    function botEnd()
    called when the bot is shutting down (the game is over, etc).

What a bot could implement (optional)

    botProcessLine(who, line)
    If a bot implements this, it will be called every time someone (’who’) sends a message (’line’) to the room
    function botHi(who)
    If a bot implements this, it will be called every time someone enters the room
    function botBye(who)
    If a bot implements this, it will be called every time someone leaves the room
    function botCamUp(who)
    If a bot implements this, it will be called every time someone cams up
    function botCamDown(who)
    If a bot implements this, it will be called every time someone cams down

What is available for a bot to use

    function botSend(s)
    sends the string ’s’ to the room. Currently only text messages (not commands) can be sent. Do not use it to the flood the room.
    function log(s)
    writes the string ’s’ to the javascript console (use ctrl-shift-i then ’console’ to view in Chrome)

When you are ready to run a bot in a room, use the ’/bot-start’ command to added your bot source to the page. You can unload the bot by refreshing the page. Run/test it in small test rooms, get room mods permission before running in larger rooms.

Created something cool? Share it with others by posting it to the ’code codechallenge’ group.








,nevaMXLP,30cfba7f229c452e9866f7d522f30c8c