aidanrwt / twitch-plays

Twitch IRC bot that takes input from the chat and presses the corresponding key.
MIT License
275 stars 59 forks source link

Anarchy/Democracy?? #4

Closed Krushchevawn closed 9 years ago

Krushchevawn commented 10 years ago

Is there Any plan to add anarchy/democracy slider or do you have any idea how to add the anarchy/democracy slider?

ynohtna92 commented 9 years ago

The ircbot is probably not connecting to the channel. You need to make sure that your config https://github.com/ynohtna92/twitch-plays/blob/master/config/config.py has the correct account details and irc settings. The server IP may have changed from when this was made so you might have to go find it.

wreck3d commented 9 years ago

Yeah, my config is definitely right. Where should I start looking for the server IP?

EDIT: Oh wait, in your original config you have the IP at: 199.9.252.26 I changed it to irc.twitch.tv to connect. Should I not have done that?

EDIT2: Changed to the IP above. Made my game stop registering chat commands. Changed back to irc, working again.

ynohtna92 commented 9 years ago

Looking at it again. formatoutput should be

function formatOutput(left, right){
  var buffer_size = 20;
  var buffer_used = 0;
  var whitespace_size = 1;
  var img = "";

  if (right == "down"){
    right = "  " // Clear instruction
    img = '<img src="downarrow.png" height="16" width="16">'
  }

  buffer_used = right.toString().length + whitespace_size;
  var buffer_left = buffer_size - buffer_used;
  if (buffer_left > left.length) {
    whitespace_size += buffer_left - left.length;
  }
  var left_end = buffer_left;
  left = left.substring(0, left_end);
  return left + Array(whitespace_size + 1).join(" ") + img + right;
};
wreck3d commented 9 years ago

Not sure what changed from the one you just posted to the original, but I pasted over it in the index.html file, then copy & pasted the code below 6 times, so here's what I have:

function formatOutput(left, right){
  var buffer_size = 20;
  var buffer_used = 0;
  var whitespace_size = 1;
  var img = "";

  if (right == "up"){
    right = "  " // Clear instruction
    img = '<img src="http://i.imgur.com/TRWSndF.png" height="16" width="16">'
  }

    if (right == "down"){
    right = "  " // Clear instruction
    img = '<img src="http://i.imgur.com/ZJc5rgj.png" height="16" width="16">'
  }

    if (right == "left"){
    right = "  " // Clear instruction
    img = '<img src="http://i.imgur.com/dCDjvIA.png" height="16" width="16">'
  }

    if (right == "right"){
    right = "  " // Clear instruction
    img = '<img src="http://i.imgur.com/LfjpijV.png" height="16" width="16">'
  }

    if (right == "a"){
    right = "  " // Clear instruction
    img = '<img src="http://i.imgur.com/atGfsuQ.png" height="16" width="16">'
  }

    if (right == "b"){
    right = "  " // Clear instruction
    img = '<img src="http://i.imgur.com/dOzvma1.png" height="16" width="16">'
  }

Still not sure why the inputs don't show on the IP URL page, though :/

ynohtna92 commented 9 years ago

are the commands showing on the cmd? Are there any errors when you press F12 on the page

wreck3d commented 9 years ago

Here's my F12 result: err

Red X says: WebSocket connection to 'ws://localhost:8888/ws' failed: Error during WebSocket handshake: Unexpected response code: 403

EDIT: This shows in CMD every-so-often, but I didn't think anything of it since everything is still working fine.

ynohtna92 commented 9 years ago

The console tab please. Make sure that a couple of commands register in cmd first.

wreck3d commented 9 years ago

Yeah, everything regarding CMD Prompt has been fine. Commands register there everytime from multiple people :)

Here's the error (as I edited in above)

err3

EDIT: I view-source'd it and it appear it's on line 171 on the index file

ynohtna92 commented 9 years ago

Try run it as admin. 403 is an access restriction error.

wreck3d commented 9 years ago

I also noticed this just now, if it matters: And you mean run CMD Prompt as Admin? err4

wreck3d commented 9 years ago

Nope. Still getting the same error

EDIT: I found this: https://github.com/moccu/django-omnibus/pull/25

Would that help? The post says the answer is: to simply add a check_origin method that returns True. Where would I do that and how?

ynohtna92 commented 9 years ago

Try add

def check_origin(self, origin):
    return True

in lib\web.py after line 16 so it looks like

class SocketHandler(websocket.WebSocketHandler):

    def check_origin(self, origin):
            return True

    def open(self):
        if self not in cl:
            cl.append(self)

    def on_close(self):
        if self in cl:
            cl.remove(self)
wreck3d commented 9 years ago

That gave me this: err

EDIT: nevermind, fixed that. hold on.

EDIT2: Ok, on the IP URL adress, it now says my socket port is open! :D Time to test

ynohtna92 commented 9 years ago

Indentation in that file is wrong now. I used tabs to indent so you will have to remove all the spaces and indent it all with a tab otherwise it will error.

wreck3d commented 9 years ago

Yeah, I edited my post (I do that a lot it seems, ha). ^

Alright, the IP URL is now receiving commands! BUT, the images still aren't showing in place of the directional inputs.

wreck3d commented 9 years ago

Here's how I have my index.html set up. Look fine? err2

ynohtna92 commented 9 years ago

It should be working then. You might need to add css for the images so they float instead of going to the end of line. You can verify the img string is being added by inspecting the line of the command.

wreck3d commented 9 years ago

Naw, just showing regular directional inputs (up, right, etc) instead of the images. I mean, it's showing up in the Inspect Element box. Not sure why the image isn't displaying, though. err3

wreck3d commented 9 years ago

I want the images to show up exactly where the regular text does. Would I just float right for that?

< style>
img {
    float: right;
}
< /style>
ynohtna92 commented 9 years ago

Ok you also have to change the following:

input_stream_buffer[17] = json.button.formated;

into, to use the method we just made.

input_stream_buffer[17] = formatOutput(json.button.user, json.button.button);

and just a few lines down

$('#' + i).text(input_stream_buffer[i]);

to

$('#' + i).html(input_stream_buffer[i]);

Then adjust it all with css. Good Luck

wreck3d commented 9 years ago

You're a saint, I don't care what anyone tells you, lol. All I did was edit the lines of code how you said to above and it came out fine without having to edit/add any CSS stuff like you mentioned. :) succc

wreck3d commented 9 years ago

Hey, new quick question: This popped up in my CMD Prompt. Any idea how to fix it real quick? First time it's shown. err

ynohtna92 commented 9 years ago

http://stackoverflow.com/a/11893504 follow this guide.

wreck3d commented 9 years ago

Yeah, I know how to add a favicon, but I was just wondering why it's only shown up this one time and not all the other hours I've had the Prompt open (like when I was getting that 403 error). Thanks!

Sent from my iPhone

On May 18, 2015, at 6:45 PM, ynohtna92 notifications@github.com wrote:

http://stackoverflow.com/a/11893504 follow this guide.

— Reply to this email directly or view it on GitHub.