JBader89 / PlugBot

A Plug.dj bot for the popular music sharing site Plug.dj
6 stars 5 forks source link

Installation? #3

Closed 70hundert closed 10 years ago

70hundert commented 10 years ago

Hi Jeremy!

I downloaded your zip file and tried to install it. I have to admit that I'm totally new to this!

I unzipped your files to a folder and ran

npm install node-uuid request uuid node-html-encoder cheerio ws

via cmd-console inbetween this folder.

Then I uploaded the whole folder to my webspace and tried to run the bot.js, but nothing happened as assumed.

After that I opened the bot.js and edited the ROOM-name and the last-fm-key, -secret, -username and -password to my settings.

In line 24 I changed the Plug-Dj-username and -password to my account name and changed the password.

But even after this I couldn't connect to the bot.

Can you please tell me how to get this running? Is a debug-function somehow available? Or could you point me to a sort of tutorial for this? That would be awesome!

ghost commented 10 years ago

To run the bot properly, you also need to npm install:

  1. simple-lastfm
  2. dictionaryapi
  3. wikijs
  4. google-geocoding
  5. weathers
  6. math-lexer
  7. mstranslator
70hundert commented 10 years ago

Hi Spiderlover...and thank you for your answer!

So I started with a new folder in which i unzipped this package, opened cmd-console, navigated to this folder and typed in

npm install node-uuid request uuid node-html-encoder cheerio ws

After that I installed all the packages you mentioned in your comment. This was ok with no errors.

After that I did edit again the ROOM-name and the last-fm-key, -secret, -username and -password to my settings. In line 24 I changed the Plug-Dj-username and -password to my account name and changed the password.

But still no activation of the bot nor any other "reaction" in the chat window or browser. How can I see an error-log or a debug-info for finding out what is going wrong?

Thank you!

ghost commented 10 years ago

hmmm, that's pretty odd. It works fine on my end.

70hundert commented 10 years ago

So the way I tried to get this running is correct? I researched a lot in the internet, and this way was my conclusion of thi rresearchs, but I don't know if all is done correctly in this way?

ghost commented 10 years ago

I suggest moving your code to Cloud9. You can login instantly to it with your GitHub account, and when you run your bot through it, it shows debugging info in its console.

JBader89 commented 10 years ago

Hey 70hundert,

Here are a few suggestions that might help:

  1. Your bot must have its own twitter account with its own username/password so that it can sign onto Plug.dj. So if you haven't already made an account for it, this would definitely be your problem.
  2. You need to run 'npm install simple-lastfm', 'npm install dictionaryapi', 'npm install wikijs', 'npm install google-geocoding', 'npm install weathers', 'npm install math-lexer', and 'npm install mstranslator' if you want to get many of the commands working.
  3. For ones that require a key/password you also need to set up accounts on those sites to get your own key/password. I think that this is the case for last.fm, merriam-webster dictionary, and microsoft translate. That being said, you don't need to include all of these commands in your bot, so you could just omit these if that makes it easier. I suppose it may work with my keys/passwords, now that I think about it, as I left them public on GitHub, so this may not be a problem.

I will soon update the repo so that these instructions are in the README. In any case, let me know if these suggestions help! :)

Regards, Jeremy

70hundert commented 10 years ago

Hi Jeremy!

Thank you for your reply!

After I received this I started from scratch to get this running. So I unzipped the zip again again and moved to the folder in the cmd-console.

There I first typed in

  1. npm install node-uuid request uuid node-html-encoder cheerio ws
  2. Same for all the other packages you and Spiderlover mentioned (again without any problem).
  3. Uploaded folder to my webspace
  4. Edited the bot.js:

Line 2 : var room - changed to my roomname

Line 8: my Lastfm-api-key Line 9: my Lastfm-api-secret Line 10: my Lastfm-username Line 11: my Lastfm-password

Line 25: my new Twitter-username Line 26: my new Twitter-password

  1. saved the file on my webspace
  2. Opened my "room" in Plug.DJ
  3. Created a new bookmark with the following content: Name: JBader-script URL: javascript:(function(){$.getScript('http://www.xxx.com/PlugBot-master/bot.js');}());
  4. Clicked on the new bookmark - > nothing happens again

I opened the Firebug-console and saw an error which appeared after I clicked on the Bookmark:

Error: Module name "plugapi" has not been loaded yet for context: _. Use require([])

Hope this helps to sort the problem out.

Thank you again for your support!

Regards, Marc

JBader89 commented 10 years ago

Oh I see - it seems I forgot to mention, you need to run 'npm install plugapi' as well, so start with that. Also, I run my bot from my terminal by typing 'node bot.js' rather than using that bookmark method. In other words, I have mine running through Node.js entirely. Your bookmark method may work as well, but I've never tested that so I don't know. Running it from the terminal works for me perfectly though. Let me know if that helps.

ghost commented 10 years ago

^, my bot worked fine with the plugapi in a folder on cloud9 without npm installing it.

70hundert commented 10 years ago

And it's me again...

So I followed your instruction and started with

npm install plugapi

followed by steps 1-4 above.

Once again the bookmark-way gives me this error:

Error: Module name "plugapi" has not been loaded yet for context: _. Use require([])

And when I try to run

node bot.js

in the terminal inside my "project"-folder I get this error:

C:\bader2>node bot.js

module.js:340 throw err; ^ Error: Cannot find module 'coffee-script' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object. (C:\bader2\plugapi\src\index.js:1:63) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17)

The coffe-script v 1.6.3 is running on my computer, I installed it before when I tested a lot of other scripts (which didn't work)...

So do I need to install the coffee-script in this folder in one of the first steps?

Otherwise I'm gonna try the way Spiderlover described - via Cloud9...

Thanks a lot for your time you already spent helping me!

70hundert commented 10 years ago

I tried it again with installing coffee-script as 2nd step...no improvement, all the same as before...

Then I tried it in Cloud9...nice site and handy tool i think so far (as I understand this all)...

So I uploaded the files of your zip there and ran the edited bot.js first (Spiderlover told about "without npm installing"), but this didn't work. Next step was to run step 1-5 (npm installations of plugapi, coffee-script, npm install node-uuid request uuid node-html-encoder cheerio ws, the other packages).

After that I first opened the "bot.js" in Cloud9 and started the process by clicking "Run"...this lead to the following error:

$ node bot.js

module.js:340 throw err; ^ Error: Cannot find module 'plug-dj-login' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Function.PlugAPI.getAuth (/var/lib/stickshift/52e5dcf34382ec9d650000c6/app-root/data/753164/plugapi/src/client.js:108:19) at Object. (/var/lib/stickshift/52e5dcf34382ec9d650000c6/app-root/data/753164/bot.js:24:9) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:901:3

And I did receive the same error when i tried to use "node bot.js" in the terminal in Cloud9.

Error: Cannot find module 'plug-dj-login'

I can't find any file that is named like this...by searching the content of all files nested in my folder (on CLoud9 and on my hd) I could only find a line in /plugapi/src/client.js

Line 108: var plugLogin = require('plug-dj-login');

I also found while searching the "repl.js" in the "plugapi"-subfolder...there I added my auth and Room-URL.

Hope this leads to a solution somehow... :)

JBader89 commented 10 years ago

Hmm it's hard for me to say what the problem may be because I can't see how you set up your directory. The bot.js file should be at the same level as the plugapi folder (not inside plugapi). From that level you should run all of the npm install commands. If you did all that correctly, I'm not sure why it isn't working, to be honest. Perhaps you could copy and paste what you have in bot.js on pastebin.com, send us the link, and we'll check out if everything looks good.

70hundert commented 10 years ago

Hello again!

Yeah, the file-structure is the same like the unzipped package, so the bot.js is outside the plugapi-folder. Only difference is the added "node_modules"-folder which got created during the package-installation...this one is in the same "root" as the bot.js and the plugapi-folder...

So here's my bot.js: http://pastebin.com/sJ5XLdNM

JBader89 commented 10 years ago

So where it says 'var ROOM = 'xxx';' did you update that to your room name? It needs to be how it looks in the URL. Like 'var ROOM = 'chillout-mixer-ambient-triphop';'

70hundert commented 10 years ago

sure...just xxx-ed it for the pastebin!

JBader89 commented 10 years ago

Ok, so isn't a problem with your code then I don't think. I wish I had more ideas. Again, it's tough to tell what the problem is without me seeing what's happening first-hand. I'm also kinda new to this as well, but I was able to get it set up. The user that helped me out is named "atomjack". He wrote the plugapi - maybe he could help you?

70hundert commented 10 years ago

Hello once again! So I contacted "atomjack" because I couldn't get it running on my own. He told me to install the plug-dj-loging via the command "npm install" to install this completely with all packages, but this didn't work for me. So I ended in installing it by typing

npm install plug-dj-login

After that I was able to start the bot via "node bot.js" in the terminal...nice!

Now my last problem seem to be the lastfm-commands like .artist, .track, .genre, these result in a new error:

\project-name\node_modules\simple-lastfm\lib\index.js this._getInfo($.extend(opt, { ^ TypeError: Object function ( w ) { if ( !w.document ) { throw new Error( "jQuery requires a window with a document" ); } return factory( w ); } has no method 'extend' at [object Object].Lastfm.getArtistInfo

Couldn't sort that out yet, but nearly all other commands are running smoothly (except .grab, but I saw the issue-post to this, gonna check this out; maybe another command as well, need to check - just checked it: .skip isn't working too atm).

Last one: I saw your post on stackoverflow about running the bot 24/7. Did you sort that out with "forever"?

Cheers, Marc

JBader89 commented 10 years ago

Hey Marc,

Glad to hear you've made progress. That makes sense that "npm install plug-dj-login" would solve that problem - I should have thought of that. In terms of the .grab command, you just need to change "if (data.from=='TerminallyChill'){" to your username. For the last.fm bug, you probably need to make your own account with your own api_key, api_secret, username, and password. Let me know if that works. I've talked with atomjack, and apparently the .skip command is just currently broken - I think he's looking into this. That's funny that you saw my stackoverflow post :D how did you find that?! I haven't looked into "forever" yet, but my plan is to do it after I've completed all of the commands I wanted. In fact, I am pretty close to satisfying all the goals I had for my bot, so "forever" will be coming soon. Let me know if you run into any other problems.

Regards, Jeremy

70hundert commented 10 years ago

Hi Jeremy!

The .grab-command I could fix earlier by the "Issue" on here, but thanks for that!

And sure I did create a new API for lastfm; I did use it a few years ago, but I can't remember anything...and it has been more PHP than Javascript. I wrote in atomjack's github about that problem, where it is explained a bit more:

https://github.com/atomjack/simple-lastfm/pull/3

YOur stackoverflow-post I found by searching for "simple-lastfm" over there :) And then I saw you name :) so all by random...

I looked at "forever" only for short; but you're right in getting all commands running first, then try to get it running 24/7.

Thank you again for your suggestions and help!

Marc