|
Aleksei Vasiliev posted:How are IRC strings formatted? If the name of sender of message is always in front then you can just compare the beginning of inputLine with whatever poster name? Also contains() should work fine for this. inputLine.contains("AlekseiV");
|
# ? May 16, 2010 20:34 |
|
|
# ? May 9, 2024 15:41 |
|
Aleksei Vasiliev posted:I'm writing a really simple IRC bot just to learn poo poo and I'm trying to do something. I don't know what it's called. This is frustrating me. (i am bad at java/programming) You'll have to study the IRC RFCs first to work out how it lets you know where a message is from, then use split or the regex Pattern and Matcher classes to filter that out. This isn't something that's in the standard string library, it's specfic to IRC. I'd also strongly recommend using the codes defined in the RFCs rather than the messages, which can change from server to server. If you haven't already, you should also probably telnet in to your favourite IRC server and pretend to be an IRC client yourself - there's a good guide here - as this really helps you understand how everything works a lot more. Also I hope you realise nicks are not a good way to authenticate people if you're doing anything important. Writing an IRC bot from scratch is harder than it looks!
|
# ? May 16, 2010 20:39 |
|
LockeNess Monster posted:How are IRC strings formatted? If the name of sender of message is always in front then you can just compare the beginning of inputLine with whatever poster name? Wow, so if I just put the owner's name in my message I can run the bot? Nice!
|
# ? May 16, 2010 20:40 |
|
LockeNess Monster posted:How are IRC strings formatted? If the name of sender of message is always in front then you can just compare the beginning of inputLine with whatever poster name? quote::javamob!javamobi@hostname.com PRIVMSG #chatt :sup Just doing a contains will get false positives of anybody saying the bot owner's name. edit: gently caress; beaten. I've been using a bit of the RFC but also mostly just looking at the packets in Wireshark. My bot is poo poo and unreliable right now but I've only spent 30+ minutes on it so far. I don't think I'll have that much problem getting the IRC stuff, but does anybody have an idea of how to do something like the isFrom() thing I'm thinking of? Malloc Voidstar fucked around with this message at 20:46 on May 16, 2010 |
# ? May 16, 2010 20:43 |
|
Aleksei Vasiliev posted:That's the bot with a nick of javamob saying "sup" in channel #chatt. code:
e: looking at the packets in wireshark seems like a pretty clunky way of doing it but whatever works for you. I prefer telnet because you get the plain text which you're dealing with and nothing else. You can also try sending strings too, which is either difficult or impossible with wireshark. Using wireshark lets you see the 'best practices' the clients use though, I guess. Jonnty fucked around with this message at 21:07 on May 16, 2010 |
# ? May 16, 2010 21:04 |
|
Jonnty posted:e: looking at the packets in wireshark seems like a pretty clunky way of doing it but whatever works for you. I prefer telnet because you get the plain text which you're dealing with and nothing else. You can also try sending strings too, which is either difficult or impossible with wireshark. Using wireshark lets you see the 'best practices' the clients use though, I guess. quote::server.com NOTICE AUTH :*** Looking up your hostname...
|
# ? May 16, 2010 21:25 |
|
Aleksei Vasiliev posted:As far as I can tell you need to send the NICK command (which is the first client command) before it does any of that, which seems to be impossible using a telnet client. It ought to be possible using a telnet client since it's functionally equivalent to a computer (apart from being slightly slower but that shouldn't matter). The error you're getting is defined here and shows you haven't registered with the USER command yet, like that link I posted told you to. e: Although it looks like you have, so post the whole exchange you've had with the server so we can see what's happening.
|
# ? May 16, 2010 21:35 |
|
Turns out when using PuTTY you need to set "Telnet negotiation mode" to Passive to be able to telnet into an IRC server. Otherwise the server'll throw errors at you.
|
# ? May 16, 2010 21:42 |
|
You could download and take a look at how pircbot does things.
epswing fucked around with this message at 05:35 on May 17, 2010 |
# ? May 17, 2010 00:46 |
|
epswing posted:You could doesn't and take a look at how pircbot does things. Was going to suggest that, I've played around with it before. Very easy to use, runs its own irc client in main.
|
# ? May 17, 2010 03:10 |
|
Could anyone help me to understand the logical difference between these two similar methods for reading individual lines from a stream (which for some reason are producing wildly different results). I started off using this method which i thought would be fairly logically sound: code:
I tried playing around with the logic a little and came up with this instead, which works flawlessly: code:
|
# ? May 18, 2010 00:21 |
|
Partyworm posted:
I assume that readLine() returns a line and then next time it is called it will return the next line? That would at least explain why the first line is not output as readLine() is called in the if statement, it is found not to be null, so else is executed which calls readLine() again. lineOut is then the second time that readLine() is called. Step through your program line by line, writing down what happens (not what you think should happen, but what *actually* happens). That ought to help you fix your logical mistakes. You'll find out that your first method and your second method are not the same at all.
|
# ? May 18, 2010 00:32 |
|
Partyworm: Are 'read' and 'buff' a FileReader and a BufferedReader, respectively, or what? I'm not aware of any classes with a resetStream(String) method. Also, that is some crazy tabbing. I don't want to start a holy war, but however you choose to format your code it is imperative that you're consistent. For comparison: code:
code:
|
# ? May 18, 2010 00:45 |
|
lewi posted:I assume that readLine() returns a line and then next time it is called it will return the next line? That would at least explain why the first line is not output as readLine() is called in the if statement, it is found not to be null, so else is executed which calls readLine() again. lineOut is then the second time that readLine() is called. Thanks, you're right. How could i overlook something that obvious I woke up this morning after sleeping on it and before even looking at this thread i suddenly realized "holy poo poo, i'm reading two lines within the same method", and felt really dumb. Internet Janitor: 'read' is an instance of a 'Reader' class i wrote that simply initializes a FileReader and BufferedReader together with the file name as the only argument. It's largely superflous and unecessary (your earlier fix worked just fine) but i like to play around as i learn and get a feel for what works and what doesn't. resetStream() is basically a method within that Reader class that closes the stream and then re-initializes it. I'm sure there's probably a simpler built in way of doing that, but at this stage i like to get my chops into writing methods wherever i can as its all good practice in the end. And yeah, apologies for the horrible formatting - I tinkered with that method so much that all concern for 'form' pretty much went out the window. Partyworm fucked around with this message at 09:47 on May 18, 2010 |
# ? May 18, 2010 09:26 |
|
Hey guys. I'm struggling through a java class in school due to my teacher. He's a horrible teacher and I've had several friends who have tried taking the class with me drop out along with me. Next semester is the 2nd time I'm trying to take his class. I'm studying over the summer and I'm wondering what would be some good books to pick-up to help me through this class.
|
# ? May 18, 2010 18:35 |
|
This set of video tutorials is linked in the OP, check them out: http://sourceforge.net/projects/eclipsetutorial/files/ Edit: vvv No worries, let us know if they're any good. epswing fucked around with this message at 20:41 on May 18, 2010 |
# ? May 18, 2010 20:00 |
|
epswing posted:This set of video tutorials is linked in the OP, check them out: http://sourceforge.net/projects/eclipsetutorial/files/ Woops, I completely looked over it. I looked for a section on books/tutorials and didnt see anything.
|
# ? May 18, 2010 20:12 |
|
I have encountered a problem I cannot begin to figure out. I have a static method that works perfectly when I test it in the main method of that same class. Here is the header: code:
code:
Also, I get a warning that I have an unchecked conversion, as if the method were only returning a Map and not a Map<String, Object>. Is this because generics are stripped out at compile time and do not actually exist in the class file, or is it related to the other problem? edit: ARG! I didn't scour hard enough. I found an old version of the file that is definitely the culprit. The unchecked conversion issue seams to have cleared up as well. Malfeasible fucked around with this message at 23:28 on May 18, 2010 |
# ? May 18, 2010 22:58 |
|
I am working on some code which needs to determine if a point on the earth is within a polygon. Are there java libraries which would allow me to do this?
|
# ? May 19, 2010 21:29 |
|
WalltBeef: It's probably not the fastest solution, but if all you care about is 2d there's always the AWT Polygon class. Check out the contains() methods.
|
# ? May 19, 2010 23:48 |
|
Internet Janitor posted:WalltBeef: It's probably not the fastest solution, but if all you care about is 2d there's always the AWT Polygon class. Check out the contains() methods. When working on some GIS stuff I tried that at first, got annoyed and ended up just making my own stuff.
|
# ? May 20, 2010 00:01 |
|
WalletBeef posted:I am working on some code which needs to determine if a point on the earth is within a polygon. Are there java libraries which would allow me to do this? Look into GeoTools. The Polygon class from AWT wouldn't deal with various edge cases. E: Actually, going straight to JTS might be a bit simpler depending on what you're trying to do. RitualConfuser fucked around with this message at 03:38 on May 20, 2010 |
# ? May 20, 2010 00:17 |
|
I've been contemplating how to build save files for an app I've been working on. The data is mostly numeric and there are about 30-50 fields per save. I was originally going to just stick the data in a plain text file and read and write straight from there, however, I figure it may be easier to try to do it in a different way. One of the ways I thought that'd be cool to try was to store said data in an Xlsx file and read out of there. The advantage is that the data is much more organized and readable. The disadvantages include having to deal with excel every time I want to view the file among other things, but I figure it would be an opportunity to learn how to use a package in Java so I justify doing it by writing it up as a learning experience. Looking through some solutions, I found This which looks to provide very promising functionality for this little project. My question is this: Is this a good idea? Am I digging myself a whole that's going to be very difficult to dig my way out of? Are there better solutions for this?
|
# ? May 20, 2010 18:19 |
|
I would use something like XStream or JSON serialization libraries before I would make it an Excel file. Seems like massive overkill for just persisting things to disk, unless you have a specific requirement to have an excel file. POI has a lot of options that might be a little daunting for a newbie, as well. Links: http://xstream.codehaus.org/ http://www.json.org/java/
|
# ? May 20, 2010 21:53 |
|
Canine Blues Arooo posted:One of the ways I thought that'd be cool to try was to store said data in an Xlsx file and read out of there. The advantage is that the data is much more organized and readable. The disadvantages include having to deal with excel every time I want to view the file among other things, but I figure it would be an opportunity to learn how to use a package in Java so I justify doing it by writing it up as a learning experience. At work I'm developing an API for manipulating XLSX files, so I know a thing or two about the format. If all you're interested in is reading and writing some numbers in a sheet, it's not too bad, but many of the corners of the OOXML standard are absolute nightmares. If you're interested in learning how everything fits together, I recommend downloading a copy of the OOXML SDK 2.0- even if you don't use .NET, the package comes with a searchable cross-referenced documentation viewer called the "OOXML Classes Explorer" that's packed with Excel-2007-specific gotchas and details. TRex is probably right, though- XLSX is most likely massive overkill for whatever project you have in mind.
|
# ? May 20, 2010 23:50 |
|
When a client quits my server by properly exiting, the server acknowledges them, deletes them from the system, and notifies all other clients. But when a client quits unexpectedly, like their computer crashes, terminating the process, losing internet, etc. I can't make the server recognize they are no longer active. Going through the socket class, I have the server periodically check on sockets of clients. I've tried isClosed, isConnected, isInputShutdown, and isOutputShutdown, but none of them acknowledge when I have a client terminate unexpectedly. How can I make the server realize when a client has quit? It must be some type of check on the socket. I know I could ping each client, and any client that doesn't respond is disconnected, but isn't there an easier way?
|
# ? May 21, 2010 01:46 |
|
_areaman posted:How can I make the server realize when a client has quit? It must be some type of check on the socket. I know I could ping each client, and any client that doesn't respond is disconnected, but isn't there an easier way? What are you expecting, some sort of "help I just caught on fire" packet? By definition, a client that goes down cannot tell you about it, because it's down. The only reasonable solution is to require periodic transmissions to keep the connection alive. That said, you can get the TCP layer to do this for you; just set SO_KEEPALIVE on the socket (i.e. socket.setKeepAlive(true)).
|
# ? May 21, 2010 03:06 |
|
I posted this in the Android thread, but that thread is sort of dead and this isn't really related to Android development, but general Java development. Anyway... I'm trying to make a Wizards of the Coast's DDI Compenium viewer app for Android and I'm running into problems with authentication. Wizards of course has no documentation for their authentication method, and looking at all the threads on this issue, it appears that no one has really figured it out, or at least bothered to figure it out and post about it. However, I know there's an iPhone app that lets you browse the compendium, and it logs in for you, so it must be possible. Their login page has a fairly basic HTML form: code:
However, it's not working: code:
|
# ? May 21, 2010 03:15 |
|
Fitret posted:... What is it doing exactly? Can you show the full response that you got back? Since you got the 200 status code I assume the server didn't choke on your request, but what did it send back to you?
|
# ? May 21, 2010 13:12 |
|
Yeah, either save every line of what your client is POSTing and what is returned, or somehow run a packet logger. Oh, and try replacing the "/"s in __VIEWSTATE with "%2F" instead. Maybe for __EVENTVALIDATION too.
|
# ? May 21, 2010 21:04 |
|
rjmccall posted:What are you expecting, some sort of "help I just caught on fire" packet? By definition, a client that goes down cannot tell you about it, because it's down. The only reasonable solution is to require periodic transmissions to keep the connection alive. Calm down calm down, I thought there might be some way to detect the socket is inactive, like maybe "isConnected" sends something to the other end of the socket and returns false if it fails, which seems completely rational to me. Thanks for the input though.
|
# ? May 22, 2010 21:43 |
|
Aleksei Vasiliev posted:Yeah, either save every line of what your client is POSTing and what is returned, or somehow run a packet logger. tcpmon is quite good for this. You start it up, tell it to act as a proxy, it prints out both request and response. Simple and just what is most likely needed here.
|
# ? May 24, 2010 06:20 |
|
New Question: I'm looking into trying to implement a recommended text-esq feature into a couple text fields. I'm not sure what this feature is called exactly which is making it difficult to search for but it works kinda like so: Lets say I have a list of colors in an array of strings. Some of the colors in the array include red, green, grey, and white. What I want to happen in this text box is for an auto-complete recommendation to fill out below it based on an array I feed it. That is, if I type a "g" in the field, I want a box to come down that shows "green" and "grey". If you've ever used the homework software Aplia for Accounting, it works exactly like that. Assuming one can gather what I want out of this based on what I've written, how could I implement this? I'd imagine something has been written to make this much easier, but without knowing what to call it, It's made finding information on it difficult.
|
# ? May 25, 2010 18:05 |
|
It is called an autocomplete widget, or an autosuggest widget.
|
# ? May 25, 2010 18:21 |
|
ynef posted:tcpmon is quite good for this. You start it up, tell it to act as a proxy, it prints out both request and response. Simple and just what is most likely needed here.
|
# ? May 25, 2010 23:43 |
|
Hi, does anyone know any good Java tutorials? I skimmed the first few pages and full out read the OP and didn't see any mention of it. I ended up settling with Netbeans as my IDE of choice. Thanks! [edit] vvvvvv gently caress, I feel dumb. Sorry about that.. Thanks! scanlonman fucked around with this message at 02:51 on May 28, 2010 |
# ? May 27, 2010 01:34 |
|
The OP posted:Also Bubblegum Wishes recommends this series of videos teaching Java from the ground up using Eclipse.
|
# ? May 27, 2010 02:55 |
|
Hello all, I'm learning a bit of java and I'm trying to work on a personal project involving measurement conversion and I need some help with the logic and see if there's a way to simplify how I think it should be done. Basically, I want to do some simple conversion of feet, meters, inches, and yards. What I'd like is to have four separate text fields and a single button and if I put a number into one field, it will calculate the other three fields after clicking the button. My original thought is to check and see if x field != "", then it would call a conversion method and then populate the remaining fields. So I'm thinking at minimum there will be four if statements. Anyone have any better ideas or a link to a tutorial on what I'm trying to accomplish?
|
# ? May 28, 2010 05:25 |
|
korofrog posted:Hello all, I'm learning a bit of java and I'm trying to work on a personal project involving measurement conversion and I need some help with the logic and see if there's a way to simplify how I think it should be done. That's pretty much it. You'll have to make an executive decision regarding what to do if they've filled in 2+ boxes - probably just take the first filled one and ignore the rest - but the way of checking would be just a bunch of if statements, yeah. Don't forget sanity checking when you're working with numbers in strings!
|
# ? May 28, 2010 08:50 |
|
|
# ? May 9, 2024 15:41 |
|
Jonnty posted:probably just take the first filled one and ignore the rest Here's a better way, remember which was last filled in by the user. code:
|
# ? May 28, 2010 10:07 |