Commit 5f083e59 authored by Danny SMc's avatar Danny SMc

Newest update, still needs updating...

parent 5beed38d
language: python
python:
- 3.3
- 2.7
install:
- if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install -r requirements/python2.txt --use-mirrors; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3* ]]; then pip install -r requirements/python3.txt --use-mirrors; fi
script: nosetests
\ No newline at end of file
......@@ -58,9 +58,8 @@ var irc = require("irc"),
unirest = require("unirest");
fs = require("fs");
var relaylist = [],
var relaylist = ["#dannysmc95"],
RelayActive = false;
console.log(relaylist.length);
// Get Log Name:
......@@ -88,7 +87,7 @@ console.log("[INFO]: Connecting to IRC");
addlog("[INFO]: Connecting to IRC");
var bot = new irc.Client("irc.esper.net", "ShinexusBot", {
channels: ["#shinexusuk", "#dannysmc95", "#DannySMc", "#shinexus"],
channels: ["#shinexusuk", "#dannysmc95"],
realName: "ShinexusUK Server Bot",
autoRejoin: true
});
......@@ -96,71 +95,31 @@ var bot = new irc.Client("irc.esper.net", "ShinexusBot", {
console.log("[INFO]: Connected");
addlog("[INFO]: Connected");
var proxy = "https://mcapi.us/server/status?ip=185.38.149.35&port=25578",
survival = "https://mcapi.us/server/status?ip=185.38.148.138&port=25594",
creative = "https://mcapi.us/server/status?ip=185.38.148.138&port=25609";
// Get server data
function getproxy(to, func) {
var Request = unirest.get(proxy);
Request.header('Accept', 'application/json').end(function (response) {
main = response["raw_body"];
pdata = JSON.parse(main);
getsurvival(to, pdata, func);
});
}
function getsurvival(to, pdata, func) {
var Request = unirest.get(survival);
Request.header('Accept', 'application/json').end(function (response) {
main = response["raw_body"];
sdata = JSON.parse(main);
getcreative(to, pdata, sdata, func);
});
}
function getcreative(to, pdata, sdata, func) {
var Request = unirest.get(creative);
Request.header('Accept', 'application/json').end(function (response) {
main = response["raw_body"];
cdata = JSON.parse(main);
if (func == "status") {
if (pdata["online"].toString() == "true") {
pon = "Online";
} else {
pon = "Offline";
}
if (sdata["online"].toString() == "true") {
son = "Online";
} else {
son = "Offline";
}
if (cdata["online"].toString() == "true") {
con = "Online";
} else {
con = "Offline";
}
bot.say(to, "Please note this can be delayed, due to servers restarting etc, it can take a few moments before the query port is initialised. Current server statuses:");
bot.say(to, "[Proxy]: "+pon+", [Survival]: "+son+", [Creative]: "+con+".");
} else if (func == "players") {
bot.say(to, "Please note this can be delayed, due to servers restarting etc, it can take a few moments before the query port is initialised. Current player count:");
bot.say(to, "[Total]: "+(Number(sdata.players.now)+Number(cdata.players.now))+"/150, [Survival]: "+sdata.players.now+", [Creative]: "+cdata. players.now+".");
}
});
}
var survival = "https://mcapi.us/server/status?ip=185.38.148.138&port=25594";
// Smart Bot System:
function chatsys(to, msg, from) {
// Load from JSON
}
// Economy System:
function ecosystem(cmd, to) {
if (cmd == "top") {
// Request Data
var Request = unirest.get(survival);
Request.header('Accept', 'application/json').end(function (response) {
main = response["raw_body"];
ecodata = JSON.parse(main);
for (var i = ecodata.length - 1; i >= 0; i--) {
ecodata[i]
};
});
} else {
bot.say(to, "Could not recognise command.");
}
}
// Main logic:
function parsemessage(msg, to, from, relaylist) {
// Execute files
......@@ -228,6 +187,7 @@ function parsemessage(msg, to, from, relaylist) {
} else if (msgs[0] == pre+"eco") {
// Add economy system functions
ecosystem(msgs[1], to);
} else if (msgs[0] == pre+"help") {
......@@ -236,7 +196,20 @@ function parsemessage(msg, to, from, relaylist) {
} else if (msgs[0] == pre+"status") {
// Get status of server, should return online/offline - player count for each server - motd
getproxy(to, "status");
var url = "https://mcapi.us/server/status?ip=185.38.148.138&port=25594";
var Request = unirest.get(proxy);
Request.header('Accept', 'application/json').end(function (response) {
main = response["raw_body"];
data = JSON.parse(main);
if (data["status"].toString() == "success") {
son = "Online";
} else {
son = "Offline";
}
bot.say(to, "[STATUS]: "+son);
});
} else if (msgs[0] == pre+"commands") {
......@@ -251,9 +224,19 @@ function parsemessage(msg, to, from, relaylist) {
} else if (msgs[0] == pre+"players") {
// Should return the player list for each server
getproxy(to, "players");
} else if (msgs[0] == pre+"motd") {
var url = "https://mcapi.us/server/status?ip=185.38.148.138&port=25594";
var Request = unirest.get(proxy);
Request.header('Accept', 'application/json').end(function (response) {
main = response["raw_body"];
data = JSON.parse(main);
if (data.players.max === 0) {
bot.say(to, "[PLAYERS]: "+data.players.now+" / "+data.players.max+" - It seems the server may be restarting...");
} else {
bot.say(to, "[PLAYERS]: "+data.players.now+" / "+data.players.max);
}
});
} else if (msgs[0] == pre+"servermotd") {
// Should return the message of the day.
var Request = unirest.get(survival);
......@@ -263,6 +246,15 @@ function parsemessage(msg, to, from, relaylist) {
bot.say(to, "MOTD: "+sdata.motd);
});
} else if (msgs[0] == pre+"motd") {
fs.readFile("dynamic/motd.txt", "utf8", function(err, data) {
if (err) {
return console.log(err);
}
bot.say(to, "MOTD: " + data);
});
} else if (msgs[0] == pre+"define") {
// Defines a word using urban dictionary.
......@@ -405,6 +397,13 @@ function parsemessage(msg, to, from, relaylist) {
var relaylist = [];
bot.say(to, "[RELAY]: Cleared relay table.");
if (RelayActive == true) {
for (i=0; i < relaylist.length; i++) {
bot.part(relaylist[i]);
bot.say(to, "Left all relay channels.");
}
}
} else {
bot.say(to, "[RELAY]: Invalid argument");
}
......@@ -461,6 +460,20 @@ function parsemessage(msg, to, from, relaylist) {
}
}
function dynamic(to, who, command) {
if (command == "motdandwelcome") {
// Anounce motd with welcome
fs.readFile("dynamic/motd.txt", "utf8", function(err, data) {
if (err) {
return console.log(err);
}
bot.say(to, "Welcome " + who + " to the ShinexusUK channel. Use: " + pre + "help for options. Message of the day: " + data);
});
}
}
function relaysystem(message, to, from) {
for (i = 1; i < relaylist.length; i++) {
if (relaylist[i] == to) {
......@@ -474,8 +487,10 @@ bot.addListener("join", function(channel, who) {
// Welcome new members
if (channel == "#shinexusuk") {
bot.say(channel,"Welcome "+ who +" to the ShinexusUK Channel. I am an automated bot with all kinds of knowledge. Use: "+pre+"help for help. I can get the status of the servers or even the player count!");
} else {
//bot.say(channel,"Welcome "+ who +" to the ShinexusUK Channel. Use " +pre+ "help for options.");
// Announce message of the day:
dynamic("#shinexusuk", who, "motdandwelcome");
} else if (channel == "#dannysmc95") {
bot.say(channel, "Welcome, I am dannysmc95's bot, if you need him he is normally on his server channel: #shinexusuk, I shall tell him you called though, so at least wait a few minutes and he may turn up after I call him.");
bot.say("#shinexusuk", "Danny! " + who + " just joined the: " + channel + " channel.");
}
......@@ -501,7 +516,7 @@ var stdin = process.openStdin();
stdin.addListener("data", function(d) {
var inp = d.toString().substring(0, d.length-1);
// Do stuff with inp ( the input)
console.log(inp);
parsemessage(inp);
});
// Listen for PM's.
......
......@@ -2,3 +2,14 @@
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connected
[COMMAND]: !relay
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !help
[COMMAND]: !players
[COMMAND]: !status
[COMMAND]: !status
[COMMAND]: !status
[COMMAND]: !status
[COMMAND]: !status
[COMMAND]: !players
[COMMAND]: !players
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[COMMAND]: !relay add #computercraft
[COMMAND]: !relay enable
[COMMAND]: !define shurtle
[COMMAND]: !relay add #testchan
[COMMAND]: !relay del #testchan
[COMMAND]: !relay view
[COMMAND]: !relay del #computercraft
[COMMAND]: !relay add #computercraft
[COMMAND]: !relay clear
[COMMAND]: !relay disable
[COMMAND]: !players
[COMMAND]: !status
[COMMAND]: !players
[COMMAND]: !relay add #testchan
[COMMAND]: !relay enable
[COMMAND]: !relad add #computercraft
[COMMAND]: !relay add #computercraft
[COMMAND]: !relay del #testchan
[COMMAND]: !relay view
[COMMAND]: !define lewd
[COMMAND]: !relay clear
[COMMAND]: !relay disable
IRC ERR: [object Object]
[COMMAND]: !players
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[COMMAND]: !players
[COMMAND]: !define EOB
[COMMAND]: !define god
[COMMAND]: !say
[COMMAND]: !shout
[COMMAND]: !define god
[COMMAND]: !define religion
[COMMAND]: !relay add #computercraft
[COMMAND]: !relay add #computercraft
[COMMAND]: !relay enable
[COMMAND]: !relay add #computercraft
[COMMAND]: !help
[COMMAND]: !commands
[COMMAND]: !relay disable
IRC ERR: [object Object]
[COMMAND]: !relay clesar
[COMMAND]: !relay clear
This diff is collapsed.
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[INFO]: Connecting to IRC
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connected
[COMMAND]: !relay
TypeError: Cannot read property 'length' of undefined
at Client._speak (c:\Users\danny\Documents\Danny\Projects\Server_bot\node_modules\irc\lib\irc.js:960:48)
at Client.say (c:\Users\danny\Documents\Danny\Projects\Server_bot\node_modules\irc\lib\irc.js:951:10)
at parsemessage (c:\Users\danny\Documents\Danny\Projects\Server_bot\bot.js:484:18)
at ReadStream.<anonymous> (c:\Users\danny\Documents\Danny\Projects\Server_bot\bot.js:530:5)
at ReadStream.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at ReadStream.Readable.push (_stream_readable.js:126:10)
at TTY.onread (net.js:538:20)
[COMMAND]: !status
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !define chicken
[COMMAND]: !players
[COMMAND]: !define RTFM<
[COMMAND]: !define RTFM
[COMMAND]: !define amend
[COMMAND]: !define dho
[COMMAND]: !define ikr
[COMMAND]: !define penis
[COMMAND]: !define virgin
IRC ERR: [object Object]
[COMMAND]: !define sweaters
[COMMAND]: !define sweatshirt
[COMMAND]: !define sister
[COMMAND]: !define vinesauce
[COMMAND]: !brother
[COMMAND]: !define brother
[COMMAND]: !define define
IRC ERR: [object Object]
[COMMAND]: !help
[COMMAND]: !commands
[COMMAND]: !help [command]
[COMMAND]: !math 0 % 0
[COMMAND]: !math 0 mod 0
[COMMAND]: !math 3/3
[COMMAND]: !math 3 / 3
[COMMAND]: !math 0 / 0
[COMMAND]: !yell
[COMMAND]: !define dickhead
[COMMAND]: !relay add #computercraft
[COMMAND]: !relay enable
[COMMAND]: !relay add #computercraft
[COMMAND]: !relay
[COMMAND]: !help relay
[COMMAND]: !help help
[COMMAND]: !commands
[COMMAND]: !define [term]
[COMMAND]: !motd
IRC ERR: [object Object]
[COMMAND]: !players
[COMMAND]: !status
[COMMAND]: !relay list
[COMMAND]: !relay list
[COMMAND]: !relay view
[COMMAND]: !relay disable
IRC ERR: [object Object]
[COMMAND]: !relay clear
[COMMAND]: !define cunt
[COMMAND]: !define ily
[COMMAND]: !define ily
[COMMAND]: !define ilyr
[COMMAND]: !players
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !define lad
[COMMAND]: !players
[COMMAND]: !define LD
[COMMAND]: !players
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !l2p
[COMMAND]: !define l2p
IRC ERR: [object Object]
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
SyntaxError: Unexpected token <
at Object.parse (native)
at c:\Users\danny\Documents\Danny\Projects\Server_bot\bot.js:125:19
at Request.handleRequestResponse [as _callback] (c:\Users\danny\Documents\Danny\Projects\Server_bot\node_modules\unirest\index.js:461:25)
at Request.self.callback (c:\Users\danny\Documents\Danny\Projects\Server_bot\node_modules\unirest\node_modules\request\request.js:373:22)
at Request.emit (events.js:110:17)
at Request.<anonymous> (c:\Users\danny\Documents\Danny\Projects\Server_bot\node_modules\unirest\node_modules\request\request.js:1318:14)
at Request.emit (events.js:129:20)
at IncomingMessage.<anonymous> (c:\Users\danny\Documents\Danny\Projects\Server_bot\node_modules\unirest\node_modules\request\request.js:1266:12)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
[COMMAND]: !players
[COMMAND]: !status
[COMMAND]: !relay list
[COMMAND]: !relay view
[COMMAND]: !relay add #dannysmc
[COMMAND]: !relay enable
[COMMAND]: !relay add #computercraft
[COMMAND]: !relay disable
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !status
[COMMAND]: !status
[COMMAND]: !players
[COMMAND]: !status
[COMMAND]: !players
[COMMAND]: !plauers
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !relay enable
TypeError: Cannot read property 'length' of undefined
at Client._speak (c:\Users\danny\Documents\Danny\Projects\Server_bot\node_modules\irc\lib\irc.js:960:48)
at Client.say (c:\Users\danny\Documents\Danny\Projects\Server_bot\node_modules\irc\lib\irc.js:951:10)
at parsemessage (c:\Users\danny\Documents\Danny\Projects\Server_bot\bot.js:441:16)
at ReadStream.<anonymous> (c:\Users\danny\Documents\Danny\Projects\Server_bot\bot.js:529:5)
at ReadStream.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at ReadStream.Readable.push (_stream_readable.js:126:10)
at TTY.onread (net.js:538:20)
[COMMAND]: !status
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[COMMAND]: !players
[COMMAND]: !players
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connected
[INFO]: Connecting to IRC
[COMMAND]: !status
[COMMAND]: !players
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[COMMAND]: !status
[COMMAND]: !players
[COMMAND]: !motd
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[COMMAND]: !status
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !status
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !players
[COMMAND]: !define giggle
[COMMAND]: !define tbh
[COMMAND]: !define omfg
[COMMAND]: !define brb
[COMMAND]: !define go outside
[COMMAND]: !define outside
[COMMAND]: !definde "go outside"
[COMMAND]: !define "go outside"
[COMMAND]: !define walk
[COMMAND]: !define Cake
[COMMAND]: !define Cheese
[COMMAND]: !define glados
[COMMAND]: !define portal
[COMMAND]: !define CherryPie
[COMMAND]: !define Computer
[COMMAND]: !define Pixels
[COMMAND]: !define ShinexusBot
[COMMAND]: !define ShinexusUK
[COMMAND]: !define UK
[COMMAND]: !define USA
[COMMAND]: !define Denmark
[COMMAND]: !define lego
[COMMAND]: !define pda
[COMMAND]: !define irc
[COMMAND]: !satus
[COMMAND]: !status
[COMMAND]: !define bbl
IRC ERR: [object Object]
[COMMAND]: !define kaflerp
[COMMAND]: !define kaflerp
[COMMAND]: !relay enable
[COMMAND]: !relay add #computercraft
[COMMAND]: !relay disable
[COMMAND]: !define ermahgerd
[COMMAND]: !define kappa
[COMMAND]: !define MarcusD
[COMMAND]: !define Danny
IRC ERR: [object Object]
[COMMAND]: !define kupo
IRC ERR: [object Object]
[COMMAND]: !define aybone
[COMMAND]: !define shinexusbot
[COMMAND]: !define ShinexusBot
[COMMAND]: !define !
[COMMAND]: !define shinexus
[COMMAND]: !define mod
[COMMAND]: !define MarcusD
[COMMAND]: !define Marcus
[COMMAND]: !defin pedobear
[COMMAND]: !defin pedobear
[COMMAND]: !define pedobear
IRC ERR: [object Object]
[COMMAND]: !define Dannysmc95
[COMMAND]: !define Marcus
[COMMAND]: !commands
[COMMAND]: !players
[COMMAND]: !define marcus
[COMMAND]: !define itsame
[COMMAND]: !define it's a me
[COMMAND]: !define simeon
IRC ERR: [object Object]
[COMMAND]: !define Kevin
[COMMAND]: !show-off
[COMMAND]: !define show-off
[COMMAND]: !define Danny
IRC ERR: [object Object]
[COMMAND]: !define bitchslap
[COMMAND]: !define outside
[COMMAND]: !define people
[COMMAND]: !status
[COMMAND]: !list
[COMMAND]: !players
[COMMAND]: !define Chagaroth
[COMMAND]: !define IRC
[COMMAND]: !define pidgeon
[COMMAND]: !define ( ͡° ͜ʖ ͡°)
[COMMAND]: !define lennyface
IRC ERR: [object Object]
[COMMAND]: !define Marcus
[COMMAND]: !define simon
IRC ERR: [object Object]
[COMMAND]: !defome food
[COMMAND]: !define food
[COMMAND]: !define food
[COMMAND]: !define Marcus
[COMMAND]: !define food
[COMMAND]: !players
[COMMAND]: !list
[COMMAND]: !status
[COMMAND]: !player
[COMMAND]: !define gl
[COMMAND]: !define sush
[COMMAND]: !define shush
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connected
[INFO]: Connecting to IRC
[COMMAND]: !!! :D
[COMMAND]: !players
[COMMAND]: !define dho
[COMMAND]: !players
[COMMAND]: !define banana
[COMMAND]: !dick
[COMMAND]: !define apple
[COMMAND]: !define mango
[COMMAND]: !define marcus
[COMMAND]: !define onion
[COMMAND]: !define pear
[COMMAND]: !define markdown
[COMMAND]: !players
[COMMAND]: !define curiosity
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
TypeError: Cannot read property '1' of null
at parseMessage (c:\Users\danny\Documents\Danny\Projects\Server_bot\node_modules\irc\lib\parse_message.js:39:28)
at iterator (c:\Users\danny\Documents\Danny\Projects\Server_bot\node_modules\irc\lib\irc.js:753:27)
at Array.forEach (native)
at Socket.<anonymous> (c:\Users\danny\Documents\Danny\Projects\Server_bot\node_modules\irc\lib\irc.js:752:15)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:538:20)
[INFO]: Starting ShinexusUK Server IRC Bot
[INFO]: Connecting to IRC
[INFO]: Connected
[COMMAND]: !help
[COMMAND]: !define person
[COMMAND]: !commands
[COMMAND]: !software
[COMMAND]: !define snow
Do you make programs for computercraft? I have a few new API's including the App Store, SocialNet, User Database and (in-progress) Web browser/parser. If you are interested in using them send me a IM/PM on IRC.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment