Unihedro / JavaBot

Java based chat bot that runs in Java room of Stack Overflow Chat.
Apache License 2.0
15 stars 4 forks source link

java.nio.file.NoSuchFileException: bot.properties #63

Open ravirupareliya opened 8 years ago

ravirupareliya commented 8 years ago

I had this file along with src, javadoc, pom.xml and other files. But still it is showing me that NoSuchFileException for bot.properties.

and here what i have inside bot.properties:

LOGIN-EMAIL=myEmailAddressPASSWORD=accountPasswordROOMS=TRIGGER=** SITE=stackoverflow

Where should i put that?

Vogel612 commented 8 years ago

the bot.properties goes into the root of the project, if you run with maven. Otherwise it needs to be in your current working directory, IOW the directory where you invoke your java process.

Also remember that the format of bot.properties requires linebreaks (I assume they just didn't get formatted correctly)

Furthermore the login to chat may currently be non-functional, because there have been breaking changes to the way SE exposes chat-login. Drop me a note regarding how it goes :)

ravirupareliya commented 8 years ago

yes, its working now, i have just copied bot.properties in root where jar is created.

As you said there might be some change in SE login, yes there is small change in login page of SE.

This is the line we need to change in StackExchangeChat.java inorder to login with stackoverflow.

HtmlForm loginForm = loginPage.getFirstByXPath("//*[@id=\"se-login-form\"]");

replace it with

HtmlForm loginForm = loginPage.getFirstByXPath("//*[@id=\"login-form\"]");

Apart from this, there is one more query i have, i have successfully logged in to SE chat and bot has posted welcome message also, but how can i interect with my bot.

I have set trigger value to \ but how should i use it? because i have tried a lot and seems bot is not listening any request. Do i need to upload my jar file on live server? or is it ok to run it in local?

Vogel612 commented 8 years ago

It should be okay to run the bot locally. To interact with the bot it should be sufficient to just write a message beginning with the trigger value. That should invoke a command.

Make sure to have a look at your immediate window. The bot may log diagnostic information there, when it doesn't respond in chat.

example message:

**help
ravirupareliya commented 8 years ago

yes i tried that, here is the room i am doing all this things http://chat.stackoverflow.com/rooms/110563/nothing-to-do

it is not responding, neither it is showing any message in my console. You can refer this screenshot.

chat bot

Vogel612 commented 8 years ago

can you verify for me whether StackExchangeChat#queryMessages is invoked? and if it is invoked whether it actually propagates any results?

ravirupareliya commented 8 years ago

yes it is invoked, but error is in StackExchangeChat#handleChatEvents , it is going in catch block.

   java.lang.NullPointerException
    at com.gmail.inverseconduit.datatype.ChatMessage.toString(ChatMessage.java:38)
    at java.lang.String.valueOf(Unknown Source)
    at java.lang.StringBuilder.append(Unknown Source)
    at com.gmail.inverseconduit.chat.StackExchangeChat.lambda$null$24(StackExchangeChat.java:322)
    at com.gmail.inverseconduit.chat.StackExchangeChat$$Lambda$34/2000460090
.accept(Unknown Source)
    at java.lang.Iterable.forEach(Unknown Source)
    at com.gmail.inverseconduit.chat.StackExchangeChat.lambda$handleChatEvents$25(StackExchangeChat.java:320)
    at com.gmail.inverseconduit.chat.StackExchangeChat$$Lambda$33/2064677091.accept(Unknown Source)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.forEach(Unknown Source)
    at com.gmail.inverseconduit.chat.StackExchangeChat.handleChatEvents(StackExchangeChat.java:318)
    at com.gmail.inverseconduit.chat.StackExchangeChat.queryAndHandleRoomEvents(StackExchangeChat.java:264)
    at com.gmail.inverseconduit.chat.StackExchangeChat.lambda$queryMessages$20(StackExchangeChat.java:254)
    at com.gmail.inverseconduit.chat.StackExchangeChat$$Lambda$30/1376907859.accept(Unknown Source)

after lot of debugging i found that events.getSite() is returning null in StackExchangeChat#handleChatEvents

Unihedro commented 8 years ago

Is this still happening?