├── .gitattributes ├── _config.yml ├── .travis.yml ├── Dockerfile ├── .editorconfig ├── lib ├── commands │ ├── help.js │ ├── release.js │ ├── author.js │ ├── decide.js │ ├── time.js │ ├── beer.js │ ├── ismember.js │ ├── pledge.js │ ├── latest.js │ └── confirm.js ├── modules │ └── clapp-discord │ │ ├── package.json │ │ ├── str-en.js │ │ └── index.js ├── code_generator.js ├── cgi_api.js └── index.js ├── test └── index.js ├── docker_rebuild.sh ├── .gitignore ├── gulpfile.js ├── package.json ├── config.example.js ├── README.md └── LICENSE /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-midnight -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - v7 4 | - v6 5 | - v5 6 | - v4 7 | - '0.12' 8 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:latest 2 | 3 | RUN mkdir -p /usr/src/app 4 | 5 | COPY package.json /usr/src/app 6 | 7 | WORKDIR /usr/src/app 8 | RUN npm install 9 | 10 | COPY . /usr/src/app 11 | 12 | CMD [ "node", "./lib/index.js" ] -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | -------------------------------------------------------------------------------- /lib/commands/help.js: -------------------------------------------------------------------------------- 1 | const Clapp = require('../modules/clapp-discord/index'); 2 | 3 | module.exports = new Clapp.Command({ 4 | name: "help", 5 | desc: " ", 6 | fn: (argv, context) => { 7 | return "type --help"; 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('assert'); 4 | var aDAM = require('../lib'); 5 | 6 | describe('aDAM', function () { 7 | it('should have unit test!', function () { 8 | assert(false, 'we expected this package author to add actual unit tests.'); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /lib/commands/release.js: -------------------------------------------------------------------------------- 1 | const Clapp = require('../modules/clapp-discord'); 2 | 3 | module.exports = new Clapp.Command({ 4 | name: "release", 5 | desc: "Find out when Star Citizen will be released.", 6 | fn: (argv, context) => { 7 | return "soon™ https://robertsspaceindustries.com/schedule-report " 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /lib/modules/clapp-discord/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clapp-discord", 3 | "version": "1.1.0", 4 | "description": "An extension of Clapp that overrides the default help generator to be able to show help with the discord markdown", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "dependencies": { 10 | "clapp": "*" 11 | }, 12 | "license": "Apache-2.0" 13 | } 14 | -------------------------------------------------------------------------------- /docker_rebuild.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #setup your config.js BEFORE call this script! 4 | 5 | docker stop janusbot #stop the running container 6 | docker rm janusbot #delete the old container 7 | docker rmi janusbot #delete the old image 8 | 9 | #build a docker image with the current folder && create a container out of it && start the container 10 | docker build -t janusbot . && docker run -tid --name janusbot --restart=always janusbot && docker start janusbot 11 | -------------------------------------------------------------------------------- /lib/modules/clapp-discord/str-en.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | // Help 4 | help_usage: 'Usage: ', 5 | help_command: '(order)', 6 | help_cmd_list: 'Here\'s are orders:', 7 | help_further_help: 'To get further help on a command, type: ', 8 | help_av_args: 'Available arguments', 9 | help_av_options: 'Available options', 10 | help_args_required_optional: 'Arguments in (parenthesis) are required, arguments in [brackets]' 11 | + ' are optional', 12 | 13 | }; 14 | -------------------------------------------------------------------------------- /lib/commands/author.js: -------------------------------------------------------------------------------- 1 | const Clapp = require('../modules/clapp-discord'); 2 | const _ = require('../../node_modules/lodash'); 3 | 4 | module.exports = new Clapp.Command({ 5 | name: "author", 6 | desc: "The real identity of my father", 7 | fn: (argv, context) => { 8 | 9 | try { 10 | return "I was made by the SC Center team, you can visit my childhood house https://starcitizen.center/"; 11 | } catch (err) { 12 | console.error(err); 13 | return "Error inside."; 14 | } 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | config.js 3 | 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | 9 | # Runtime data 10 | pids 11 | *.pid 12 | *.seed 13 | *.pid.lock 14 | 15 | # Directory for instrumented libs generated by jscoverage/JSCover 16 | lib-cov 17 | 18 | # Coverage directory used by tools like istanbul 19 | coverage 20 | 21 | # nyc test coverage 22 | .nyc_output 23 | 24 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 25 | .grunt 26 | 27 | # node-waf configuration 28 | .lock-wscript 29 | 30 | # Compiled binary addons (http://nodejs.org/api/addons.html) 31 | build/Release 32 | 33 | # Dependency directories 34 | node_modules 35 | jspm_packages 36 | 37 | # Optional npm cache directory 38 | .npm 39 | 40 | # Optional eslint cache 41 | .eslintcache 42 | 43 | # Optional REPL history 44 | .node_repl_history 45 | 46 | # Output of 'npm pack' 47 | *.tgz 48 | 49 | # Yarn Integrity file 50 | .yarn-integrity -------------------------------------------------------------------------------- /lib/code_generator.js: -------------------------------------------------------------------------------- 1 | function s4() { 2 | return Math.floor((1 + Math.random()) * 0x10000) 3 | .toString(16) 4 | .substring(1); 5 | } 6 | 7 | module.exports = { 8 | /** 9 | * "true random" one time hash, if you want to use this you need to make your own confirmation system 10 | * keep the code stored in a persistent environment. 11 | * @return {*} 12 | */ 13 | getRandom: function () { 14 | return s4() + s4(); 15 | }, 16 | /** 17 | * Generates a "random" code, based on the current UTC date and the RSI letter characters. 18 | * This way the system is simpler (we don't need to keep a code in the database for X hours. 19 | * @param rsiHandler 20 | * @return {string} 21 | */ 22 | getDaily: function (rsiHandler) { 23 | let dat = new Date(); 24 | let fixedSecret = 931321123 + dat.getUTCFullYear() + dat.getUTCDate(); 25 | let personal = rsiHandler.charCodeAt(0) + rsiHandler.charCodeAt(1); 26 | 27 | return (fixedSecret + personal).toString(16); 28 | } 29 | }; -------------------------------------------------------------------------------- /lib/commands/decide.js: -------------------------------------------------------------------------------- 1 | const Clapp = require('../modules/clapp-discord'); 2 | const _ = require('../../node_modules/lodash'); 3 | 4 | module.exports = new Clapp.Command({ 5 | name: "decide", 6 | desc: "Let Janus decide for you: decide Should I buy another ship?", 7 | fn: (argv, context) => { 8 | 9 | try { 10 | if (context.msg.content.indexOf('?') == -1) { 11 | return 'Is there a question mark?'; 12 | } 13 | 14 | let truly = [ 15 | "Affirmative. :ok_hand: ", 16 | "Definitely. :ok_hand: ", 17 | "Go for it! :ok_hand: " 18 | ]; 19 | let falsy = ["NO! :no_entry_sign: ", "False. :no_entry: ", "No way. :no_entry: "]; 20 | let maybe = ["Haven't decided yet.", "Figure it yourself.", "Return later I'm busy."]; 21 | 22 | let rdm = Math.random(); 23 | if (rdm < 0.45) 24 | return _.sample(truly); 25 | else if (rdm < 0.8) 26 | return _.sample(falsy); 27 | else 28 | return _.sample(maybe); 29 | } catch (err) { 30 | console.error(err); 31 | return "Error inside."; 32 | } 33 | } 34 | }); 35 | -------------------------------------------------------------------------------- /lib/commands/time.js: -------------------------------------------------------------------------------- 1 | const Clapp = require('../modules/clapp-discord/index'); 2 | const moment = require('moment-timezone'); 3 | const _ = require("lodash"); 4 | const cfg = require('../../config.js'); 5 | 6 | 7 | let format = "MMM D, HH:mm ZZ z"; 8 | let rightPad = (s, c, n) => n - s.length > 0 ? s + c.repeat(n - s.length) : s; 9 | 10 | module.exports = new Clapp.Command({ 11 | name: "time", 12 | desc: "The clock around the real verse.", 13 | fn: (argv, context) => { 14 | let utc = moment(); 15 | 16 | //TODO make this work 17 | // if (argv.args["moment"].length > 0) 18 | // utc = moment(argv.args["moment"]); 19 | 20 | let result = "```apache" + 21 | "\n" + rightPad("UTC", " ", 25) + utc.utc().format(format) + ""; 22 | _.each(cfg.timezonesList, (tz) => { 23 | result += "\n" + rightPad(tz.replace("/", "_"), " ", 25) + utc.tz(tz).format(format); 24 | }); 25 | 26 | //TODO add the ingame time, when the devs invent one 27 | result += "\n" + rightPad("Star_Citizen_PU", " ", 25) + "soon™"; 28 | 29 | return result + "```"; 30 | }, 31 | args: [ 32 | // { 33 | // name: 'moment', 34 | // desc: 'A specific moment in time ex: 2014-06-01T12:00:00Z "', 35 | // type: 'string', 36 | // required: false, 37 | // default: "" 38 | // } 39 | ] 40 | }); 41 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var path = require('path'); 3 | var gulp = require('gulp'); 4 | var eslint = require('gulp-eslint'); 5 | var excludeGitignore = require('gulp-exclude-gitignore'); 6 | var mocha = require('gulp-mocha'); 7 | var istanbul = require('gulp-istanbul'); 8 | var nsp = require('gulp-nsp'); 9 | var plumber = require('gulp-plumber'); 10 | 11 | gulp.task('static', function () { 12 | return gulp.src('**/*.js') 13 | .pipe(excludeGitignore()) 14 | .pipe(eslint()) 15 | .pipe(eslint.format()) 16 | .pipe(eslint.failAfterError()); 17 | }); 18 | 19 | gulp.task('nsp', function (cb) { 20 | nsp({package: path.resolve('package.json')}, cb); 21 | }); 22 | 23 | gulp.task('pre-test', function () { 24 | return gulp.src('lib/**/*.js') 25 | .pipe(excludeGitignore()) 26 | .pipe(istanbul({ 27 | includeUntested: true 28 | })) 29 | .pipe(istanbul.hookRequire()); 30 | }); 31 | 32 | gulp.task('test', ['pre-test'], function (cb) { 33 | var mochaErr; 34 | 35 | gulp.src('test/**/*.js') 36 | .pipe(plumber()) 37 | .pipe(mocha({reporter: 'spec'})) 38 | .on('error', function (err) { 39 | mochaErr = err; 40 | }) 41 | .pipe(istanbul.writeReports()) 42 | .on('end', function () { 43 | cb(mochaErr); 44 | }); 45 | }); 46 | 47 | gulp.task('watch', function () { 48 | gulp.watch(['lib/**/*.js', 'test/**'], ['test']); 49 | }); 50 | 51 | gulp.task('prepublish', ['nsp']); 52 | gulp.task('default', ['static', 'test']); 53 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SC-Janus", 3 | "version": "0.0.1-soomTM", 4 | "description": "The frst AI from StarCitizen returns, as a fun discord bot.", 5 | "homepage": "https://github.com/BTooLs/sc-janus", 6 | "author": { 7 | "name": "B3aT - Adrian", 8 | "email": "btools@gmail.com", 9 | "url": "btools.eu" 10 | }, 11 | "files": [ 12 | "lib" 13 | ], 14 | "main": "lib/index.js", 15 | "keywords": [ 16 | "" 17 | ], 18 | "scripts": { 19 | "bot": "node ./lib/index.js", 20 | "prepublish": "gulp prepublish", 21 | "test": "gulp" 22 | }, 23 | "devDependencies": { 24 | "eslint": "^3.1.1", 25 | "eslint-config-xo-space": "^0.15.0", 26 | "gulp": "^3.9.0", 27 | "gulp-eslint": "^3.0.1", 28 | "gulp-exclude-gitignore": "^1.0.0", 29 | "gulp-line-ending-corrector": "^1.0.1", 30 | "gulp-istanbul": "^1.0.0", 31 | "gulp-mocha": "^3.0.1", 32 | "gulp-plumber": "^1.0.0", 33 | "gulp-nsp": "^2.1.0" 34 | }, 35 | "eslintConfig": { 36 | "extends": "xo-space", 37 | "env": { 38 | "mocha": true 39 | } 40 | }, 41 | "repository": "https://github.com/BTooLs/sc-janus", 42 | "license": "MIT", 43 | "dependencies": { 44 | "cheerio": "^0.22.0", 45 | "clapp": "^1.1.1", 46 | "discord.js": "^10.0.1", 47 | "jsonfile": "^2.4.0", 48 | "lodash": "^4.17.2", 49 | "moment-timezone": "^0.5.11", 50 | "node-dijkstra": "^2.3.0", 51 | "request": "^2.79.0", 52 | "request-promise": "^4.1.1" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/commands/beer.js: -------------------------------------------------------------------------------- 1 | const Clapp = require('../modules/clapp-discord/index'); 2 | const rp = require('request-promise'); 3 | const cheerio = require('cheerio'); 4 | 5 | module.exports = new Clapp.Command({ 6 | name: "beer", 7 | desc: "Quench your thirst!", 8 | fn: (argv, context) => { 9 | 10 | try { 11 | let options = { 12 | method: 'GET', 13 | uri: 'https://beeroverip.org/random/' 14 | }; 15 | 16 | return new Promise((fulfill, reject) => { 17 | rp(options).then((asHTML) => { 18 | let response = ""; 19 | 20 | try { 21 | let $ = cheerio.load(asHTML); 22 | let img = $('img', "#drink"); 23 | response = "Here's a ***" + img.attr("alt") + "*** \n" 24 | + img.attr("src"); 25 | 26 | } catch (err2) { 27 | console.error(err2); 28 | response = "Sorry the bar is closed :("; 29 | } 30 | fulfill({ 31 | message: response, 32 | context: context 33 | }); 34 | }).catch(err => { 35 | console.error(err); 36 | reject(err); 37 | }); 38 | }); 39 | } catch (err) { 40 | console.error(err); 41 | return "Error inside :(."; 42 | } 43 | } 44 | }); 45 | 46 | -------------------------------------------------------------------------------- /lib/commands/ismember.js: -------------------------------------------------------------------------------- 1 | //https://robertsspaceindustries.com/citizens/NutCaze/organizations 2 | 3 | const _ = require('../../node_modules/lodash'); 4 | const Clapp = require('../modules/clapp-discord/index'); 5 | const cgi_api = require('../cgi_api'); 6 | 7 | module.exports = new Clapp.Command({ 8 | name: "isMember", 9 | desc: "Confirms that a RSI handler exists and that is part of our organisation.", 10 | fn: (argv, context) => { 11 | try { 12 | let rsi_handler = argv.args["RSIhandler"]; 13 | 14 | //context.respondToUser = context.msg.author; 15 | 16 | return new Promise((fulfill, reject) => { 17 | (cgi_api.isMember(rsi_handler)).then((isMember) => { 18 | if (isMember) { 19 | fulfill({ 20 | message: "Organisation affiliation confirmed. ", 21 | context: context 22 | }); 23 | } else { 24 | fulfill({ 25 | message: "Access denied, cannot confirm organisation affiliation.", 26 | context: context 27 | }); 28 | } 29 | }).catch(err => { 30 | // fulfill("Error " + err); 31 | reject(err); 32 | }); 33 | }); 34 | } catch (err) { 35 | console.error(err); 36 | return "Error inside :(."; 37 | } 38 | }, 39 | args: [ 40 | { 41 | name: 'RSIhandler', 42 | desc: 'A RSI handler', 43 | type: 'string', 44 | required: true, 45 | default: ' ' 46 | } 47 | ] 48 | }); 49 | -------------------------------------------------------------------------------- /lib/cgi_api.js: -------------------------------------------------------------------------------- 1 | const org_url = "https://robertsspaceindustries.com/citizens/%HANDLER%/organizations"; 2 | const check_url = "https://robertsspaceindustries.com/citizens/%HANDLER%"; 3 | const cheerio = require('cheerio'); 4 | const rp = require('request-promise'); 5 | const cfg = require('../config.js'); 6 | 7 | module.exports = { 8 | isMember: function (rsi_handler) { 9 | let options = { 10 | method: 'GET', 11 | uri: org_url.replace("%HANDLER%", rsi_handler) 12 | }; 13 | 14 | return new Promise((fulfill, reject) => { 15 | rp(options).then((response) => { 16 | // console.log(response); 17 | let $ = cheerio.load(response); 18 | let urls = $('.orgs-content .value[href="/orgs/' + cfg.organisationSID + '"]'); 19 | let isTest = urls.length > 0; 20 | 21 | fulfill(isTest); 22 | }).catch(err => { 23 | console.error(err.message); 24 | reject(err); 25 | }); 26 | }); 27 | }, 28 | hasCodeOnProfile: function (rsi_handler, code) { 29 | let options = { 30 | method: 'GET', 31 | uri: check_url.replace("%HANDLER%", rsi_handler) 32 | }; 33 | return new Promise((fulfill, reject) => { 34 | rp(options).then((response) => { 35 | // console.log(response); 36 | let $ = cheerio.load(response); 37 | let bio = $('.entry.bio'); 38 | // console.log(urls); 39 | let hasCode = bio != null && bio.html() != null && 40 | bio.html().indexOf(code) > -1; 41 | 42 | if (hasCode == false) { 43 | console.log("bio found but no code " + bio.html()); 44 | } 45 | fulfill(hasCode); 46 | }).catch(err => { 47 | console.error(err); 48 | reject(err); 49 | }); 50 | }); 51 | } 52 | }; 53 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const Clapp = require('./modules/clapp-discord'); 5 | const cfg = require('../config.js'); 6 | const pkg = require('../package.json'); 7 | const Discord = require('discord.js'); 8 | const bot = new Discord.Client(); 9 | 10 | const app = new Clapp.App({ 11 | name: cfg.name, 12 | desc: pkg.description, 13 | prefix: cfg.prefix, 14 | version: pkg.version, 15 | separator: cfg.prefixSeparator, 16 | onReply: (msg, context) => { 17 | try { 18 | if (cfg.deleteAfterReply.enabled && context.isDM == false) { 19 | if (context.msg.deletable) 20 | context.msg.delete(cfg.deleteAfterReply.time) 21 | .then(msg => console.log(`Deleted message from ${msg.author}`)) 22 | .catch(console.error); 23 | } 24 | 25 | //if we must reply as a direct message 26 | if (cfg.replyToDM) { 27 | context.msg.author.sendMessage('\n' + msg); 28 | } else if (context.respondToUser) { 29 | //each Command can force the message to be a DM, to a specific user 30 | context.respondToUser.sendMessage('\n' + msg); 31 | } else { 32 | //default behaviour, reply in the same context the command arrived 33 | context.msg.reply('\n' + msg).then(bot_response => { 34 | 35 | }).catch((err) => { 36 | console.error(err); 37 | }); 38 | } 39 | } catch (err) { 40 | console.error(err); 41 | } 42 | } 43 | }); 44 | 45 | // Load every command in the commands folder 46 | fs.readdirSync('./lib/commands/').forEach(file => { 47 | app.addCommand(require("./commands/" + file)); 48 | }); 49 | 50 | bot.on('message', msg => { 51 | // Fired when someone sends a message, on any text channel or as DM 52 | try { 53 | if (app.isCliSentence(msg.content)) { 54 | app.parseInput(msg.content, { 55 | msg: msg, 56 | //some helpers added for future laziness 57 | discord: bot, 58 | isDM: msg.channel.type == "dm", 59 | sender: msg.user, 60 | // Keep adding properties to the context as you need them 61 | }); 62 | } 63 | } catch (err) { 64 | console.error(err); 65 | } 66 | }); 67 | 68 | bot.login(cfg.token).then(() => { 69 | bot.user.setUsername(cfg.botNickname); 70 | bot.user.setGame(cfg.botGame, ""); 71 | console.log('Running!'); 72 | }).catch((err) => { 73 | console.error(err); 74 | }); 75 | 76 | -------------------------------------------------------------------------------- /config.example.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | // Your bot name. Typically, this is your bot's username without the discriminator. 4 | // i.e: if your bot's username is MemeBot#0420, then this option would be MemeBot. 5 | name: "Janus", 6 | 7 | // The bot's command prefix. The bot will recognize as command any message that begins with it. 8 | // i.e: "!Janus foo" or "!foo" will trigger the command "foo", 9 | // whereas "Janus foo" will do nothing at all. 10 | prefix: "!", 11 | 12 | //Add here a space if you want your commands to be like "! command" instead of "!command" 13 | prefixSeparator: "", 14 | 15 | // Your bot's user token. If you don't know what that is, go here: 16 | // https://discordapp.com/developers/applications/me 17 | // Then create a new application and grab your token. 18 | token: "", 19 | 20 | // If this option is enabled, the bot will delete the message that triggered it, and its own 21 | // response, after the specified amount of time has passed. 22 | // Enable this if you don't want your channel to be flooded with bot messages. 23 | // ATTENTION! In order for this to work, you need to give your bot the following permission: 24 | // MANAGE_MESSAGES - 0x00002000 25 | // More info: https://discordapp.com/developers/docs/topics/permissions 26 | deleteAfterReply: { 27 | enabled: true, 28 | time: 5 * 1000, // In milliseconds 29 | }, 30 | // If true, the bot will always respond to commands in private messages. 31 | //This way you ensure that the commands are not poluting the public channels. 32 | //If set to false, only SOME commands results will be sent to private like Confirm or Latest. 33 | replyToDM: false, 34 | 35 | //confirm feature will add the roleName to the user on the serverID 36 | confirm_data: { 37 | //discord server ID 38 | serverId: "1111111111", 39 | //the role to add 40 | roleName: "member", 41 | }, 42 | //This is your organisation Spectrum Identification (SID) 43 | //https://robertsspaceindustries.com/orgs/SID 44 | organisationSID: "myorg", 45 | //the /time command will list the current hour for all these timezones (UTC is always included) 46 | //put here the most popular timezones from your organisation 47 | timezonesList: [ 48 | "America/Los_Angeles", 49 | "America/New_York", 50 | "Europe/London", 51 | "Europe/Bucharest", 52 | "Asia/Moscow", 53 | "Asia/Tokyo", 54 | "Australia/Sydney", 55 | ], 56 | //the bot can change his own nickname, if allowed, at connect 57 | //usefull only when you do not have permissions to change its nickname as admin 58 | botNickname: "Janus-AI", 59 | //a text that will be displayed under its nickanme (Currently playing .... game ) 60 | //you can put a funny message or propaganda 61 | botGame: 'DM: $ --help. Our bot!' 62 | }; 63 | -------------------------------------------------------------------------------- /lib/commands/pledge.js: -------------------------------------------------------------------------------- 1 | const Clapp = require('../modules/clapp-discord/index'); 2 | let cached = undefined; 3 | const cacheTTL = 60 * 1000;//seconds * ms 4 | const rp = require('request-promise'); 5 | 6 | 7 | module.exports = new Clapp.Command({ 8 | name: "pledge", 9 | desc: "Basic stats on SC/SQ42 funding campaign", 10 | fn: (argv, context) => { 11 | 12 | try { 13 | if (typeof(cached) != "undefined") { 14 | return { 15 | message: cached, 16 | context: context 17 | }; 18 | } 19 | 20 | //https://robertsspaceindustries.com/api/stats/getCrowdfundStats 21 | let options = { 22 | method: 'POST', 23 | json: true, 24 | uri: 'https://robertsspaceindustries.com/api/stats/getCrowdfundStats', 25 | headers: { 26 | "Origin": "https://robertsspaceindustries.com", 27 | "content-type": "application/json", 28 | }, body: {"chart": "month", "fans": true, "funds": true, "alpha_slots": true, "fleet": true} 29 | }; 30 | 31 | return new Promise((fulfill, reject) => { 32 | rp(options).then((asJson) => { 33 | let funds = "-1"; 34 | try { 35 | funds = parseInt(asJson.data.funds / 100);//they included the decimals too 36 | } catch (err) { 37 | console.error(asJson); 38 | console.error(err); 39 | reject(err); 40 | } 41 | 42 | // Create our number formatter. 43 | let formatter = new Intl.NumberFormat('en-US', { 44 | style: 'currency', 45 | currency: 'USD', 46 | minimumFractionDigits: 0, 47 | }); 48 | let regular = new Intl.NumberFormat('en-US', { 49 | minimumFractionDigits: 0, 50 | }); 51 | 52 | funds = formatter.format(funds); 53 | 54 | cached = "```css\nSo far CGI {raised: " + funds + "USD; from: " 55 | + regular.format(asJson.data.fans) + "_fans;combined_fleet_of: " 56 | + regular.format(asJson.data.fleet) + "_ships;}```"; 57 | 58 | setTimeout(() => { 59 | cached = undefined; 60 | }, cacheTTL); 61 | 62 | fulfill({ 63 | message: cached, 64 | context: context 65 | }); 66 | }).catch(err => { 67 | reject(err); 68 | }); 69 | }); 70 | } catch (err) { 71 | console.error(err); 72 | return "Error inside :(."; 73 | } 74 | } 75 | }); 76 | 77 | -------------------------------------------------------------------------------- /lib/commands/latest.js: -------------------------------------------------------------------------------- 1 | const Clapp = require('../modules/clapp-discord'); 2 | const _ = require('../../node_modules/lodash'); 3 | const rp = require('request-promise'); 4 | //https://github.com/request/request-promise 5 | 6 | //each request must be cached, because is a slow operation 7 | let cached = {}; 8 | const cacheTTL = 15 * 1000;//seconds * ms 9 | 10 | function parseBeautify(argv, jsonResponse) { 11 | let result = ""; 12 | let source = argv.args.source; 13 | 14 | try { 15 | if (source == "reddit") { 16 | _.each(jsonResponse.data.children, (post) => { 17 | if (post.data.stickied == true) 18 | return true; 19 | 20 | result += "\n" + post.data.title + ": " + post.data.url; 21 | }); 22 | } 23 | } catch (ex) { 24 | result = "Error at parse." 25 | } 26 | 27 | return result; 28 | } 29 | 30 | module.exports = new Clapp.Command({ 31 | name: "latest", 32 | desc: "Bring you the latest: reddit|hotties", 33 | fn: (argv, context) => { 34 | 35 | try { 36 | let options = { 37 | method: 'GET', 38 | json: true 39 | }; 40 | 41 | switch (argv.args.source) { 42 | case "reddit": 43 | options.uri = 'http://www.reddit.com/r/starcitizen/.json'; 44 | options.qs = { 45 | "sort": "new", "limit": 5 46 | }; 47 | break; 48 | default: 49 | return "Not implemented (yet, bring some beers to the devs)."; 50 | break; 51 | } 52 | //we always force this Command to respond in private, is a shit long message of previews 53 | context.respondToUser = context.msg.author; 54 | 55 | let source = argv.args.source; 56 | if (typeof(cached[source]) != "undefined") { 57 | return { 58 | message: cached[source], 59 | context: context 60 | }; 61 | } 62 | 63 | return new Promise((fulfill, reject) => { 64 | rp(options).then((response) => { 65 | cached[source] = parseBeautify(argv, response); 66 | setTimeout(() => { 67 | cached[source] = undefined; 68 | }, cacheTTL); 69 | 70 | fulfill({ 71 | message: cached[source], 72 | context: context 73 | }); 74 | }).catch(err => { 75 | reject(err); 76 | }); 77 | }); 78 | } catch (err) { 79 | console.error(err); 80 | return "Error inside :(."; 81 | } 82 | }, args: [ 83 | { 84 | name: 'source', 85 | desc: 'One of reddit|hotties', 86 | type: 'string', 87 | required: false, 88 | default: 'reddit' 89 | } 90 | ], 91 | }); 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # StarCitizen Janus - private discord version 2 | Janus is a funny discord bot, made specific for private organisations. 3 | If your org has a discord server you can use Janus to entertain your members or do boring admin tasks. 4 | 5 | Built with love for SC community by [http://StarCitizen.center]. 6 | 7 | ## Features 8 | * custom command prefix (usefull when you already have a bot with "!") 9 | * easy to setup (only a config file) 10 | * auto delete commands and replies - keep your public channels clean 11 | * accept commands on private messages and public text channels 12 | * responds as private message - global and per command option 13 | * custom name - if you don't like Janus, you can change it 14 | * commands with multiple parameters and/or flags 15 | 16 | ## Commands 17 | * **isMember**: Confirms that a RSI handler exists and that is part of our organisation 18 | * **confirm**: Allow your users to confirm their affiliation to your organisation and automatically add your Membership discord role. 19 | * **beer**: Any user can order a free random beer, it replies with a random real-life beer name and image using https://beeroverip.org/random/ 20 | * **decide**: Allow your members to take decisions, they ask a question and the bot replies with (yes 40%, no 40%, maybe 10% chance). 21 | * **latest**: Returns the latest 5 reddit posts from /r/starcitizen Works great with the Discord preview thumbnails. 22 | * **pledge**: Fetch the latest CIG pledge details like Funds raised so far, number of pledgers and their ship bought count. 23 | * **time**: Returns the current time for multiple timezones (customizable list). 24 | * **release**: Returns the release date for StarCitizen. 25 | * **author**: A small token of appreciation to the original author. 26 | * **your-command**: add a new .js file in /lib/commands folder. 27 | 28 | ## Video trailer and live demo 29 | [![trailer logo](http://maintenance.starcitizen.center/media/posters/SCJanus.jpg)](https://youtu.be/POPMwX80AX8) 30 | 31 | # Technical 32 | 33 | ## Details 34 | * needs minimal technical knowledge to setup (bash, json) 35 | * built as a node.js app 36 | * script to run it inside a docker (recommended) 37 | * easy to extend - add new commands as simple as adding a new file 38 | * uses https://github.com/mellamopablo/clapp and https://github.com/hydrabolt/discord.js 39 | 40 | 41 | ## Setup 42 | 1. Make a bot app on discord and get it's token 43 | 2. Make a discord server 44 | 3. Invite the bot on your discord Ex: https://discordapp.com/oauth2/authorize?&client_id=111111111111&scope=bot&permissions=0 (you need to be a moderator/admin) 45 | 46 | *Note: I recommend to make a new bot and server for testing/development process.* 47 | 48 | ## Tech setup 49 | 1. Clone this repo 50 | 2. Make a config and populate it 51 | ```bash 52 | cp config.example.js config.js 53 | vim config.js 54 | ``` 55 | 3. Install the dependencies 56 | ```bash 57 | npm install --production 58 | ``` 59 | 4. Run the bot (see below) 60 | 61 | 62 | *Note: DO not run multiple instances with the same config file, the universe will explode.* 63 | 64 | If you have trouble with the Discord website you can follow this tutorial [https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token] 65 | 66 | ### Run as local process 67 | 68 | ```bash 69 | node ./lib/index.js 70 | ``` 71 | 72 | ### Run it as a Docker container 73 | Requires Docker to be installed locally. 74 | 75 | ```bash 76 | chmod +x *.sh 77 | ./docker_rebuild.sh 78 | #see the errors 79 | docker logs -f janusbot 80 | ``` 81 | 82 | # Thanks 83 | If you appreciate and use my work see more on [http://StarCitizen.center] and consider giving credits (back link) and making a donation. 84 | -------------------------------------------------------------------------------- /lib/modules/clapp-discord/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const Clapp = require('clapp') 4 | , Table = require('cli-table2') 5 | , str = require('./str-en.js'); 6 | 7 | class App extends Clapp.App { 8 | constructor(options) { 9 | super(options); 10 | } 11 | 12 | _getHelp() { 13 | const LINE_WIDTH = 175; 14 | 15 | var r = 16 | this.name + (typeof this.version !== 'undefined' ? ' v' + this.version : '') + '\n' + 17 | this.desc + '\n\n' + 18 | 19 | str.help_usage + this.prefix + this.separator + str.help_command + '\n\n' + 20 | 21 | str.help_cmd_list + '\n\n' 22 | ; 23 | 24 | // Command list 25 | var table = null; 26 | try { 27 | table = new Table({ 28 | chars: { 29 | 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '', 'bottom': '' , 30 | 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': '', 'left': '' , 31 | 'left-mid': '' , 'mid': '' , 'mid-mid': '', 'right': '' , 'right-mid': '' , 32 | 'middle': '' 33 | }, 34 | colWidths: [ 35 | Math.round(0.15*LINE_WIDTH), // We round it because providing a decimal number would 36 | Math.round(0.65*LINE_WIDTH) // break cli-table2 37 | ], 38 | wordWrap: true 39 | }); 40 | 41 | for (var i in this.commands) { 42 | if(typeof(this.commands[i]) == "undefined"){ 43 | continue; 44 | } 45 | table.push([i, this.commands[i].desc]); 46 | } 47 | } catch(err){ 48 | console.error(err); 49 | console.log(table); 50 | } 51 | 52 | try { 53 | r += 54 | '```' + table.toString() + '```\n\n' + 55 | str.help_further_help + this.prefix + ' ' + str.help_command + ' --help' 56 | ; 57 | } catch (err){ 58 | console.error(err); 59 | console.log(table); 60 | } 61 | 62 | return r; 63 | } 64 | } 65 | 66 | class Command extends Clapp.Command { 67 | constructor(options) { 68 | super(options); 69 | } 70 | 71 | _getHelp(app) { 72 | const LINE_WIDTH = 175; 73 | 74 | var r = str.help_usage + ' ' + app.prefix + ' ' + this.name; 75 | 76 | // Add every argument to the usage (Only if there are arguments) 77 | if (Object.keys(this.args).length > 0) { 78 | var args_table = new Table({ 79 | chars: { 80 | 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '', 'bottom': '' , 81 | 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': '', 'left': '' , 82 | 'left-mid': '' , 'mid': '' , 'mid-mid': '', 'right': '' , 'right-mid': '' , 83 | 'middle': '' 84 | }, 85 | head: ['Argument', 'Description', 'Default'], 86 | colWidths: [ 87 | Math.round(0.10*LINE_WIDTH), 88 | Math.round(0.45*LINE_WIDTH), 89 | Math.round(0.25*LINE_WIDTH) 90 | ], 91 | wordWrap: true 92 | }); 93 | for (var i in this.args) { 94 | r += this.args[i].required ? ' (' + i + ')' : ' [' + i + ']'; 95 | args_table.push([ 96 | i, 97 | typeof this.args[i].desc !== 'undefined' ? 98 | this.args[i].desc : '', 99 | typeof this.args[i].default !== 'undefined' ? 100 | this.args[i].default : '' 101 | ]); 102 | } 103 | } 104 | 105 | r += '\n' + this.desc; 106 | 107 | if (Object.keys(this.args).length > 0) 108 | r += '\n\n' + str.help_av_args + ':\n\n```' + args_table.toString() + '```'; 109 | 110 | // Add every flag, only if there are flags to add 111 | if (Object.keys(this.flags).length > 0) { 112 | var flags_table = new Table({ 113 | chars: { 114 | 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '', 'bottom': '' , 115 | 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': '', 'left': '' , 116 | 'left-mid': '' , 'mid': '' , 'mid-mid': '', 'right': '' , 'right-mid': '' , 117 | 'middle': '' 118 | }, 119 | head: ['Option', 'Description', 'Default'], 120 | colWidths: [ 121 | Math.round(0.10*LINE_WIDTH), 122 | Math.round(0.45*LINE_WIDTH), 123 | Math.round(0.25*LINE_WIDTH) 124 | ], 125 | wordWrap: true 126 | }); 127 | for (i in this.flags) { 128 | flags_table.push([ 129 | (typeof this.flags[i].alias !== 'undefined' ? 130 | '-' + this.flags[i].alias + ', ' : '') + '--' + i, 131 | typeof this.flags[i].desc !== 'undefined' ? 132 | this.flags[i].desc : '', 133 | typeof this.flags[i].default !== 'undefined' ? 134 | this.flags[i].default : '' 135 | ]); 136 | } 137 | 138 | r += '\n\n' + str.help_av_options + ':\n\n```' + flags_table.toString() + '```'; 139 | } 140 | 141 | if (Object.keys(this.args).length > 0) 142 | r += '\n\n' + str.help_args_required_optional; 143 | 144 | return r; 145 | } 146 | } 147 | 148 | module.exports = { 149 | App: App, 150 | Argument: Clapp.Argument, 151 | Command: Command, 152 | Flag: Clapp.Flag 153 | }; 154 | -------------------------------------------------------------------------------- /lib/commands/confirm.js: -------------------------------------------------------------------------------- 1 | //https://robertsspaceindustries.com/citizens/ExampleHandler/organizations 2 | 3 | const _ = require('../../node_modules/lodash'); 4 | const Clapp = require('../modules/clapp-discord/index'); 5 | const cgi_api = require('../cgi_api'); 6 | const code_generator = require('../code_generator'); 7 | const cfg = require('../../config.js'); 8 | 9 | 10 | let success_code_str = "Congrats, we verified your account. You can remove the code now."; 11 | let success_failed_add = "We verified your account, but there was an error adding your membership role"; 12 | let failed_code_str = "We need to confirm your account, please add this code %CODE% " 13 | + " to your 'Short Bio' field here https://robertsspaceindustries.com/account/profile and then repeat this command."; 14 | let already_str = "You already are a proud member!"; 15 | 16 | module.exports = new Clapp.Command({ 17 | name: "confirm", 18 | desc: "Confirm your organisation membership and get your discord member role.", 19 | fn: (argv, context) => { 20 | try { 21 | let rsi_handler = argv.args["RSIhandler"]; 22 | 23 | //if is already a test, nothing to confirm 24 | if (hasMemberRole(context.discord, context.msg.author)) { 25 | return already_str; 26 | } 27 | 28 | //the bot replies make no sense on a public chat 29 | context.respondToUser = context.msg.author; 30 | let code = code_generator.getDaily(rsi_handler); 31 | 32 | //TODO refactor - use promises correctly 33 | return new Promise((fulfill, reject) => { 34 | (cgi_api.isMember(rsi_handler)).then((isMember) => { 35 | if (isMember) { 36 | 37 | (cgi_api.hasCodeOnProfile(rsi_handler, code)).then((hasCode) => { 38 | if (hasCode) { 39 | 40 | addMemberRole(context.discord, context.msg.author) 41 | .then(roleWasAdded => { 42 | 43 | if (roleWasAdded) { 44 | fulfill({ 45 | message: success_code_str, 46 | context: context 47 | }); 48 | } else { 49 | fulfill({ 50 | message: success_failed_add, 51 | context: context 52 | }); 53 | } 54 | }).catch(err2 => { 55 | console.error(err2); 56 | fulfill({ 57 | message: success_failed_add, 58 | context: context 59 | }); 60 | }); 61 | 62 | } else { 63 | fulfill({ 64 | message: failed_code_str.replace('%CODE%', code), 65 | context: context 66 | }); 67 | } 68 | }) 69 | 70 | } else { 71 | fulfill({ 72 | message: "You must be a public member of our organisation.", 73 | context: context 74 | }); 75 | } 76 | }).catch(err => { 77 | // fulfill("Error " + err); 78 | reject(err); 79 | }); 80 | }); 81 | } catch (err) { 82 | console.error(err); 83 | return "Error inside :(."; 84 | } 85 | }, 86 | args: [ 87 | { 88 | name: 'RSIhandler', 89 | desc: 'Your StarCitizen handler', 90 | type: 'string', 91 | required: true, 92 | default: ' ' 93 | } 94 | ] 95 | }); 96 | 97 | /** 98 | * Adds your organisation member role to an discord user. 99 | * @param discordClient 100 | * @param discordUser 101 | * @return {Promise} Promise 102 | */ 103 | function addMemberRole(discordClient, discordUser) { 104 | return new Promise((fulfill, reject) => { 105 | let discordServer = discordClient.guilds.get(cfg.confirm_data.serverId); 106 | 107 | if (discordServer == null || discordServer.available == false) { 108 | reject("Cannot find guild/server " + cfg.confirm_data.serverId); 109 | return; 110 | } 111 | 112 | let memberRole = discordServer.roles.find(val => val.name == cfg.confirm_data.roleName); 113 | 114 | if (memberRole == null) { 115 | reject("Cannot find the role " + cfg.confirm_data.roleName); 116 | return; 117 | } 118 | 119 | let asGuildMember = discordServer.members.get(discordUser.id); 120 | 121 | if (asGuildMember == null) { 122 | reject("Cannot find you as an user of discord " + discordServer.name); 123 | return; 124 | } 125 | 126 | asGuildMember.addRole(memberRole).then((guildMember) => { 127 | let newRole = guildMember.roles.find(role => role.id == memberRole.id); 128 | fulfill(newRole != null); 129 | }).catch(err => { 130 | reject(err); 131 | }); 132 | }); 133 | } 134 | 135 | /** 136 | * Checks if a specific discord user already has the member role. 137 | * @param discordClient 138 | * @param discordUser 139 | * @return {boolean} 140 | */ 141 | function hasMemberRole(discordClient, discordUser) { 142 | try { 143 | let discordServer = discordClient.guilds.get(cfg.confirm_data.serverId); 144 | 145 | if (discordServer == null || discordServer.available == false) { 146 | return false; 147 | } 148 | 149 | let testRole = discordServer.roles.find(val => val.name == cfg.confirm_data.roleName); 150 | 151 | if (testRole == null) { 152 | return false; 153 | } 154 | 155 | let asGuildMember = discordServer.members.get(discordUser.id); 156 | 157 | if (asGuildMember == null) { 158 | return false; 159 | } 160 | 161 | let newRole = asGuildMember.roles.find(role => role.id == testRole.id); 162 | 163 | return newRole != null; 164 | } catch (err) { 165 | console.error(err); 166 | return false; 167 | } 168 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | <<<<<<< HEAD 3 | <<<<<<< HEAD 4 | Version 2, June 1991 5 | 6 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 7 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 8 | ======= 9 | Version 3, 29 June 2007 10 | 11 | Copyright (C) 2007 Free Software Foundation, Inc. 12 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 13 | ======= 14 | Version 3, 29 June 2007 15 | 16 | Copyright (C) 2007 Free Software Foundation, Inc. 17 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 18 | Everyone is permitted to copy and distribute verbatim copies 19 | of this license document, but changing it is not allowed. 20 | 21 | Preamble 22 | 23 | <<<<<<< HEAD 24 | <<<<<<< HEAD 25 | The licenses for most software are designed to take away your 26 | freedom to share and change it. By contrast, the GNU General Public 27 | License is intended to guarantee your freedom to share and change free 28 | software--to make sure the software is free for all its users. This 29 | General Public License applies to most of the Free Software 30 | Foundation's software and to any other program whose authors commit to 31 | using it. (Some other Free Software Foundation software is covered by 32 | the GNU Lesser General Public License instead.) You can apply it to 33 | ======= 34 | ======= 35 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 36 | The GNU General Public License is a free, copyleft license for 37 | software and other kinds of works. 38 | 39 | The licenses for most software and other practical works are designed 40 | to take away your freedom to share and change the works. By contrast, 41 | the GNU General Public License is intended to guarantee your freedom to 42 | share and change all versions of a program--to make sure it remains free 43 | software for all its users. We, the Free Software Foundation, use the 44 | GNU General Public License for most of our software; it applies also to 45 | any other work released this way by its authors. You can apply it to 46 | <<<<<<< HEAD 47 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 48 | ======= 49 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 50 | your programs, too. 51 | 52 | When we speak of free software, we are referring to freedom, not 53 | price. Our General Public Licenses are designed to make sure that you 54 | have the freedom to distribute copies of free software (and charge for 55 | <<<<<<< HEAD 56 | <<<<<<< HEAD 57 | this service if you wish), that you receive source code or can get it 58 | if you want it, that you can change the software or use pieces of it 59 | in new free programs; and that you know you can do these things. 60 | 61 | To protect your rights, we need to make restrictions that forbid 62 | anyone to deny you these rights or to ask you to surrender the rights. 63 | These restrictions translate to certain responsibilities for you if you 64 | distribute copies of the software, or if you modify it. 65 | 66 | For example, if you distribute copies of such a program, whether 67 | gratis or for a fee, you must give the recipients all the rights that 68 | you have. You must make sure that they, too, receive or can get the 69 | source code. And you must show them these terms so they know their 70 | rights. 71 | 72 | We protect your rights with two steps: (1) copyright the software, and 73 | (2) offer you this license which gives you legal permission to copy, 74 | distribute and/or modify the software. 75 | 76 | Also, for each author's protection and ours, we want to make certain 77 | that everyone understands that there is no warranty for this free 78 | software. If the software is modified by someone else and passed on, we 79 | want its recipients to know that what they have is not the original, so 80 | that any problems introduced by others will not reflect on the original 81 | authors' reputations. 82 | 83 | Finally, any free program is threatened constantly by software 84 | patents. We wish to avoid the danger that redistributors of a free 85 | program will individually obtain patent licenses, in effect making the 86 | program proprietary. To prevent this, we have made it clear that any 87 | patent must be licensed for everyone's free use or not licensed at all. 88 | ======= 89 | ======= 90 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 91 | them if you wish), that you receive source code or can get it if you 92 | want it, that you can change the software or use pieces of it in new 93 | free programs, and that you know you can do these things. 94 | 95 | To protect your rights, we need to prevent others from denying you 96 | these rights or asking you to surrender the rights. Therefore, you have 97 | certain responsibilities if you distribute copies of the software, or if 98 | you modify it: responsibilities to respect the freedom of others. 99 | 100 | For example, if you distribute copies of such a program, whether 101 | gratis or for a fee, you must pass on to the recipients the same 102 | freedoms that you received. You must make sure that they, too, receive 103 | or can get the source code. And you must show them these terms so they 104 | know their rights. 105 | 106 | Developers that use the GNU GPL protect your rights with two steps: 107 | (1) assert copyright on the software, and (2) offer you this License 108 | giving you legal permission to copy, distribute and/or modify it. 109 | 110 | For the developers' and authors' protection, the GPL clearly explains 111 | that there is no warranty for this free software. For both users' and 112 | authors' sake, the GPL requires that modified versions be marked as 113 | changed, so that their problems will not be attributed erroneously to 114 | authors of previous versions. 115 | 116 | Some devices are designed to deny users access to install or run 117 | modified versions of the software inside them, although the manufacturer 118 | can do so. This is fundamentally incompatible with the aim of 119 | protecting users' freedom to change the software. The systematic 120 | pattern of such abuse occurs in the area of products for individuals to 121 | use, which is precisely where it is most unacceptable. Therefore, we 122 | have designed this version of the GPL to prohibit the practice for those 123 | products. If such problems arise substantially in other domains, we 124 | stand ready to extend this provision to those domains in future versions 125 | of the GPL, as needed to protect the freedom of users. 126 | 127 | Finally, every program is threatened constantly by software patents. 128 | States should not allow patents to restrict development and use of 129 | software on general-purpose computers, but in those that do, we wish to 130 | avoid the special danger that patents applied to a free program could 131 | make it effectively proprietary. To prevent this, the GPL assures that 132 | patents cannot be used to render the program non-free. 133 | <<<<<<< HEAD 134 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 135 | ======= 136 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 137 | 138 | The precise terms and conditions for copying, distribution and 139 | modification follow. 140 | 141 | <<<<<<< HEAD 142 | <<<<<<< HEAD 143 | GNU GENERAL PUBLIC LICENSE 144 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 145 | 146 | 0. This License applies to any program or other work which contains 147 | a notice placed by the copyright holder saying it may be distributed 148 | under the terms of this General Public License. The "Program", below, 149 | refers to any such program or work, and a "work based on the Program" 150 | means either the Program or any derivative work under copyright law: 151 | that is to say, a work containing the Program or a portion of it, 152 | either verbatim or with modifications and/or translated into another 153 | language. (Hereinafter, translation is included without limitation in 154 | the term "modification".) Each licensee is addressed as "you". 155 | 156 | Activities other than copying, distribution and modification are not 157 | covered by this License; they are outside its scope. The act of 158 | running the Program is not restricted, and the output from the Program 159 | is covered only if its contents constitute a work based on the 160 | Program (independent of having been made by running the Program). 161 | Whether that is true depends on what the Program does. 162 | 163 | 1. You may copy and distribute verbatim copies of the Program's 164 | source code as you receive it, in any medium, provided that you 165 | conspicuously and appropriately publish on each copy an appropriate 166 | copyright notice and disclaimer of warranty; keep intact all the 167 | notices that refer to this License and to the absence of any warranty; 168 | and give any other recipients of the Program a copy of this License 169 | along with the Program. 170 | 171 | You may charge a fee for the physical act of transferring a copy, and 172 | you may at your option offer warranty protection in exchange for a fee. 173 | 174 | 2. You may modify your copy or copies of the Program or any portion 175 | of it, thus forming a work based on the Program, and copy and 176 | distribute such modifications or work under the terms of Section 1 177 | above, provided that you also meet all of these conditions: 178 | 179 | a) You must cause the modified files to carry prominent notices 180 | stating that you changed the files and the date of any change. 181 | 182 | b) You must cause any work that you distribute or publish, that in 183 | whole or in part contains or is derived from the Program or any 184 | part thereof, to be licensed as a whole at no charge to all third 185 | parties under the terms of this License. 186 | 187 | c) If the modified program normally reads commands interactively 188 | when run, you must cause it, when started running for such 189 | interactive use in the most ordinary way, to print or display an 190 | announcement including an appropriate copyright notice and a 191 | notice that there is no warranty (or else, saying that you provide 192 | a warranty) and that users may redistribute the program under 193 | these conditions, and telling the user how to view a copy of this 194 | License. (Exception: if the Program itself is interactive but 195 | does not normally print such an announcement, your work based on 196 | the Program is not required to print an announcement.) 197 | 198 | These requirements apply to the modified work as a whole. If 199 | identifiable sections of that work are not derived from the Program, 200 | and can be reasonably considered independent and separate works in 201 | themselves, then this License, and its terms, do not apply to those 202 | sections when you distribute them as separate works. But when you 203 | distribute the same sections as part of a whole which is a work based 204 | on the Program, the distribution of the whole must be on the terms of 205 | this License, whose permissions for other licensees extend to the 206 | entire whole, and thus to each and every part regardless of who wrote it. 207 | 208 | Thus, it is not the intent of this section to claim rights or contest 209 | your rights to work written entirely by you; rather, the intent is to 210 | exercise the right to control the distribution of derivative or 211 | collective works based on the Program. 212 | 213 | In addition, mere aggregation of another work not based on the Program 214 | with the Program (or with a work based on the Program) on a volume of 215 | a storage or distribution medium does not bring the other work under 216 | the scope of this License. 217 | 218 | 3. You may copy and distribute the Program (or a work based on it, 219 | under Section 2) in object code or executable form under the terms of 220 | Sections 1 and 2 above provided that you also do one of the following: 221 | 222 | a) Accompany it with the complete corresponding machine-readable 223 | source code, which must be distributed under the terms of Sections 224 | 1 and 2 above on a medium customarily used for software interchange; or, 225 | 226 | b) Accompany it with a written offer, valid for at least three 227 | years, to give any third party, for a charge no more than your 228 | cost of physically performing source distribution, a complete 229 | machine-readable copy of the corresponding source code, to be 230 | distributed under the terms of Sections 1 and 2 above on a medium 231 | customarily used for software interchange; or, 232 | 233 | c) Accompany it with the information you received as to the offer 234 | to distribute corresponding source code. (This alternative is 235 | allowed only for noncommercial distribution and only if you 236 | received the program in object code or executable form with such 237 | an offer, in accord with Subsection b above.) 238 | 239 | The source code for a work means the preferred form of the work for 240 | making modifications to it. For an executable work, complete source 241 | code means all the source code for all modules it contains, plus any 242 | associated interface definition files, plus the scripts used to 243 | control compilation and installation of the executable. However, as a 244 | special exception, the source code distributed need not include 245 | anything that is normally distributed (in either source or binary 246 | form) with the major components (compiler, kernel, and so on) of the 247 | operating system on which the executable runs, unless that component 248 | itself accompanies the executable. 249 | 250 | If distribution of executable or object code is made by offering 251 | access to copy from a designated place, then offering equivalent 252 | access to copy the source code from the same place counts as 253 | distribution of the source code, even though third parties are not 254 | compelled to copy the source along with the object code. 255 | 256 | 4. You may not copy, modify, sublicense, or distribute the Program 257 | except as expressly provided under this License. Any attempt 258 | otherwise to copy, modify, sublicense or distribute the Program is 259 | void, and will automatically terminate your rights under this License. 260 | However, parties who have received copies, or rights, from you under 261 | this License will not have their licenses terminated so long as such 262 | parties remain in full compliance. 263 | 264 | 5. You are not required to accept this License, since you have not 265 | signed it. However, nothing else grants you permission to modify or 266 | distribute the Program or its derivative works. These actions are 267 | prohibited by law if you do not accept this License. Therefore, by 268 | modifying or distributing the Program (or any work based on the 269 | Program), you indicate your acceptance of this License to do so, and 270 | all its terms and conditions for copying, distributing or modifying 271 | the Program or works based on it. 272 | 273 | 6. Each time you redistribute the Program (or any work based on the 274 | Program), the recipient automatically receives a license from the 275 | original licensor to copy, distribute or modify the Program subject to 276 | these terms and conditions. You may not impose any further 277 | restrictions on the recipients' exercise of the rights granted herein. 278 | You are not responsible for enforcing compliance by third parties to 279 | this License. 280 | 281 | 7. If, as a consequence of a court judgment or allegation of patent 282 | infringement or for any other reason (not limited to patent issues), 283 | conditions are imposed on you (whether by court order, agreement or 284 | otherwise) that contradict the conditions of this License, they do not 285 | excuse you from the conditions of this License. If you cannot 286 | distribute so as to satisfy simultaneously your obligations under this 287 | License and any other pertinent obligations, then as a consequence you 288 | may not distribute the Program at all. For example, if a patent 289 | license would not permit royalty-free redistribution of the Program by 290 | all those who receive copies directly or indirectly through you, then 291 | the only way you could satisfy both it and this License would be to 292 | refrain entirely from distribution of the Program. 293 | 294 | If any portion of this section is held invalid or unenforceable under 295 | any particular circumstance, the balance of the section is intended to 296 | apply and the section as a whole is intended to apply in other 297 | circumstances. 298 | 299 | It is not the purpose of this section to induce you to infringe any 300 | patents or other property right claims or to contest validity of any 301 | such claims; this section has the sole purpose of protecting the 302 | integrity of the free software distribution system, which is 303 | implemented by public license practices. Many people have made 304 | generous contributions to the wide range of software distributed 305 | through that system in reliance on consistent application of that 306 | system; it is up to the author/donor to decide if he or she is willing 307 | to distribute software through any other system and a licensee cannot 308 | impose that choice. 309 | 310 | This section is intended to make thoroughly clear what is believed to 311 | be a consequence of the rest of this License. 312 | 313 | 8. If the distribution and/or use of the Program is restricted in 314 | certain countries either by patents or by copyrighted interfaces, the 315 | original copyright holder who places the Program under this License 316 | may add an explicit geographical distribution limitation excluding 317 | those countries, so that distribution is permitted only in or among 318 | countries not thus excluded. In such case, this License incorporates 319 | the limitation as if written in the body of this License. 320 | 321 | 9. The Free Software Foundation may publish revised and/or new versions 322 | of the General Public License from time to time. Such new versions will 323 | be similar in spirit to the present version, but may differ in detail to 324 | address new problems or concerns. 325 | 326 | Each version is given a distinguishing version number. If the Program 327 | specifies a version number of this License which applies to it and "any 328 | later version", you have the option of following the terms and conditions 329 | either of that version or of any later version published by the Free 330 | Software Foundation. If the Program does not specify a version number of 331 | this License, you may choose any version ever published by the Free Software 332 | Foundation. 333 | 334 | 10. If you wish to incorporate parts of the Program into other free 335 | programs whose distribution conditions are different, write to the author 336 | to ask for permission. For software which is copyrighted by the Free 337 | Software Foundation, write to the Free Software Foundation; we sometimes 338 | make exceptions for this. Our decision will be guided by the two goals 339 | of preserving the free status of all derivatives of our free software and 340 | of promoting the sharing and reuse of software generally. 341 | 342 | NO WARRANTY 343 | 344 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 345 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 346 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 347 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 348 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 349 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 350 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 351 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 352 | REPAIR OR CORRECTION. 353 | 354 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 355 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 356 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 357 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 358 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 359 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 360 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 361 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 362 | POSSIBILITY OF SUCH DAMAGES. 363 | ======= 364 | ======= 365 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 366 | TERMS AND CONDITIONS 367 | 368 | 0. Definitions. 369 | 370 | "This License" refers to version 3 of the GNU General Public License. 371 | 372 | "Copyright" also means copyright-like laws that apply to other kinds of 373 | works, such as semiconductor masks. 374 | 375 | "The Program" refers to any copyrightable work licensed under this 376 | License. Each licensee is addressed as "you". "Licensees" and 377 | "recipients" may be individuals or organizations. 378 | 379 | To "modify" a work means to copy from or adapt all or part of the work 380 | in a fashion requiring copyright permission, other than the making of an 381 | exact copy. The resulting work is called a "modified version" of the 382 | earlier work or a work "based on" the earlier work. 383 | 384 | A "covered work" means either the unmodified Program or a work based 385 | on the Program. 386 | 387 | To "propagate" a work means to do anything with it that, without 388 | permission, would make you directly or secondarily liable for 389 | infringement under applicable copyright law, except executing it on a 390 | computer or modifying a private copy. Propagation includes copying, 391 | distribution (with or without modification), making available to the 392 | public, and in some countries other activities as well. 393 | 394 | To "convey" a work means any kind of propagation that enables other 395 | parties to make or receive copies. Mere interaction with a user through 396 | a computer network, with no transfer of a copy, is not conveying. 397 | 398 | An interactive user interface displays "Appropriate Legal Notices" 399 | to the extent that it includes a convenient and prominently visible 400 | feature that (1) displays an appropriate copyright notice, and (2) 401 | tells the user that there is no warranty for the work (except to the 402 | extent that warranties are provided), that licensees may convey the 403 | work under this License, and how to view a copy of this License. If 404 | the interface presents a list of user commands or options, such as a 405 | menu, a prominent item in the list meets this criterion. 406 | 407 | 1. Source Code. 408 | 409 | The "source code" for a work means the preferred form of the work 410 | for making modifications to it. "Object code" means any non-source 411 | form of a work. 412 | 413 | A "Standard Interface" means an interface that either is an official 414 | standard defined by a recognized standards body, or, in the case of 415 | interfaces specified for a particular programming language, one that 416 | is widely used among developers working in that language. 417 | 418 | The "System Libraries" of an executable work include anything, other 419 | than the work as a whole, that (a) is included in the normal form of 420 | packaging a Major Component, but which is not part of that Major 421 | Component, and (b) serves only to enable use of the work with that 422 | Major Component, or to implement a Standard Interface for which an 423 | implementation is available to the public in source code form. A 424 | "Major Component", in this context, means a major essential component 425 | (kernel, window system, and so on) of the specific operating system 426 | (if any) on which the executable work runs, or a compiler used to 427 | produce the work, or an object code interpreter used to run it. 428 | 429 | The "Corresponding Source" for a work in object code form means all 430 | the source code needed to generate, install, and (for an executable 431 | work) run the object code and to modify the work, including scripts to 432 | control those activities. However, it does not include the work's 433 | System Libraries, or general-purpose tools or generally available free 434 | programs which are used unmodified in performing those activities but 435 | which are not part of the work. For example, Corresponding Source 436 | includes interface definition files associated with source files for 437 | the work, and the source code for shared libraries and dynamically 438 | linked subprograms that the work is specifically designed to require, 439 | such as by intimate data communication or control flow between those 440 | subprograms and other parts of the work. 441 | 442 | The Corresponding Source need not include anything that users 443 | can regenerate automatically from other parts of the Corresponding 444 | Source. 445 | 446 | The Corresponding Source for a work in source code form is that 447 | same work. 448 | 449 | 2. Basic Permissions. 450 | 451 | All rights granted under this License are granted for the term of 452 | copyright on the Program, and are irrevocable provided the stated 453 | conditions are met. This License explicitly affirms your unlimited 454 | permission to run the unmodified Program. The output from running a 455 | covered work is covered by this License only if the output, given its 456 | content, constitutes a covered work. This License acknowledges your 457 | rights of fair use or other equivalent, as provided by copyright law. 458 | 459 | You may make, run and propagate covered works that you do not 460 | convey, without conditions so long as your license otherwise remains 461 | in force. You may convey covered works to others for the sole purpose 462 | of having them make modifications exclusively for you, or provide you 463 | with facilities for running those works, provided that you comply with 464 | the terms of this License in conveying all material for which you do 465 | not control copyright. Those thus making or running the covered works 466 | for you must do so exclusively on your behalf, under your direction 467 | and control, on terms that prohibit them from making any copies of 468 | your copyrighted material outside their relationship with you. 469 | 470 | Conveying under any other circumstances is permitted solely under 471 | the conditions stated below. Sublicensing is not allowed; section 10 472 | makes it unnecessary. 473 | 474 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 475 | 476 | No covered work shall be deemed part of an effective technological 477 | measure under any applicable law fulfilling obligations under article 478 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 479 | similar laws prohibiting or restricting circumvention of such 480 | measures. 481 | 482 | When you convey a covered work, you waive any legal power to forbid 483 | circumvention of technological measures to the extent such circumvention 484 | is effected by exercising rights under this License with respect to 485 | the covered work, and you disclaim any intention to limit operation or 486 | modification of the work as a means of enforcing, against the work's 487 | users, your or third parties' legal rights to forbid circumvention of 488 | technological measures. 489 | 490 | 4. Conveying Verbatim Copies. 491 | 492 | You may convey verbatim copies of the Program's source code as you 493 | receive it, in any medium, provided that you conspicuously and 494 | appropriately publish on each copy an appropriate copyright notice; 495 | keep intact all notices stating that this License and any 496 | non-permissive terms added in accord with section 7 apply to the code; 497 | keep intact all notices of the absence of any warranty; and give all 498 | recipients a copy of this License along with the Program. 499 | 500 | You may charge any price or no price for each copy that you convey, 501 | and you may offer support or warranty protection for a fee. 502 | 503 | 5. Conveying Modified Source Versions. 504 | 505 | You may convey a work based on the Program, or the modifications to 506 | produce it from the Program, in the form of source code under the 507 | terms of section 4, provided that you also meet all of these conditions: 508 | 509 | a) The work must carry prominent notices stating that you modified 510 | it, and giving a relevant date. 511 | 512 | b) The work must carry prominent notices stating that it is 513 | released under this License and any conditions added under section 514 | 7. This requirement modifies the requirement in section 4 to 515 | "keep intact all notices". 516 | 517 | c) You must license the entire work, as a whole, under this 518 | License to anyone who comes into possession of a copy. This 519 | License will therefore apply, along with any applicable section 7 520 | additional terms, to the whole of the work, and all its parts, 521 | regardless of how they are packaged. This License gives no 522 | permission to license the work in any other way, but it does not 523 | invalidate such permission if you have separately received it. 524 | 525 | d) If the work has interactive user interfaces, each must display 526 | Appropriate Legal Notices; however, if the Program has interactive 527 | interfaces that do not display Appropriate Legal Notices, your 528 | work need not make them do so. 529 | 530 | A compilation of a covered work with other separate and independent 531 | works, which are not by their nature extensions of the covered work, 532 | and which are not combined with it such as to form a larger program, 533 | in or on a volume of a storage or distribution medium, is called an 534 | "aggregate" if the compilation and its resulting copyright are not 535 | used to limit the access or legal rights of the compilation's users 536 | beyond what the individual works permit. Inclusion of a covered work 537 | in an aggregate does not cause this License to apply to the other 538 | parts of the aggregate. 539 | 540 | 6. Conveying Non-Source Forms. 541 | 542 | You may convey a covered work in object code form under the terms 543 | of sections 4 and 5, provided that you also convey the 544 | machine-readable Corresponding Source under the terms of this License, 545 | in one of these ways: 546 | 547 | a) Convey the object code in, or embodied in, a physical product 548 | (including a physical distribution medium), accompanied by the 549 | Corresponding Source fixed on a durable physical medium 550 | customarily used for software interchange. 551 | 552 | b) Convey the object code in, or embodied in, a physical product 553 | (including a physical distribution medium), accompanied by a 554 | written offer, valid for at least three years and valid for as 555 | long as you offer spare parts or customer support for that product 556 | model, to give anyone who possesses the object code either (1) a 557 | copy of the Corresponding Source for all the software in the 558 | product that is covered by this License, on a durable physical 559 | medium customarily used for software interchange, for a price no 560 | more than your reasonable cost of physically performing this 561 | conveying of source, or (2) access to copy the 562 | Corresponding Source from a network server at no charge. 563 | 564 | c) Convey individual copies of the object code with a copy of the 565 | written offer to provide the Corresponding Source. This 566 | alternative is allowed only occasionally and noncommercially, and 567 | only if you received the object code with such an offer, in accord 568 | with subsection 6b. 569 | 570 | d) Convey the object code by offering access from a designated 571 | place (gratis or for a charge), and offer equivalent access to the 572 | Corresponding Source in the same way through the same place at no 573 | further charge. You need not require recipients to copy the 574 | Corresponding Source along with the object code. If the place to 575 | copy the object code is a network server, the Corresponding Source 576 | may be on a different server (operated by you or a third party) 577 | that supports equivalent copying facilities, provided you maintain 578 | clear directions next to the object code saying where to find the 579 | Corresponding Source. Regardless of what server hosts the 580 | Corresponding Source, you remain obligated to ensure that it is 581 | available for as long as needed to satisfy these requirements. 582 | 583 | e) Convey the object code using peer-to-peer transmission, provided 584 | you inform other peers where the object code and Corresponding 585 | Source of the work are being offered to the general public at no 586 | charge under subsection 6d. 587 | 588 | A separable portion of the object code, whose source code is excluded 589 | from the Corresponding Source as a System Library, need not be 590 | included in conveying the object code work. 591 | 592 | A "User Product" is either (1) a "consumer product", which means any 593 | tangible personal property which is normally used for personal, family, 594 | or household purposes, or (2) anything designed or sold for incorporation 595 | into a dwelling. In determining whether a product is a consumer product, 596 | doubtful cases shall be resolved in favor of coverage. For a particular 597 | product received by a particular user, "normally used" refers to a 598 | typical or common use of that class of product, regardless of the status 599 | of the particular user or of the way in which the particular user 600 | actually uses, or expects or is expected to use, the product. A product 601 | is a consumer product regardless of whether the product has substantial 602 | commercial, industrial or non-consumer uses, unless such uses represent 603 | the only significant mode of use of the product. 604 | 605 | "Installation Information" for a User Product means any methods, 606 | procedures, authorization keys, or other information required to install 607 | and execute modified versions of a covered work in that User Product from 608 | a modified version of its Corresponding Source. The information must 609 | suffice to ensure that the continued functioning of the modified object 610 | code is in no case prevented or interfered with solely because 611 | modification has been made. 612 | 613 | If you convey an object code work under this section in, or with, or 614 | specifically for use in, a User Product, and the conveying occurs as 615 | part of a transaction in which the right of possession and use of the 616 | User Product is transferred to the recipient in perpetuity or for a 617 | fixed term (regardless of how the transaction is characterized), the 618 | Corresponding Source conveyed under this section must be accompanied 619 | by the Installation Information. But this requirement does not apply 620 | if neither you nor any third party retains the ability to install 621 | modified object code on the User Product (for example, the work has 622 | been installed in ROM). 623 | 624 | The requirement to provide Installation Information does not include a 625 | requirement to continue to provide support service, warranty, or updates 626 | for a work that has been modified or installed by the recipient, or for 627 | the User Product in which it has been modified or installed. Access to a 628 | network may be denied when the modification itself materially and 629 | adversely affects the operation of the network or violates the rules and 630 | protocols for communication across the network. 631 | 632 | Corresponding Source conveyed, and Installation Information provided, 633 | in accord with this section must be in a format that is publicly 634 | documented (and with an implementation available to the public in 635 | source code form), and must require no special password or key for 636 | unpacking, reading or copying. 637 | 638 | 7. Additional Terms. 639 | 640 | "Additional permissions" are terms that supplement the terms of this 641 | License by making exceptions from one or more of its conditions. 642 | Additional permissions that are applicable to the entire Program shall 643 | be treated as though they were included in this License, to the extent 644 | that they are valid under applicable law. If additional permissions 645 | apply only to part of the Program, that part may be used separately 646 | under those permissions, but the entire Program remains governed by 647 | this License without regard to the additional permissions. 648 | 649 | When you convey a copy of a covered work, you may at your option 650 | remove any additional permissions from that copy, or from any part of 651 | it. (Additional permissions may be written to require their own 652 | removal in certain cases when you modify the work.) You may place 653 | additional permissions on material, added by you to a covered work, 654 | for which you have or can give appropriate copyright permission. 655 | 656 | Notwithstanding any other provision of this License, for material you 657 | add to a covered work, you may (if authorized by the copyright holders of 658 | that material) supplement the terms of this License with terms: 659 | 660 | a) Disclaiming warranty or limiting liability differently from the 661 | terms of sections 15 and 16 of this License; or 662 | 663 | b) Requiring preservation of specified reasonable legal notices or 664 | author attributions in that material or in the Appropriate Legal 665 | Notices displayed by works containing it; or 666 | 667 | c) Prohibiting misrepresentation of the origin of that material, or 668 | requiring that modified versions of such material be marked in 669 | reasonable ways as different from the original version; or 670 | 671 | d) Limiting the use for publicity purposes of names of licensors or 672 | authors of the material; or 673 | 674 | e) Declining to grant rights under trademark law for use of some 675 | trade names, trademarks, or service marks; or 676 | 677 | f) Requiring indemnification of licensors and authors of that 678 | material by anyone who conveys the material (or modified versions of 679 | it) with contractual assumptions of liability to the recipient, for 680 | any liability that these contractual assumptions directly impose on 681 | those licensors and authors. 682 | 683 | All other non-permissive additional terms are considered "further 684 | restrictions" within the meaning of section 10. If the Program as you 685 | received it, or any part of it, contains a notice stating that it is 686 | governed by this License along with a term that is a further 687 | restriction, you may remove that term. If a license document contains 688 | a further restriction but permits relicensing or conveying under this 689 | License, you may add to a covered work material governed by the terms 690 | of that license document, provided that the further restriction does 691 | not survive such relicensing or conveying. 692 | 693 | If you add terms to a covered work in accord with this section, you 694 | must place, in the relevant source files, a statement of the 695 | additional terms that apply to those files, or a notice indicating 696 | where to find the applicable terms. 697 | 698 | Additional terms, permissive or non-permissive, may be stated in the 699 | form of a separately written license, or stated as exceptions; 700 | the above requirements apply either way. 701 | 702 | 8. Termination. 703 | 704 | You may not propagate or modify a covered work except as expressly 705 | provided under this License. Any attempt otherwise to propagate or 706 | modify it is void, and will automatically terminate your rights under 707 | this License (including any patent licenses granted under the third 708 | paragraph of section 11). 709 | 710 | However, if you cease all violation of this License, then your 711 | license from a particular copyright holder is reinstated (a) 712 | provisionally, unless and until the copyright holder explicitly and 713 | finally terminates your license, and (b) permanently, if the copyright 714 | holder fails to notify you of the violation by some reasonable means 715 | prior to 60 days after the cessation. 716 | 717 | Moreover, your license from a particular copyright holder is 718 | reinstated permanently if the copyright holder notifies you of the 719 | violation by some reasonable means, this is the first time you have 720 | received notice of violation of this License (for any work) from that 721 | copyright holder, and you cure the violation prior to 30 days after 722 | your receipt of the notice. 723 | 724 | Termination of your rights under this section does not terminate the 725 | licenses of parties who have received copies or rights from you under 726 | this License. If your rights have been terminated and not permanently 727 | reinstated, you do not qualify to receive new licenses for the same 728 | material under section 10. 729 | 730 | 9. Acceptance Not Required for Having Copies. 731 | 732 | You are not required to accept this License in order to receive or 733 | run a copy of the Program. Ancillary propagation of a covered work 734 | occurring solely as a consequence of using peer-to-peer transmission 735 | to receive a copy likewise does not require acceptance. However, 736 | nothing other than this License grants you permission to propagate or 737 | modify any covered work. These actions infringe copyright if you do 738 | not accept this License. Therefore, by modifying or propagating a 739 | covered work, you indicate your acceptance of this License to do so. 740 | 741 | 10. Automatic Licensing of Downstream Recipients. 742 | 743 | Each time you convey a covered work, the recipient automatically 744 | receives a license from the original licensors, to run, modify and 745 | propagate that work, subject to this License. You are not responsible 746 | for enforcing compliance by third parties with this License. 747 | 748 | An "entity transaction" is a transaction transferring control of an 749 | organization, or substantially all assets of one, or subdividing an 750 | organization, or merging organizations. If propagation of a covered 751 | work results from an entity transaction, each party to that 752 | transaction who receives a copy of the work also receives whatever 753 | licenses to the work the party's predecessor in interest had or could 754 | give under the previous paragraph, plus a right to possession of the 755 | Corresponding Source of the work from the predecessor in interest, if 756 | the predecessor has it or can get it with reasonable efforts. 757 | 758 | You may not impose any further restrictions on the exercise of the 759 | rights granted or affirmed under this License. For example, you may 760 | not impose a license fee, royalty, or other charge for exercise of 761 | rights granted under this License, and you may not initiate litigation 762 | (including a cross-claim or counterclaim in a lawsuit) alleging that 763 | any patent claim is infringed by making, using, selling, offering for 764 | sale, or importing the Program or any portion of it. 765 | 766 | 11. Patents. 767 | 768 | A "contributor" is a copyright holder who authorizes use under this 769 | License of the Program or a work on which the Program is based. The 770 | work thus licensed is called the contributor's "contributor version". 771 | 772 | A contributor's "essential patent claims" are all patent claims 773 | owned or controlled by the contributor, whether already acquired or 774 | hereafter acquired, that would be infringed by some manner, permitted 775 | by this License, of making, using, or selling its contributor version, 776 | but do not include claims that would be infringed only as a 777 | consequence of further modification of the contributor version. For 778 | purposes of this definition, "control" includes the right to grant 779 | patent sublicenses in a manner consistent with the requirements of 780 | this License. 781 | 782 | Each contributor grants you a non-exclusive, worldwide, royalty-free 783 | patent license under the contributor's essential patent claims, to 784 | make, use, sell, offer for sale, import and otherwise run, modify and 785 | propagate the contents of its contributor version. 786 | 787 | In the following three paragraphs, a "patent license" is any express 788 | agreement or commitment, however denominated, not to enforce a patent 789 | (such as an express permission to practice a patent or covenant not to 790 | sue for patent infringement). To "grant" such a patent license to a 791 | party means to make such an agreement or commitment not to enforce a 792 | patent against the party. 793 | 794 | If you convey a covered work, knowingly relying on a patent license, 795 | and the Corresponding Source of the work is not available for anyone 796 | to copy, free of charge and under the terms of this License, through a 797 | publicly available network server or other readily accessible means, 798 | then you must either (1) cause the Corresponding Source to be so 799 | available, or (2) arrange to deprive yourself of the benefit of the 800 | patent license for this particular work, or (3) arrange, in a manner 801 | consistent with the requirements of this License, to extend the patent 802 | license to downstream recipients. "Knowingly relying" means you have 803 | actual knowledge that, but for the patent license, your conveying the 804 | covered work in a country, or your recipient's use of the covered work 805 | in a country, would infringe one or more identifiable patents in that 806 | country that you have reason to believe are valid. 807 | 808 | If, pursuant to or in connection with a single transaction or 809 | arrangement, you convey, or propagate by procuring conveyance of, a 810 | covered work, and grant a patent license to some of the parties 811 | receiving the covered work authorizing them to use, propagate, modify 812 | or convey a specific copy of the covered work, then the patent license 813 | you grant is automatically extended to all recipients of the covered 814 | work and works based on it. 815 | 816 | A patent license is "discriminatory" if it does not include within 817 | the scope of its coverage, prohibits the exercise of, or is 818 | conditioned on the non-exercise of one or more of the rights that are 819 | specifically granted under this License. You may not convey a covered 820 | work if you are a party to an arrangement with a third party that is 821 | in the business of distributing software, under which you make payment 822 | to the third party based on the extent of your activity of conveying 823 | the work, and under which the third party grants, to any of the 824 | parties who would receive the covered work from you, a discriminatory 825 | patent license (a) in connection with copies of the covered work 826 | conveyed by you (or copies made from those copies), or (b) primarily 827 | for and in connection with specific products or compilations that 828 | contain the covered work, unless you entered into that arrangement, 829 | or that patent license was granted, prior to 28 March 2007. 830 | 831 | Nothing in this License shall be construed as excluding or limiting 832 | any implied license or other defenses to infringement that may 833 | otherwise be available to you under applicable patent law. 834 | 835 | 12. No Surrender of Others' Freedom. 836 | 837 | If conditions are imposed on you (whether by court order, agreement or 838 | otherwise) that contradict the conditions of this License, they do not 839 | excuse you from the conditions of this License. If you cannot convey a 840 | covered work so as to satisfy simultaneously your obligations under this 841 | License and any other pertinent obligations, then as a consequence you may 842 | not convey it at all. For example, if you agree to terms that obligate you 843 | to collect a royalty for further conveying from those to whom you convey 844 | the Program, the only way you could satisfy both those terms and this 845 | License would be to refrain entirely from conveying the Program. 846 | 847 | 13. Use with the GNU Affero General Public License. 848 | 849 | Notwithstanding any other provision of this License, you have 850 | permission to link or combine any covered work with a work licensed 851 | under version 3 of the GNU Affero General Public License into a single 852 | combined work, and to convey the resulting work. The terms of this 853 | License will continue to apply to the part which is the covered work, 854 | but the special requirements of the GNU Affero General Public License, 855 | section 13, concerning interaction through a network will apply to the 856 | combination as such. 857 | 858 | 14. Revised Versions of this License. 859 | 860 | The Free Software Foundation may publish revised and/or new versions of 861 | the GNU General Public License from time to time. Such new versions will 862 | be similar in spirit to the present version, but may differ in detail to 863 | address new problems or concerns. 864 | 865 | Each version is given a distinguishing version number. If the 866 | Program specifies that a certain numbered version of the GNU General 867 | Public License "or any later version" applies to it, you have the 868 | option of following the terms and conditions either of that numbered 869 | version or of any later version published by the Free Software 870 | Foundation. If the Program does not specify a version number of the 871 | GNU General Public License, you may choose any version ever published 872 | by the Free Software Foundation. 873 | 874 | If the Program specifies that a proxy can decide which future 875 | versions of the GNU General Public License can be used, that proxy's 876 | public statement of acceptance of a version permanently authorizes you 877 | to choose that version for the Program. 878 | 879 | Later license versions may give you additional or different 880 | permissions. However, no additional obligations are imposed on any 881 | author or copyright holder as a result of your choosing to follow a 882 | later version. 883 | 884 | 15. Disclaimer of Warranty. 885 | 886 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 887 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 888 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 889 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 890 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 891 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 892 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 893 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 894 | 895 | 16. Limitation of Liability. 896 | 897 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 898 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 899 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 900 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 901 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 902 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 903 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 904 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 905 | SUCH DAMAGES. 906 | 907 | 17. Interpretation of Sections 15 and 16. 908 | 909 | If the disclaimer of warranty and limitation of liability provided 910 | above cannot be given local legal effect according to their terms, 911 | reviewing courts shall apply local law that most closely approximates 912 | an absolute waiver of all civil liability in connection with the 913 | Program, unless a warranty or assumption of liability accompanies a 914 | copy of the Program in return for a fee. 915 | <<<<<<< HEAD 916 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 917 | ======= 918 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 919 | 920 | END OF TERMS AND CONDITIONS 921 | 922 | How to Apply These Terms to Your New Programs 923 | 924 | If you develop a new program, and you want it to be of the greatest 925 | possible use to the public, the best way to achieve this is to make it 926 | free software which everyone can redistribute and change under these terms. 927 | 928 | To do so, attach the following notices to the program. It is safest 929 | to attach them to the start of each source file to most effectively 930 | <<<<<<< HEAD 931 | <<<<<<< HEAD 932 | convey the exclusion of warranty; and each file should have at least 933 | the "copyright" line and a pointer to where the full notice is found. 934 | 935 | {description} 936 | Copyright (C) {year} {fullname} 937 | 938 | This program is free software; you can redistribute it and/or modify 939 | it under the terms of the GNU General Public License as published by 940 | the Free Software Foundation; either version 2 of the License, or 941 | ======= 942 | ======= 943 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 944 | state the exclusion of warranty; and each file should have at least 945 | the "copyright" line and a pointer to where the full notice is found. 946 | 947 | {one line to give the program's name and a brief idea of what it does.} 948 | Copyright (C) {year} {name of author} 949 | 950 | This program is free software: you can redistribute it and/or modify 951 | it under the terms of the GNU General Public License as published by 952 | the Free Software Foundation, either version 3 of the License, or 953 | <<<<<<< HEAD 954 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 955 | ======= 956 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 957 | (at your option) any later version. 958 | 959 | This program is distributed in the hope that it will be useful, 960 | but WITHOUT ANY WARRANTY; without even the implied warranty of 961 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 962 | GNU General Public License for more details. 963 | 964 | <<<<<<< HEAD 965 | <<<<<<< HEAD 966 | You should have received a copy of the GNU General Public License along 967 | with this program; if not, write to the Free Software Foundation, Inc., 968 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 969 | 970 | Also add information on how to contact you by electronic and paper mail. 971 | 972 | If the program is interactive, make it output a short notice like this 973 | when it starts in an interactive mode: 974 | 975 | Gnomovision version 69, Copyright (C) year name of author 976 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 977 | ======= 978 | ======= 979 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 980 | You should have received a copy of the GNU General Public License 981 | along with this program. If not, see . 982 | 983 | Also add information on how to contact you by electronic and paper mail. 984 | 985 | If the program does terminal interaction, make it output a short 986 | notice like this when it starts in an interactive mode: 987 | 988 | {project} Copyright (C) {year} {fullname} 989 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 990 | <<<<<<< HEAD 991 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 992 | ======= 993 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 994 | This is free software, and you are welcome to redistribute it 995 | under certain conditions; type `show c' for details. 996 | 997 | The hypothetical commands `show w' and `show c' should show the appropriate 998 | <<<<<<< HEAD 999 | <<<<<<< HEAD 1000 | parts of the General Public License. Of course, the commands you use may 1001 | be called something other than `show w' and `show c'; they could even be 1002 | mouse-clicks or menu items--whatever suits your program. 1003 | 1004 | You should also get your employer (if you work as a programmer) or your 1005 | school, if any, to sign a "copyright disclaimer" for the program, if 1006 | necessary. Here is a sample; alter the names: 1007 | 1008 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 1009 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 1010 | 1011 | {signature of Ty Coon}, 1 April 1989 1012 | Ty Coon, President of Vice 1013 | 1014 | This General Public License does not permit incorporating your program into 1015 | proprietary programs. If your program is a subroutine library, you may 1016 | consider it more useful to permit linking proprietary applications with the 1017 | library. If this is what you want to do, use the GNU Lesser General 1018 | Public License instead of this License. 1019 | ======= 1020 | ======= 1021 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 1022 | parts of the General Public License. Of course, your program's commands 1023 | might be different; for a GUI interface, you would use an "about box". 1024 | 1025 | You should also get your employer (if you work as a programmer) or school, 1026 | if any, to sign a "copyright disclaimer" for the program, if necessary. 1027 | For more information on this, and how to apply and follow the GNU GPL, see 1028 | . 1029 | 1030 | The GNU General Public License does not permit incorporating your program 1031 | into proprietary programs. If your program is a subroutine library, you 1032 | may consider it more useful to permit linking proprietary applications with 1033 | the library. If this is what you want to do, use the GNU Lesser General 1034 | Public License instead of this License. But first, please read 1035 | . 1036 | <<<<<<< HEAD 1037 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 1038 | ======= 1039 | >>>>>>> 6211081cc146974a982f178d12a80f75b9465e5a 1040 | --------------------------------------------------------------------------------