Skip to content

Instantly share code, notes, and snippets.

@mzhaodev
Last active May 6, 2016 06:20
Show Gist options
  • Save mzhaodev/be8e576e8856340a734cc2b9b709327c to your computer and use it in GitHub Desktop.
Save mzhaodev/be8e576e8856340a734cc2b9b709327c to your computer and use it in GitHub Desktop.
BotLand
# Emacs recovery files
*~
[#]*[#]
.\#*
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
node_modules
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history

BotLand - A helper-robot for your forum

BotLand is an AoPS chatbot that can do a variety of things.

For information on interacting with the bots, read the list of commands.

To implement these bots on your own AoPS forum, read Implementing BotLand.

To contribute to the code, read CONTRIBUTING.md.

Helpers

Ross Hinkley

Nightmare = require('nightmare');
exports.post = function(username, password, thread, message) {
new Nightmare({show:true})
.goto('http://artofproblemsolving.com/')
.click('#header-login')
.type('#login-username', username)
.type('#login-password', password)
.click('#login-button')
.wait(.evaluate(function(){return user.username}))
.goto(thread)
.wait('div.cmty-post:nth-child(2) > div:nth-child(2) > div:nth-child(1) > div:nth-child(2)')
.click('div.cmty-topic-jump-bottom')
.click('.cmty-topic-mini-reply')
.type('.cmty-post-textarea', message)
.click('div.cmty-posting-environ-buttons:nth-child(2) > input:nth-child(2)')
.end()
.then(function(){
console.log(username + ' posted: ' + message);
});
}
{
"name": "botland",
"version": "0.1.0",
"description": "Chatbots for the MDaoG forum on AoPS",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/thepiercingarrow2/BotLand.git"
},
"keywords": [
"chatbot",
"botland",
"aops"
],
"author": "Mark Wright",
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/thepiercingarrow2/BotLand/issues"
},
"homepage": "https://github.com/thepiercingarrow2/BotLand#readme",
"dependencies": {
"nightmare": "^2.3.4"
}
}
actions = require('./actions.js');
var robot = {
user: process.env.AOPS_ROBOT_USER,
pass: process.env.AOPS_ROBOT_PASS
};
var botland = {
botlandthread: 'http://artofproblemsolving.com/community/c77418h1140059'
};
actions.post(robot.user, robot.pass, botland.botlandthread, 'Hello World');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment