atomjack / plugbotapi Goto Github PK
View Code? Open in Web Editor NEWAn API for creating bots on plug.dj
An API for creating bots on plug.dj
Whenever i run build.cmd for PhantomJS 2.0, it doesn't build at all, it just gives me 2 blank log files.
OS: Windows 7 Professional SP1 64-Bit
Computer: Dell Inspirion N411Z
is it possible for someone to do a tutorial on how to install phantomjs on windows. I have no idea what the hell I am doing
Howdy,
Usually I would get a stream.js error when plug was under heavy load but now it seems that it's just regularly happening.
stream.js:94
throw er; // Unhandled stream error in pipe.
At a lost of how to prevent this from consistently killing my bot
I know there was an update to the moderateBanUser code shortly before "the update", and I haven't been able to get that code to work since. If this code working? My experience with it has been that the callback fires but the bot doesn't actually ban anyone.
Ok, I think I only have one remaining issue that's preventing me from switching full time to this API. Sometimes it doesn't seem to want to connect. After a long timeout, a message like this will appear:
phantom stdout: onStatusError ==> 15
phantom stdout: http://plug.dj/_/static/js/room.aa4ab92.js:26 in onStatusError
Room Join Error :: 15
http://plug.dj/_/static/js/room.aa4ab92.js:26 in onServiceError
If that happens, I have to manually stop and restart the script because it doesn't actually close, nor does it connect to the room. If it would error out, I could catch it with Forever and restart it automatically.
This is different than the c[3000 Go Away message... I still get that occasionally too on startup, but the API seems to handle that gracefully and reconnects on it's own.
bot.moderateMoveDJ(targetID, iPos, function(){});
Any time I try to use moderateMoveDJ, I get the following unknown endpoint error. I've verified that I'm passing valid values for targetID and iPos.
ERROR: onStatusError ==> 15
ERROR TRACE: [ { file: 'http://plug.dj/_/static/js/room.aa4ab92.js',
line: 26,
function: 'onStatusError' } ]
Server Error ==> Unknown endpoint
0 = U
1 = n
2 = k
3 = n
4 = o
5 = w
6 = n
7 =
8 = e
9 = n
10 = d
11 = p
12 = o
13 = i
14 = n
15 = t
After a time, it seems the Woot / Meh functions no longer work. They don't produce an error, the just no longer affect the bot's behavior.
(And, as a side note, they're missing from the readme file as well.)
How can you download phantomjs 2.0 for the plugbotapi?
bot.moderateBanUser(targetID, bot.API.BAN.HOUR, function() {});
This is producing a permanent ban rather than a one hour ban. What format should the duration be? For the old API I had it as the time in minutes (so 60 in this case) but that also produced a perm ban in this API.
Seems a bit like this is API is abandoned since it hasn't needed any changes as of late, but I'll ask anyway. It seems like the bot "sees" HTML entities and emojis in a translated form - for example &
is seen by the bot as &
and :smile:
is seen as pure HTML code. This didn't use to happen - the bot used to see them exactly as typed. Is there a way to fix this to work the way it used to?
This is rather strange. After running fine for awhile, the bot went mute - it was completely unable to send chat messages to the room. The log files for the bot indicate that it was still functioning properly, just none of the announcements it normally makes were shown in the room.
Log segment:
[14:03:57] djAdvance: Stallion Duck is now playing "Another You" by Of Mice & Men
sio disconnect
sio disconnect
[14:05:13] Left: Stallion Duck
[14:05:13] djAdvance: Smokeout is now playing "Mr. Highway's Thinking About The End" by A Day To Remember
[14:09:14] displayStats
[14:09:18] djAdvance: DJ_AirTime is now playing "Lost That Loving Feeling Lyrics" by Righteous Brothers
[14:12:42] displayStats
[14:12:46] djAdvance: MegaRsmm is now playing "November Rain" by Guns N' Roses
After the "sio disconnect" messages happened, the bot went silent. As you can see above the events were still firing, but at each of those event logs the bot should send a message to the room but nothing came through.
A mod in the room at the time attempted to use a bot command to restart the bot, but the attempt to do so was not logged and the bot did not restart as it should, so it's possible the bot could no longer see chat either.
Manually stopping / restarting the script brought the bot back to normal operation.
While reviewing the logs I found this. I wasn't in the room at the time, so unfortunately I can't comment as to whether or how it affected the bot.
ERROR: onStatusError ==> 15
Server Error ==> Unknown endpoint
0 = U
1 = n
2 = k
3 = n
4 = o
5 = w
6 = n
7 =
8 = e
9 = n
10 = d
11 = p
12 = o
13 = i
14 = n
15 = t
The only thing possibly worthy of mention was that within 3 minutes of this, the bot encountered another of the "sio disconnect" errors I reported in #12.
I know it hasn't been updated yet but I figured I'd get a convo going. :)
My error is "TypeError: Cannot read property 'attribs' of undefined" in the plug-dj-login/index.js file on line 79
Plug had a lot of issues over the weekend. I had some stability issues with the bot as well, but I assumed it was Plug related. After things seemed to settle down with Plug though, I still wasn't able to get the bot back online. I logged in as the bot to disagnose and was able to login fine. I then checked and found that there was a new auth code. Once I loaded the new code into the bot, it loaded without issue.
Is there any way that an invalid auth code can be detected & logged? This would have been 10x easier to diagnose if there was. (My bot uses Facebook to authenticate.)
Figured I'd start a thread about it ;)
bot.moderateAddDJ(config.botId, function(){});
bot.moderateRemoveDJ(config.botId, function(){});
Neither seems to work. Yes, I've confirmed that config.botId
is the actual bot UID... I've even replaced it with the actual UID number instead of a variable - it didn't help. If I put another user's UID in there instead, such as my own, the commands work fine.
Any thoughts on this?
phantom stderr: PhantomJS has crashed. Please read the crash reporting guide at https://github.com/ariya/phantomjs/wiki/Crash-Reporting and file a bug report at https://github.com/ariya/phantomjs/issues/new with the crash dump file attached: /tmp/33f123c6-ff15-2aaf-67ac10e7-0bd6d0a1.dmp
AssertionError: signal killed phantomjs: SIGSEGV
at Console.assert (console.js:102:23)
at ChildProcess.<anonymous> (/root/yay/node_modules/plugbotapi/node_modules/phantom/phantom.js:128:21)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at Process.ChildProcess._handle.onexit (child_process.js:789:12)
and I have literally no idea where to go from here.
// connect to plug
lib.api.getAuth(_auth,function(err,auth){
if (err) return $err("Error Getting Auth.",err);
note("Got Auth, Connecting to plug...","gray");
global.$bot = new lib.api(auth);
$bot.setMaxListeners(20);
// $bot.debug.SHOWAPI = false;
// $bot.debug.SHOWOTHER = false;
$bot.connect($cfg.room);
$bot.on('roomJoin',function(){
$bot.getUsers(function(users){
$bot.getMedia(function(media){
$bot.getStaff(function(staff){
$bot.getWaitList(function(waitlist){
$bot.getDJ(function(dj){
$bot.getRoomScore(function(score){
return console.log(score);
});
});
});
});
});
});
});
});
Plug.dj went down this afternoon for a software update and since it has come back online neither of my bots are working. They appear to connect but see no other users in the room.
It's like the data isn't making it through when an event fires. For example, this code:
bot.on('roomJoin', function(data) {
util.log(util.inspect(data));
Yields:
18 Jun 17:28:28 - undefined
so the roomJoin event is being processed, but data is empty/undefined .
I am thinking of keeping my bot on the old api, because phantomjs 2.0 is way too confusing to set up for this new bot api.
I am running pretty default code:
var _auth = {},
room = 'room',
api = require('plugbotapi');
api.getAuth(_auth,function(err,auth){
if (!err) {
console.log("Got auth! Connecting To Room...");
global.$bot = new api(auth);
$bot.connect(room);
$bot.on('roomJoin',function(){
console.log("Joined Room! Powering On.....");
$bot.getUsers(function(users){
$bot.getMedia(function(media){
return console.log(users,media);
});
});
});
}
});
But I don't get any of my logs after Got Auth!
, and then (after around 30 seconds of just sitting), I get this message in console:
phantom stdout: TypeError: 'null' is not an object (evaluating 'e.transport.onClose')
followed by this one:
phantom stdout: http://plug.dj/_/static/js/core.53afc28.js:144
Hopefully this is a stupid question. I tried to set up PhantomJS on Cloud9 IDE and was unsuccessful - it kept running it out of drive space. I have about 900 mb free space there, but every time I tried the "git submodule update" step it exhausted all available drive space. I don't actually run my bot from Cloud9, but it's sure a whole lot simpler to develop it there, so it would be nice if there was a work-around for this. Is there?
For some reason, my voteUpdate event doesn't seem to be firing when people vote. I hesitated to ask about this because I figured it must be my code's fault since the rest of the events work but I can't find the issue. I've stripped it down to the following though and I'm still not getting anything:
bot.on('voteUpdate', function(data) {
console.log(data);
});
A normal startup looks like this:
debug: sjs connect
debug: sio connecting websocket
debug: sio connect
debug: sjs join rock-madness
debug: room joined
debug: sio join rock-madness
Today one of the restarts looked like this instead:
debug: sjs connect
debug: sjs disconnect SimpleEvent(type=close, code=3000, reason=Go away!, wasClean=true)
debug: sjs attempting to re-connect to the server 1
debug: sio connecting websocket
debug: sjs connect
debug: sio connect
debug: sjs join rock-madness
debug: room joined
debug: sio join rock-madness
When this happened, every time the bot was issued a command it would double respond. Regular events seemed unaffected (djAdvance, userJoin, etc).
Looks like the PhantomJS Team has built 2.0 for us, so that takes out the hard part of setting this API up for our bots.
https://groups.google.com/forum/#!topic/phantomjs/cgTH-jqCSGg
Just started getting "Sorry, I couldn't seem to connect." -- anyone else?
If a line of text sent with the chat action has multiple escaped characters, it fails.
This code:
bot.chat(data.from + ', you\'re in position ' + (iPos+1) + ', it\'ll be your turn to DJ in roughly ' + ((iPos+1) * iAvgLength).toFixed(0) + ' minutes.');
is producing this:
debug: result = API.sendChat('username, you\'re in position 10, it'll be your turn to DJ in roughly 40 minutes.');
Note that "it'll" is not properly escaped in the debug output, though it is in the original API call. It seems it fails on the second escaped character, as "you're" was escaped properly. Because of this, the text doesn't actually get output to the room.
In this example, I've changed "it'll" to "it will" to bypass the problem and the text properly sends.
I want to use Sourcegraph for plugbotapi code search, browsing, and usage examples. Can an admin enable Sourcegraph for this repository? Just go to https://sourcegraph.com/github.com/atomjack/plugbotapi. (It should only take 30 seconds.)
Thank you!
Is there an equivalent action to bot.vote('up') or bot.vote('down') to allow the bot to vote?
A lot of times on connect (especially within the last few days), the bot connects and sees zero users in the room... Since that's obviously not possible (he should at least see himself), I just added a line of code to restart if that happens... but is there something more going on here? He frequently tries to reconnect 10 times or more even when Plug appears to be working fine.
I also periodically find the bot just missing, though the logs say he's in the room and nothing's happening (to him the room looks idle even when it's not). That may be the same thing going on... not sure?
@atomjack I got this error when running my bot with the latest version of plugbotapi and phantomjs 2.0.
Error Log:
TypeError: Object [object Object] has no method 'connect'
at /var/lib/stickshift/52bdc9f44382ecfb8d000026/app-root/data/704711/Plug.DJ
at /var/lib/stickshift/52bdc9f44382ecfb8d000026/app-root/data/704711/node_modules/plugbotapi/index.js:188:11
at Request._callback (/var/lib/stickshift/52bdc9f44382ecfb8d000026/app-root/data/704711/node_modules/plugbotapi/node_modules/plug-dj-login/index.js:32:11)
at Request.self.callback (/var/lib/stickshift/52bdc9f44382ecfb8d000026/app-root/data/704711/node_modules/plugbotapi/node_modules/plug-dj-login/node_modules/request/request.js:129:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request. (/var/lib/stickshift/52bdc9f44382ecfb8d000026/app-root/data/704711/node_modules/plugbotapi/node_modules/plug-dj-login/node_modules/request/request.js:873:14)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage. (/var/lib/stickshift/52bdc9f44382ecfb8d000026/app-root/data/704711/node_modules/plugbotapi/node_modules/plug-dj-login/node_modules/request/request.js:824:12)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
Change the woot and meh icons to .icon-woot and .icon-meh respectively
Line 501:
if(which == 'woot')
$('.icon-woot').click();
else if(which == 'meh') {
$('.icon-meh').click();
}
If I had a bot written for the original API, how much effort would it be to migrate it over? Is the data being passed in the same structure?
PlugBotAPI.prototype.joinwaitlist = function() {
if (this.pageReady === true) {
$( "#dj-button" ).trigger( "click" );
}
};
PlugBotAPI.prototype.joinwaitlist();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.