diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 7552aa8..0000000 --- a/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -build -dist -log4j.properties -mobibot.properties -mobibot.ser -logs \ No newline at end of file diff --git a/build.properties b/build.properties deleted file mode 100644 index e30731e..0000000 --- a/build.properties +++ /dev/null @@ -1 +0,0 @@ -main.class=net.thauvin.erik.mobibot.Mobibot \ No newline at end of file diff --git a/build.xml b/build.xml deleted file mode 100644 index fffa1e0..0000000 --- a/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lib/MathEvaluator.jar b/lib/MathEvaluator.jar deleted file mode 100644 index d263227..0000000 Binary files a/lib/MathEvaluator.jar and /dev/null differ diff --git a/lib/commons-logging.jar b/lib/commons-logging.jar deleted file mode 100644 index b99c937..0000000 Binary files a/lib/commons-logging.jar and /dev/null differ diff --git a/lib/google.jar b/lib/google.jar deleted file mode 100644 index 391aba6..0000000 Binary files a/lib/google.jar and /dev/null differ diff --git a/lib/googleapi.jar b/lib/googleapi.jar deleted file mode 100644 index 2aade51..0000000 Binary files a/lib/googleapi.jar and /dev/null differ diff --git a/lib/jakarta-oro-2.0.8.jar b/lib/jakarta-oro-2.0.8.jar deleted file mode 100644 index 23488d2..0000000 Binary files a/lib/jakarta-oro-2.0.8.jar and /dev/null differ diff --git a/lib/log4j-1.2.8.jar b/lib/log4j-1.2.8.jar deleted file mode 100644 index 11f7f8e..0000000 Binary files a/lib/log4j-1.2.8.jar and /dev/null differ diff --git a/lib/pircbot.jar b/lib/pircbot.jar deleted file mode 100644 index a74cf68..0000000 Binary files a/lib/pircbot.jar and /dev/null differ diff --git a/licenses/Commons License.txt b/licenses/Commons License.txt deleted file mode 100644 index 428700a..0000000 --- a/licenses/Commons License.txt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * ==================================================================== - * - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, if - * any, must include the following acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements normally appear. - * - * 4. The names "The Jakarta Project", "Commons", and "Apache Software - * Foundation" must not be used to endorse or promote products derived - * from this software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - * - */ \ No newline at end of file diff --git a/licenses/Google License.txt b/licenses/Google License.txt deleted file mode 100644 index 50f948b..0000000 --- a/licenses/Google License.txt +++ /dev/null @@ -1,150 +0,0 @@ -Thank you for using the Google Web APIs (TM) service! By using this -service ("Google Web APIs") you agree to be bound by the following -terms and conditions (the "Terms and Conditions"). - -PERSONAL AND LEGITIMATE USES ONLY - -The Google Web APIs service is made available to you for your -personal, non-commercial use only (at home or at work). You may only -create a single account and must provide accurate identification, -contact, and other information required as part of the registration -process. You may not create any script or other automated tool that -attempts to create multiple Google Web APIs accounts. And you may not -use the search results provided by the Google Web APIs service with an -existing product or service that competes with products or services -offered by Google. - -If you are interested in doing anything different than the foregoing, -you must first obtain Google's written consent. If you fail to do so, -Google reserves the right to take legal action against you. - -Furthermore, you may not use Google Web APIs in any manner that either -directly or indirectly violates any laws or proprietary rights. This -includes laws and proprietary rights in the United States as well as -in other countries. - -If you have questions on your contemplated use or if you have comments -on Google Web APIs or ideas on how to improve it, please email -api-support@google.com. Please note that by doing so, you also grant -Google permission to use and incorporate your ideas or comments into -Google Web APIs without further compensation. - -INTELLECTUAL PROPERTY - -You agree not to remove, obscure, or alter Google's copyright notice, -trademarks, or other proprietary rights notices affixed to or -contained within Google Web APIs. You also acknowledge that Google -owns all right, title and interest in and to Google Web APIs, -including without limitation all intellectual property rights (the -"Google Rights"). The Google Rights include rights to the following: -(1) the APIs developed and provided by Google, (2) all software -associated with the Google Web APIs server, and (3) the search results -and spell checking you obtain when you use Google Web APIs. The Google -Rights do not include the following: (1) third party components used -as part of Google Web APIs; or (2) software developed by you in -conjunction with using Google Web APIs. - -PUBLICITY - -So long as you comply with your obligations under this Agreement, you -may indicate that a product or service that you created either used or -is based on Google Web APIs provided that those products or services -do not in Google's reasonable opinion (1) tarnish, infringe, or dilute -Google's trademarks, (2) violate any applicable law, and (3) infringe -any third party rights. If you wish to use the GOOGLE trademark and/or -logo in any other manner, you must first obtain Google's written -consent. - -DISCLAIMER OF WARRANTIES - -The Google Web APIs service is presently in Beta form and has not been -fully tested or debugged. Accordingly, Google disclaims any -responsibility for any harm resulting from your use of Google Web APIs. - -The Google Web APIs service is provided "as is," with no warranties -whatsoever. Google expressly disclaims to the fullest extent permitted -by law all express, implied, and statutory warranties, including, -without limitation, the warranties of merchantability, fitness for a -particular purpose, and non-infringement of proprietary rights. Google -disclaims any warranties regarding the security, reliability, -timeliness, availability, and performance of Google Web APIs. - -You understand and agree that you use Google Web APIs at your own -discretion and risk and that you will be solely responsible for any -damages to your computer system or loss of data that results from the -download or use of Google Web APIs. - -Some states or other jurisdictions do not allow the exclusion of -implied warranties, so the above exclusions may not apply to you. You -may also have other rights that vary from state to state and -jurisdiction to jurisdiction. - -LIMITATION OF LIABILITY - -The Google Web APIs service is being provided free of charge. -Accordingly, you agree that Google shall have no liability arising -from or based on your use of Google Web APIs. - -Under no circumstances shall Google be liable to any user on account -of that user's use or misuse of Google Web APIs. Such limitation of -liability shall apply to prevent recovery of direct, indirect, -incidental, consequential, special, exemplary, and punitive damages -whether such claim is based on warranty, contract, tort (including -negligence), or otherwise, even if Google has been advised of the -possibility of such damages). Such limitation of liability shall apply -whether the damages arise from use or misuse of and reliance on the -Google Web APIs, from inability to use Google Web APIs, or from the -interruption, suspension, or termination of Google Web APIs (including -such damages incurred by third parties). Such limitation shall apply -notwithstanding a failure of essential purpose of any limited remedy -and to the fullest extent permitted by law. - -Some states or other jurisdictions do not allow the exclusion or -limitation of liability for incidental or consequential damages, so -the above limitations and exclusions may not apply to you. - -INDEMNIFICATION - -You hereby agree to indemnify, defend and hold Google, and its -officers, directors, agents, licensors and licensees (collectively, -the "Indemnified Parties") harmless from and against any and all -liability and costs incurred by the Indemnified Parties in connection -with any claim arising out of your use of Google Web APIs, including, -without limitation, reasonable attorneys' fees. You shall cooperate as -fully as reasonably required in the defense of any claim. Google -reserves the right, at its own expense, to assume the exclusive -defense and control of any matter subject to indemnification by you. - -GOOGLE'S SEARCH SERVICE - -The Google Web APIs service is designed to be used in conjunction with -Google's search services. Accordingly, your use of Google Web APIs is -also defined by Google's Terms of Service and Privacy Policy. In the -event of a conflict between these Terms and Conditions and Google's -Terms of Service, these Terms and Conditions shall prevail. - -TERM AND TERMINATION - -If you wish to terminate this Agreement, you may simply cease using -the Google Web APIs service. In such a case, you must delete any -search result information that you may have obtained from the Google -Web APIs service. Google may terminate this Agreement (and your -account) at any time, with or without cause. - -GENERAL PROVISIONS - -These Terms and Conditions will be governed by and construed in -accordance with the laws of the State of California, without giving -effect to the conflict of laws provisions of California or your actual -state or country of residence. Any dispute arising from these Terms -and Conditions shall be adjudicated in the federal or state courts -located in Santa Clara County, California. If for any reason a court -of competent jurisdiction finds any provision or portion of these -Terms and Conditions to be unenforceable, the remainder of these Terms -and Conditions will continue in full force and effect. These Terms and -Conditions constitute the entire agreement between the parties with -respect to the subject matter hereof and supersede and replace all -prior or contemporaneous understandings or agreements, written or -oral, regarding such subject matter. Any waiver of any provision of -these Terms and Conditions will be effective only if in writing and -signed by Google. diff --git a/licenses/GoogleTagLib License.txt b/licenses/GoogleTagLib License.txt deleted file mode 100644 index c300b97..0000000 --- a/licenses/GoogleTagLib License.txt +++ /dev/null @@ -1,29 +0,0 @@ -Google Tag Library License - -Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of the author nor the names of its contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/licenses/JDOM License.txt b/licenses/JDOM License.txt deleted file mode 100644 index dbb014b..0000000 --- a/licenses/JDOM License.txt +++ /dev/null @@ -1,54 +0,0 @@ -/*-- - - Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions, and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions, and the disclaimer that follows - these conditions in the documentation and/or other materials - provided with the distribution. - - 3. The name "JDOM" must not be used to endorse or promote products - derived from this software without prior written permission. For - written permission, please contact . - - 4. Products derived from this software may not be called "JDOM", nor - may "JDOM" appear in their name, without prior written permission - from the JDOM Project Management . - - In addition, we request (but do not require) that you include in the - end-user documentation provided with the redistribution and/or in the - software itself an acknowledgement equivalent to the following: - "This product includes software developed by the - JDOM Project (http://www.jdom.org/)." - Alternatively, the acknowledgment may be graphical using the logos - available at http://www.jdom.org/images/logos. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - - This software consists of voluntary contributions made by many - individuals on behalf of the JDOM Project and was originally - created by Jason Hunter and - Brett McLaughlin . For more information - on the JDOM Project, please see . - - */ - diff --git a/licenses/JWeather License.txt b/licenses/JWeather License.txt deleted file mode 100644 index 14db8fc..0000000 --- a/licenses/JWeather License.txt +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/licenses/License.txt b/licenses/License.txt deleted file mode 100644 index c4fe425..0000000 --- a/licenses/License.txt +++ /dev/null @@ -1,29 +0,0 @@ -Mobibot License - -Copyright (c) 2004, Erik C. Thauvin (erik@thauvin.net) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of the author nor the names of its contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/licenses/Log4j License.txt b/licenses/Log4j License.txt deleted file mode 100644 index 007db57..0000000 --- a/licenses/Log4j License.txt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The end-user documentation included with the redistribution, if any, must - * include the following acknowledgment: "This product includes software - * developed by the Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, if - * and wherever such third-party acknowledgments normally appear. - * - * 4. The names "log4j" and "Apache Software Foundation" must not be used to - * endorse or promote products derived from this software without prior - * written permission. For written permission, please contact - * apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", nor may - * "Apache" appear in their name, without prior written permission of the - * Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * on behalf of the Apache Software Foundation. For more information on the - * Apache Software Foundation, please see . - * - */ diff --git a/licenses/PircBot License.html b/licenses/PircBot License.html deleted file mode 100644 index 2a5a569..0000000 --- a/licenses/PircBot License.html +++ /dev/null @@ -1,60 +0,0 @@ - - - -The GNU General Public License (GPL) - - -

The GNU General Public License (GPL)

-

Version 2, June 1991

-

Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

-

Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.

-

Preamble

-

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

-

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

-

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

-

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

-

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

-

Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

-

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

-

The precise terms and conditions for copying, distribution and modification follow.

-

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

-

0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".

-

Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

-

1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

-

You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

-

2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:

-
-

a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.

-

b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.

-

c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)

-
-

These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

-

Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

-

In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

-

3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:

-
-

a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

-

b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

-

c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)

-
-

The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

-

If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

-

4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

-

5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.

-

6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

-

7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

-

If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

-

It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

-

This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

-

8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.

-

9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

-

Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

-

10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

-

NO WARRANTY

-

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

-

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

-

END OF TERMS AND CONDITIONS

- - diff --git a/mobibot.fb b/mobibot.fb deleted file mode 100644 index f02b78c..0000000 --- a/mobibot.fb +++ /dev/null @@ -1,20 +0,0 @@ -[Jar files] -D:\projects\java\mobibot\build -[Source dirs] -D:\projects\java\mobibot\src -[Aux classpath entries] -D:\projects\java\mobibot\lib\commons-httpclient-2.0-final.jar -D:\projects\java\mobibot\lib\commons-logging.jar -D:\projects\java\mobibot\lib\commons-net-1.1.0.jar -D:\projects\java\mobibot\lib\EXML.jar -D:\projects\java\mobibot\lib\fetchrss.jar -D:\projects\java\mobibot\lib\google.jar -D:\projects\java\mobibot\lib\googleapi.jar -D:\projects\java\mobibot\lib\jakarta-oro-2.0.7.jar -D:\projects\java\mobibot\lib\jakarta-oro-2.0.8.jar -D:\projects\java\mobibot\lib\jdom.jar -D:\projects\java\mobibot\lib\jweather-0.2.3.jar -D:\projects\java\mobibot\lib\log4j-1.2.8.jar -D:\projects\java\mobibot\lib\MathEvaluator.jar -D:\projects\java\mobibot\lib\pircbot.jar -D:\projects\java\mobibot\lib\rsslibj.jar diff --git a/mobibot.iml b/mobibot.iml deleted file mode 100644 index 960a19c..0000000 --- a/mobibot.iml +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mobibot.ipr b/mobibot.ipr deleted file mode 100644 index f44f2ae..0000000 --- a/mobibot.ipr +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - false - false - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mobibot.iws b/mobibot.iws deleted file mode 100644 index 9b6a364..0000000 --- a/mobibot.iws +++ /dev/null @@ -1,588 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - localhost - 5050 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/net/thauvin/erik/mobibot/CurrencyConverter.java b/src/net/thauvin/erik/mobibot/CurrencyConverter.java deleted file mode 100644 index 65cf6dc..0000000 --- a/src/net/thauvin/erik/mobibot/CurrencyConverter.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * @(#)CurrencyConverter.java - * - * Copyright (c) 2004, Erik C. Thauvin (erik@thauvin.net) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id$ - * - */ -package net.thauvin.erik.mobibot; - -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.Namespace; - -import org.jdom.input.SAXBuilder; - -import java.io.IOException; - -import java.net.URL; - -import java.text.NumberFormat; - -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.TreeMap; - - -/** - * Converts various currencies. - * - * @author Erik C. Thauvin - * @version $Revision$, $Date$ - * - * @created Feb 11, 2004 - * @since 1.0 - */ -public class CurrencyConverter implements Runnable -{ - /** - * The exchange rates table URL. - */ - public static final String EXCHANGE_TABLE_URL = "http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"; - - /** - * The exchange rates. - */ - private static final Map EXCHANGE_RATES = new TreeMap(); - - /** - * The last exchange rates table publication date. - */ - private static String s_date = ""; - - /** - * The bot. - */ - private final Mobibot _bot; - - /** - * The actual currency _query. - */ - private final String _query; - - /** - * The nick of the person who sent the message. - */ - private final String _sender; - - /** - * Creates a new CurrencyConverter object. - * - * @param bot The bot. - * @param sender The nick of the person who sent the message. - * @param query The currency query. - * @param date The current date. - */ - public CurrencyConverter(Mobibot bot, String sender, String query, String date) - { - _bot = bot; - _sender = sender; - _query = query; - - if (!s_date.equals(date)) - { - EXCHANGE_RATES.clear(); - } - } - - // Converts specified currencies. - public void run() - { - if (EXCHANGE_RATES.isEmpty()) - { - try - { - final SAXBuilder builder = new SAXBuilder(); - builder.setIgnoringElementContentWhitespace(true); - - final Document doc = builder.build(new URL(EXCHANGE_TABLE_URL)); - final Element root = doc.getRootElement(); - final Namespace ns = root.getNamespace(""); - final Element cubeRoot = root.getChild("Cube", ns); - final Element cubeTime = cubeRoot.getChild("Cube", ns); - - s_date = cubeTime.getAttribute("time").getValue(); - - final List cubes = cubeTime.getChildren(); - Element cube; - - for (int i = 0; i < cubes.size(); i++) - { - cube = (Element) cubes.get(i); - EXCHANGE_RATES.put(cube.getAttribute("currency").getValue(), cube.getAttribute("rate").getValue()); - } - - EXCHANGE_RATES.put("EUR", "1"); - } - catch (JDOMException e) - { - _bot.getLogger().debug("Unable to parse the exchange rates table.", e); - _bot.sendNotice(_sender, "An error has occurred while parsing the exchange rates table."); - } - catch (IOException e) - { - _bot.getLogger().debug("Unable to fetch the exchange rates table.", e); - _bot.sendNotice(_sender, - "An error has occurred while fetching the exchange rates table: " + e.getMessage()); - } - } - - if (!EXCHANGE_RATES.isEmpty()) - { - if (_query.matches("\\d+([,\\d]+)?(\\.\\d+)? [a-z]{3}+ to [a-z]{3}+")) - { - final String[] cmds = _query.split(" "); - - if (cmds.length == 4) - { - if (cmds[3].equals(cmds[1])) - { - _bot.sendNotice(_sender, "You're kidding, right?"); - } - else - { - try - { - final double amt = Double.parseDouble(cmds[0].replaceAll(",", "")); - final double from = Double.parseDouble((String) EXCHANGE_RATES.get(cmds[1].toUpperCase())); - double to = Double.parseDouble((String) EXCHANGE_RATES.get(cmds[3].toUpperCase())); - - _bot.sendNotice(_bot.getChannel(), - NumberFormat.getCurrencyInstance(Locale.US).format(amt).substring(1) + ' ' + - cmds[1].toUpperCase() + " = " + - NumberFormat.getCurrencyInstance(Locale.US).format((amt * to) / from) - .substring(1) + ' ' + cmds[3].toUpperCase()); - } - catch (NullPointerException e) - { - _bot.sendNotice(_sender, - "The supported currencies are: " + EXCHANGE_RATES.keySet().toString()); - } - } - } - } - else - { - _bot.helpResponse(_sender, Mobibot.CURRENCY_CMD + ' ' + _query); - _bot.sendNotice(_sender, "The supported currencies are: " + EXCHANGE_RATES.keySet().toString()); - } - } - else - { - _bot.getLogger().debug("The exchange rate table is empty."); - _bot.sendNotice(_sender, "Sorry, but the exchange rate table is empty."); - } - } -} diff --git a/src/net/thauvin/erik/mobibot/EntryComment.java b/src/net/thauvin/erik/mobibot/EntryComment.java deleted file mode 100644 index b6876dc..0000000 --- a/src/net/thauvin/erik/mobibot/EntryComment.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * @(#)EntryComment.java - * - * Copyright (c) 2004, Erik C. Thauvin (erik@thauvin.net) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id$ - * - */ -package net.thauvin.erik.mobibot; - -import java.io.Serializable; - -import java.util.Calendar; -import java.util.Date; - - -/** - * The class used to store comments associated to a specific entry. - * - * @author Erik C. Thauvin - * @version $Revision$, $Date$ - * - * @created Jan 31, 2004 - * @since 1.0 - */ -public class EntryComment implements Serializable -{ - /** - * The serial version UID. - */ - static final long serialVersionUID = 6957415292233553224L; - - /** - * The creation date. - */ - private final Date _date = Calendar.getInstance().getTime(); - private String _comment = ""; - private String _nick = ""; - - /** - * Creates a new comment. - * - * @param comment The new comment. - * @param nick The nickname of the comment's author. - */ - public EntryComment(String comment, String nick) - { - _comment = comment; - _nick = nick; - } - - /** - * Creates a new comment. - */ - protected EntryComment() - { - ; // Required for serialization. - } - - /** - * Sets the comment. - * - * @param comment The actual comment. - */ - public final void setComment(String comment) - { - _comment = comment; - } - - /** - * Returns the comment. - * - * @return The comment. - */ - public final String getComment() - { - return _comment; - } - - /** - * Returns the comment's creation date. - * - * @return The date. - */ - public final Date getDate() - { - return _date; - } - - /** - * Sets the nickname of the author of the comment. - * - * @param nick The new nickname. - */ - public final void setNick(String nick) - { - _nick = nick; - } - - /** - * Returns the nickname of the author of the comment. - * - * @return The nickname. - */ - public final String getNick() - { - return _nick; - } -} diff --git a/src/net/thauvin/erik/mobibot/EntryLink.java b/src/net/thauvin/erik/mobibot/EntryLink.java deleted file mode 100644 index 67fe2ae..0000000 --- a/src/net/thauvin/erik/mobibot/EntryLink.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * @(#)EntryLink.java - * - * Copyright (c) 2004, Erik C. Thauvin (erik@thauvin.net) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id$ - * - */ -package net.thauvin.erik.mobibot; - -import java.io.Serializable; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - - -/** - * The class used to store link entries. - * - * @author Erik C. Thauvin - * @version $Revision$, $Date$ - * - * @created Jan 31, 2004 - * @since 1.0 - */ -public class EntryLink implements Serializable -{ - /** - * The serial version UID. - */ - static final long serialVersionUID = 3676245542270899086L; - - /** - * The creation date. - */ - private final Date _date = Calendar.getInstance().getTime(); - - /** - * The comments. - */ - private final List _comments = new ArrayList(0); - private String _link = ""; - private String _login = ""; - private String _nick = ""; - private String _title = "No Title"; - - /** - * Creates a new entry. - * - * @param link The new entry's link. - * @param nick The nickname of the author of the link. - * @param login The login of the author of the link. - */ - public EntryLink(String link, String nick, String login) - { - _link = link; - _nick = nick; - _login = login; - } - - /** - * Creates a new entry. - * - * @param link The new entry's link. - * @param title The new entry's title. - * @param nick The nickname of the author of the link. - * @param login The login of the author of the link. - */ - public EntryLink(String link, String title, String nick, String login) - { - _link = link; - _title = title; - _nick = nick; - _login = login; - } - - /** - * Creates a new EntryLink object. - */ - protected EntryLink() - { - ; // Required for serialization. - } - - /** - * Sets a comment. - * - * @param index The comment's index. - * @param comment The actual comment. - * @param nick The nickname of the author of the comment. - */ - public final synchronized void setComment(int index, String comment, String nick) - { - if (index < _comments.size()) - { - _comments.set(index, new EntryComment(comment, nick)); - } - } - - /** - * Returns a comment. - * - * @param index The comment's index. - * - * @return The specific comment. - */ - public final synchronized EntryComment getComment(int index) - { - return ((EntryComment) _comments.get(index)); - } - - /** - * Returns all the comments. - * - * @return The comments. - */ - public final synchronized EntryComment[] getComments() - { - return ((EntryComment[]) _comments.toArray(new EntryComment[0])); - } - - /** - * Returns the total number of comments. - * - * @return The count of comments. - */ - public final synchronized int getCommentsCount() - { - return _comments.size(); - } - - /** - * Returns the comment's creation date. - * - * @return The date. - */ - public final synchronized Date getDate() - { - return _date; - } - - /** - * Sets the comment's link. - * - * @param link The new link. - */ - public final synchronized void setLink(String link) - { - this._link = link; - } - - /** - * Returns the comment's link. - * - * @return The link. - */ - public final synchronized String getLink() - { - return _link; - } - - /** - * Set the comment's author login. - * - * @param login The new login. - */ - public final synchronized void setLogin(String login) - { - this._login = login; - } - - /** - * Return's the comment's author login. - * - * @return The login; - */ - public final synchronized String getLogin() - { - return _login; - } - - /** - * Sets the comment's author nickname. - * - * @param nick The new nickname. - */ - public final synchronized void setNick(String nick) - { - this._nick = nick; - } - - /** - * Returns the comment's author nickname. - * - * @return The nickname. - */ - public final synchronized String getNick() - { - return _nick; - } - - /** - * Sets the comment's title. - * - * @param title The new title. - */ - public final synchronized void setTitle(String title) - { - this._title = title; - } - - /** - * Returns the comment's title. - * - * @return The title. - */ - public final synchronized String getTitle() - { - return _title; - } - - /** - * Adds a new comment. - * - * @param comment The actual comment. - * @param nick The nickname of the author of the comment. - * - * @return The total number of comments for this entry. - */ - public final synchronized int addComment(String comment, String nick) - { - _comments.add(new EntryComment(comment, nick)); - - return (_comments.size() - 1); - } - - /** - * Deletes a specific comment. - * - * @param index The index of the comment to delete. - */ - public final synchronized void deleteComment(int index) - { - if (index < _comments.size()) - { - _comments.remove(index); - } - } - - /** - * Returns true if the entry has comments. - * - * @return true if there are comments, false otherwise. - */ - public final synchronized boolean hasComments() - { - return (_comments.size() > 0); - } -} diff --git a/src/net/thauvin/erik/mobibot/FeedReader.java b/src/net/thauvin/erik/mobibot/FeedReader.java deleted file mode 100644 index 62b6de4..0000000 --- a/src/net/thauvin/erik/mobibot/FeedReader.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * @(#)FeedReader.java - * - * Copyright (c) 2004, Erik C. Thauvin (erik@thauvin.net) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id$ - * - */ -package net.thauvin.erik.mobibot; - -import org.crazybob.rss.Channel; -import org.crazybob.rss.Item; -import org.crazybob.rss.Parser; -import org.crazybob.rss.UrlLoader; -import org.crazybob.rss.UrlLoader.Response; - -import org.jdom.JDOMException; - -import org.jdom.input.SAXBuilder; - -import java.io.IOException; -import java.io.StringReader; - -import java.util.Iterator; -import java.util.List; - - -/** - * Reads a RSS feed. - * - * @author Erik C. Thauvin - * @version $Revision$, $Date$ - * - * @created Feb 1, 2004 - * @since 1.0 - */ -public class FeedReader implements Runnable -{ - /** - * The maximum number of feed items to display. - */ - private static final int MAX_ITEMS = 5; - - /** - * The tab indent (4 spaces). - */ - private static final String TAB_INDENT = " "; - - /** - * The bot. - */ - private final Mobibot _bot; - - /** - * The nick of the person who sent the message. - */ - private final String _sender; - - /** - * The URL to fetch. - */ - private final String _url; - - /** - * Creates a new FeedReader object. - * - * @param bot The bot. - * @param sender The nick of the person who sent the message. - * @param url The URL to fetch. - */ - public FeedReader(Mobibot bot, String sender, String url) - { - _bot = bot; - _sender = sender; - _url = url; - } - - /** - * Fetches the Feed's items. - */ - public void run() - { - List items = null; - - try - { - final Response response = new UrlLoader().load(_url, _bot.getFeedLastMod()); - - if (response != null) - { - _bot.setFeedLastMod(response.getLastModified()); - - final Channel chan = new Parser().parse(new SAXBuilder().build(new StringReader(response.getBody()))); - items = chan.getItems(); - _bot.setFeedItems(items); - } - } - catch (JDOMException e) - { - _bot.getLogger().debug("Unable to parse the feed.", e); - _bot.sendNotice(_sender, "An error has occurred while parsing the feed."); - } - catch (IOException e) - { - _bot.getLogger().debug("Unable to fetch the feed.", e); - _bot.sendNotice(_sender, "An error has occurred while fetching the feed: " + e.getMessage()); - } - - if (items == null) - { - items = _bot.getFeedItems(); - } - - if ((items != null) && (!items.isEmpty())) - { - Item item; - int i = 0; - final Iterator it = items.iterator(); - - while (it.hasNext() && (i < MAX_ITEMS)) - { - item = (Item) it.next(); - _bot.sendNotice(_sender, item.getTitle()); - _bot.sendNotice(_sender, TAB_INDENT + '<' + item.getLink() + '>'); - - i++; - } - - if (_bot.getFeedLastMod().length() > 0) - { - _bot.sendNotice(_sender, "Last Updated: " + _bot.getFeedLastMod()); - } - } - } -} diff --git a/src/net/thauvin/erik/mobibot/GoogleSearch.java b/src/net/thauvin/erik/mobibot/GoogleSearch.java deleted file mode 100644 index 852ff12..0000000 --- a/src/net/thauvin/erik/mobibot/GoogleSearch.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * @(#)GoogleSearch.java - * - * Copyright (c) 2004, Erik C. Thauvin (erik@thauvin.net) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id$ - * - */ -package net.thauvin.erik.mobibot; - -import com.google.soap.search.GoogleSearchFault; - -import net.thauvin.google.GoogleSearchBean; - -import org.jibble.pircbot.Colors; - - -/** - * Performs a Google search or spell checking query. - * - * @author Erik C. Thauvin - * @version $Revision$, $Date$ - * - * @created Feb 7, 2004 - * @since 1.0 - */ -public class GoogleSearch implements Runnable -{ - /** - * The maximum number of Google results to display. - */ - private static final int MAX_GOOGLE = 5; - - /** - * The Google search bean. - */ - private static final GoogleSearchBean GOOGLE_BEAN = new GoogleSearchBean(); - - /** - * The tab indent (4 spaces). - */ - private static final String TAB_INDENT = " "; - - /** - * The bot. - */ - private final Mobibot _bot; - - /** - * The Google API key. - */ - private final String _key; - - /** - * The search query. - */ - private final String _query; - - /** - * The nick of the person who sent the message. - */ - private final String _sender; - - /** - * Spell Checking query flag. - */ - private final boolean _isSpellQuery; - - /** - * Creates a new GoogleSearch object. - * - * @param bot The bot. - * @param key The Google API key. - * @param sender The nick of the person who sent the message. - * @param query The Google query - * @param isSpellQuery Set to true if the query is a Spell Checking query - */ - public GoogleSearch(Mobibot bot, String key, String sender, String query, boolean isSpellQuery) - { - _bot = bot; - _key = key; - _sender = sender; - _query = query; - _isSpellQuery = isSpellQuery; - } - - /** - * Main processing method. - */ - public void run() - { - GOOGLE_BEAN.setKey(_key); - - if (_isSpellQuery) - { - try - { - final String r = GOOGLE_BEAN.getSpellingSuggestion(_query); - - if ((r != null) && (r.length() > 0)) - { - _bot.sendNotice(_sender, Mobibot.unescapeXml(r)); - } - else - { - _bot.sendNotice(_sender, "You've just won our spelling bee contest."); - } - } - catch (GoogleSearchFault e) - { - _bot.getLogger().warn("Unable to spell: " + _query, e); - _bot.sendNotice(_sender, "An error has occurred: " + e.getMessage()); - } - } - else - { - try - { - GOOGLE_BEAN.getGoogleSearch(_query, GoogleSearchBean.DEFAULT_START, MAX_GOOGLE, - GoogleSearchBean.DEFAULT_FILTER, GoogleSearchBean.DEFAULT_RESTRICT, - GoogleSearchBean.DEFAULT_SAFE_SEARCH, GoogleSearchBean.DEFAULT_LR); - - if (GOOGLE_BEAN.isValidResult()) - { - for (int i = 0; i < GOOGLE_BEAN.getResultElementsCount(); i++) - { - _bot.sendNotice(_sender, - GOOGLE_BEAN.getResultElementProperty(i, "title").replaceAll("<([bB]|/[bB])>", - Colors.BOLD)); - _bot.sendNotice(_sender, TAB_INDENT + '<' + GOOGLE_BEAN.getResultElementProperty(i, "url") + - '>'); - } - } - } - catch (GoogleSearchFault e) - { - _bot.getLogger().warn("Unable to search in Google for: " + _query, e); - _bot.sendNotice(_sender, "An error has occurred: " + e.getMessage()); - } - } - } -} diff --git a/src/net/thauvin/erik/mobibot/Mobibot.java b/src/net/thauvin/erik/mobibot/Mobibot.java deleted file mode 100644 index 75900a3..0000000 --- a/src/net/thauvin/erik/mobibot/Mobibot.java +++ /dev/null @@ -1,2210 +0,0 @@ -/* - * @(#)Mobibot.java - * - * Copyright (c) 2004, Erik C. Thauvin (erik@thauvin.net) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id$ - * - */ -package net.thauvin.erik.mobibot; - -import com.primalworld.math.MathEvaluator; - -import com.rsslibj.elements.Channel; -import com.rsslibj.elements.Item; - -import org.apache.commons.logging.impl.Log4JLogger; -import org.apache.commons.net.WhoisClient; - -import org.apache.log4j.Level; - -import org.jibble.pircbot.*; - -import java.io.*; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -import java.text.SimpleDateFormat; - -import java.util.*; - - -/** - * Implements the #mobitopia bot. - * - * @author Erik C. Thauvin - * @version $Revision$, $Date$ - * - * @created Jan 31, 2004 - * @since 1.0 - */ -public class Mobibot extends PircBot -{ - /** - * The connect/read timeout in ms. - */ - public static final int CONNECT_TIMEOUT = 5000; - - /** - * The info strings. - */ - private static final String[] INFO_STRS = - { - "Mobibot v0.1.2 by Erik C. Thauvin (erik@thauvin.net)", - "" - }; - - /** - * Debug command line argument. - */ - private static final String DEBUG_ARG = "-debug"; - - /** - * The object serialization file where data is saved between launches. - */ - private static final String DATA_FILE = "./mobibot.ser"; - - /** - * The maximum number of times the bot will try to reconnect, if disconnected. - */ - private static final int MAX_RECONNECT = 10; - - /** - * The default maximum number of entries to display. - */ - private static final int MAX_ENTRIES = 8; - - /** - * The default maximum recap entries. - */ - private static final int MAX_RECAP = 10; - - /** - * The maximum number of backlogs to keep. - */ - private static final int MAX_BACKLOGS = 10; - - /** - * The double tab indent (8 spaces). - */ - private static final String DOUBLE_INDENT = " "; - - /** - * The add (back)log command. - */ - private static final String ADDLOG_CMD = "addlog"; - - /** - * The debug command. - */ - private static final String DEBUG_CMD = "debug"; - - /** - * The dices command. - */ - private static final String DICE_CMD = "dice"; - - /** - * The say command. - */ - private static final String SAY_CMD = "say"; - - /** - * The die command. - */ - private static final String DIE_CMD = "die"; - - /** - * The cycle command. - */ - private static final String CYCLE_CMD = "cycle"; - - /** - * The help command. - */ - private static final String HELP_CMD = "help"; - - /** - * The help on posting keyword. - */ - private static final String HELP_POSTING_KEYWORD = "posting"; - - /** - * The Google command. - */ - private static final String GOOGLE_CMD = "google"; - - /** - * The math command. - */ - private static final String CALC_CMD = "calc"; - - /** - * The me command. - */ - private static final String ME_CMD = "me"; - - /** - * The nick command. - */ - private static final String NICK_CMD = "nick"; - - /** - * The link command. - */ - private static final String LINK_CMD = "L"; - - /** - * The link match string. - */ - private static final String LINK_MATCH = "http://"; - - /** - * The lookup command. - */ - private static final String LOOKUP_CMD = "lookup"; - - /** - * The recap command. - */ - private static final String RECAP_CMD = "recap"; - - /** - * The spell command. - */ - private static final String SPELL_CMD = "spell"; - - /** - * The stock command. - */ - private static final String STOCK_CMD = "stock"; - - /** - * The time command. - */ - private static final String TIME_CMD = "time"; - - /** - * The countries supporte by the {@link #TIME_CMD time} command. - */ - private static final Map COUNTRIES_MAP = new TreeMap(); - - /** - * The date/time format for the {@link #TIME_CMD time} command. - */ - private static final SimpleDateFormat TIME_SDF = new SimpleDateFormat("'The time is 'HH:mm' on 'EEE, d MMM yyyy' in '"); - - /** - * The beats (Internet Time) keyword. - */ - private static final String BEATS_KEYWORD = ".beats"; - - /** - * The currency command. - */ - public static final String CURRENCY_CMD = "currency"; - - /** - * The users command. - */ - private static final String USERS_CMD = "users"; - - /** - * The info command. - */ - private static final String INFO_CMD = "info"; - - /** - * The view command. - */ - private static final String VIEW_CMD = "view"; - - /** - * The view "all" keyword. - */ - private static final String VIEW_ALL_KEYWORD = "all"; - - /** - * The weather command. - */ - private static final String WEATHER_CMD = "weather"; - - /** - * The HH:MM timestamp simple date format. - */ - private static final SimpleDateFormat HHMM_SDF = new SimpleDateFormat("HH:mm"); - - /** - * The ISO (YYYY-MM-DD) simple date format. - */ - private static final SimpleDateFormat ISO_SDF = new SimpleDateFormat("yyyy-MM-dd"); - - /** - * The start time. - */ - private static final long START_TIME = System.currentTimeMillis(); - - /** - * The recap array. - */ - private static final List RECAP_ARRAY = new ArrayList(MAX_RECAP); - - // Initialize the countries. - static - { - COUNTRIES_MAP.put("AU", "Australia/Sydney"); - COUNTRIES_MAP.put("BE", "Europe/Brussels"); - COUNTRIES_MAP.put("CA", "America/Montreal"); - COUNTRIES_MAP.put("CH", "Europe/Zurich"); - COUNTRIES_MAP.put("CN", "Asia/Shanghai"); - COUNTRIES_MAP.put("DE", "Europe/Berlin"); - COUNTRIES_MAP.put("DK", "Europe/Copenhagen"); - COUNTRIES_MAP.put("ES", "Europe/Madrid"); - COUNTRIES_MAP.put("FR", "Europe/Paris"); - COUNTRIES_MAP.put("GB", "Europe/London"); - COUNTRIES_MAP.put("HK", "Asia/Hong_Kong"); - COUNTRIES_MAP.put("IE", "Europe/Dublin"); - COUNTRIES_MAP.put("IL", "Israel"); - COUNTRIES_MAP.put("IN", "Asia/Calcutta"); - COUNTRIES_MAP.put("IS", "Iceland"); - COUNTRIES_MAP.put("IT", "Europe/Rome"); - COUNTRIES_MAP.put("JP", "Asia/Tokyo"); - COUNTRIES_MAP.put("MX", "Mexico/Mexico_City"); - COUNTRIES_MAP.put("NL", "Europe/Amsterdam"); - COUNTRIES_MAP.put("NO", "Europe/Oslo"); - COUNTRIES_MAP.put("NZ", "Pacific/Auckland"); - COUNTRIES_MAP.put("RU", "Europe/Moscow"); - COUNTRIES_MAP.put("SE", "Europe/Stockholm"); - COUNTRIES_MAP.put("SU", "Europe/Moscow"); - COUNTRIES_MAP.put("TH", "Asia/Bangkok"); - COUNTRIES_MAP.put("TW", "Asia/Taipei"); - COUNTRIES_MAP.put("UK", "Europe/London"); - COUNTRIES_MAP.put("US", "America/New_York"); - COUNTRIES_MAP.put("EST", "America/New_York"); - COUNTRIES_MAP.put("CST", "America/Chicago"); - COUNTRIES_MAP.put("MST", "America/Denver"); - COUNTRIES_MAP.put("PST", "America/Los_Angeles"); - COUNTRIES_MAP.put("EDT", "America/New_York"); - COUNTRIES_MAP.put("CDT", "America/Chicago"); - COUNTRIES_MAP.put("MDT", "America/Denver"); - COUNTRIES_MAP.put("PDT", "America/Los_Angeles"); - COUNTRIES_MAP.put("CET", "CET"); - COUNTRIES_MAP.put("GMT", "GMT"); - COUNTRIES_MAP.put("UTC", "UTC"); - COUNTRIES_MAP.put("INTERNET", BEATS_KEYWORD); - COUNTRIES_MAP.put("BEATS", BEATS_KEYWORD); - } - - /** - * The whois host. - */ - private static final String WHOIS_HOST = "whois.arin.net"; - - /** - * The logger default level. - */ - private final Level _loggerLevel; - - /** - * The feed items. - */ - private final List _feedItems = new ArrayList(0); - - /** - * The logger. - */ - private final Log4JLogger _logger; - - /** - * The backlogs URL. - */ - private final String _backlogsURL; - - /** - * The main channel. - */ - private final String _channel; - - /** - * The feed URL. - */ - private final String _feedURL; - - /** - * The IRC server. - */ - private final String _ircServer; - - /** - * The log directory. - */ - private final String _logsDir; - - /** - * The weblog URL. - */ - private final String _weblogURL; - - /** - * The entries array. - */ - private final Vector _entries = new Vector(0); - - /** - * The history/backlogs array. - */ - private final Vector _history = new Vector(0); - - // The feed last modification date. - private String _feedLastMod = ""; - - // The Google API key. - private String _googleKey = ""; - - // Today's date. - private String _today = today(); - - // The Google API key flag. - private boolean _isGoogleKeySet; - - /** - * Creates a new Mobibot object. - * - * @param server The server. - * @param channel The channel. - * @param weblogURL The weblog URL. - * @param feedURL The feed URL. - * @param backlogsURL The backlogs URL. - * @param logsDir The logs directory. - */ - public Mobibot(String server, String channel, String weblogURL, String feedURL, String backlogsURL, String logsDir) - { - System.getProperties().setProperty("sun.net.client.defaultConnectTimeout", String.valueOf(CONNECT_TIMEOUT)); - System.getProperties().setProperty("sun.net.client.defaultReadTimeout", String.valueOf(CONNECT_TIMEOUT)); - - _ircServer = server; - _channel = channel; - _weblogURL = weblogURL; - _feedURL = feedURL; - _backlogsURL = backlogsURL; - _logsDir = logsDir; - - // Set the logger - _logger = new Log4JLogger(Mobibot.class.getPackage().getName()); - _loggerLevel = _logger.getLogger().getLevel(); - - // Load the saved data, if any - final File ser = new File(DATA_FILE); - - if (ser.exists()) - { - ObjectInputStream ois = null; - - try - { - ois = new ObjectInputStream(new FileInputStream(ser)); - - _entries.addAll((Vector) ois.readObject()); - _today = (String) ois.readObject(); - _history.addAll((Vector) ois.readObject()); - - saveEntries(true); - - if (!today().equals(_today)) - { - _entries.clear(); - _today = today(); - } - } - catch (ClassNotFoundException e) - { - _logger.fatal("Unable to read objects in data file.", e); - System.exit(1); - } - catch (IOException e) - { - _logger.fatal("Unable to open data file.", e); - System.exit(1); - } - finally - { - if (ois != null) - { - try - { - ois.close(); - } - catch (IOException ignore) - { - ; // Do nothing - } - } - } - } - } - - /** - * The Truth Is Out There... - * - * @param args The command line arguments. - */ - public static void main(String[] args) - { - FileInputStream fis = null; - final Properties p = new Properties(); - - try - { - fis = new FileInputStream(new File("./mobibot.properties")); - - // Load the properties files - p.load(fis); - } - catch (FileNotFoundException e) - { - System.err.println("Unable to find properties file."); - e.printStackTrace(System.err); - System.exit(1); - } - catch (IOException e) - { - System.err.println("Unable to open properties file."); - e.printStackTrace(System.err); - System.exit(1); - } - finally - { - if (fis != null) - { - try - { - fis.close(); - } - catch (IOException ignore) - { - ; // Do nothing - } - } - } - - // Get the main properties - final String channel = p.getProperty("channel"); - final String server = p.getProperty("server"); - final String nickname = p.getProperty("nick", Mobibot.class.getName().toLowerCase()); - final String logsDir = ensureDir(p.getProperty("logs", "."), false); - - if ((args.length == 0) || !DEBUG_ARG.equals(args[0])) - { - // Redirect the stdout and stderr - PrintStream stdout = null; - - try - { - stdout = new PrintStream(new FileOutputStream(logsDir + channel.substring(1) + '.' + today() + ".log", - true)); - } - catch (IOException e) - { - System.err.println("Unable to open output (stdout) log file."); - e.printStackTrace(System.err); - System.exit(1); - } - - PrintStream stderr = null; - - try - { - stderr = new PrintStream(new FileOutputStream(logsDir + nickname + ".err", true)); - } - catch (IOException e) - { - System.err.println("Unable to open error (stderr) log file."); - e.printStackTrace(System.err); - System.exit(1); - } - - System.setOut(stdout); - System.setErr(stderr); - } - - // Get the bot's properties - final String login = p.getProperty("login", nickname); - final String weblogURL = p.getProperty("weblog", ""); - final String feedURL = p.getProperty("feed", ""); - final String backlogsURL = ensureDir(p.getProperty("backlogs", weblogURL), true); - final String googleKey = p.getProperty("google", ""); - - // Create the bot - final Mobibot bot = new Mobibot(server, channel, weblogURL, feedURL, backlogsURL, logsDir); - - // Initialize the bot - bot.setVerbose(true); - bot.setName(nickname); - bot.setLogin(login); - bot.setVersion(weblogURL); - - // Set the Google key - bot.setGoogleKey(googleKey); - - // Connect - try - { - bot.connect(server); - } - catch (Exception e) - { - int retries = 0; - - while ((retries < MAX_RECONNECT) && !bot.isConnected()) - { - sleep(10); - - if ((retries > 0) && (e instanceof NickAlreadyInUseException)) - { - bot.setName(nickname + retries); - } - - retries++; - - try - { - bot.connect(server); - } - catch (NickAlreadyInUseException ex) - { - if (retries == MAX_RECONNECT) - { - System.err.println("Unable to connect to " + server + " after " + MAX_RECONNECT + - " retries. Nickname already in use."); - e.printStackTrace(System.err); - System.exit(1); - } - } - catch (Exception ex) - { - if (retries == MAX_RECONNECT) - { - System.err.println("Unable to connect to " + server + " after " + MAX_RECONNECT + " retries."); - e.printStackTrace(System.err); - System.exit(1); - } - } - } - } - - bot.setVersion(INFO_STRS[0]); - bot.joinChannel(channel); - } - - /** - * Converts XML/XHTML entities to plain text. - * - * @param str The string to unescape. - * - * @return The unescaped string. - */ - public static String unescapeXml(String str) - { - String s = str.replaceAll("&", "&"); - s = s.replaceAll("<", "<"); - s = s.replaceAll(">", ">"); - s = s.replaceAll(""", "\""); - s = s.replaceAll("'", "'"); - s = s.replaceAll("'", "'"); - - return s; - } - - /** - * Returns the current channel. - * - * @return The current channel. - */ - public final String getChannel() - { - return _channel; - } - - /** - * Sets the feed items. - * - * @param items The feed items. - */ - public final void setFeedItems(List items) - { - synchronized (_feedItems) - { - _feedItems.clear(); - _feedItems.addAll(items); - } - } - - /** - * Returns the feed items. - * - * @return The feed items. - */ - public final List getFeedItems() - { - synchronized (_feedItems) - { - return _feedItems; - } - } - - /** - * Sets the feed last modification date. - * - * @param feedLastMod The last modification date. - */ - public final void setFeedLastMod(String feedLastMod) - { - _feedLastMod = feedLastMod; - } - - /** - * Returns the feed last modification date. - * - * @return The feed modification date, or empty. - */ - public final String getFeedLastMod() - { - if (_feedLastMod != null) - { - return _feedLastMod; - } - - return ""; - } - - /** - * Sets the Google API key. - * - * @param googleKey The Google API key. - */ - public final void setGoogleKey(String googleKey) - { - if ((googleKey != null) && (googleKey.length() > 0)) - { - _googleKey = googleKey; - _isGoogleKeySet = true; - } - } - - /** - * Returns the bot's logger. - * - * @return The bot's logger. - */ - public final Log4JLogger getLogger() - { - return _logger; - } - - /** - * Set today's date. - * - * @param today Today's date. - */ - public final void setToday(String today) - { - synchronized (_today) - { - _today = today; - } - } - - /** - * Get today's date. - * - * @return Today's date. - */ - public final String getToday() - { - synchronized (_today) - { - return _today; - } - } - - /** - * Sends a private message or notice. - * - * @param sender The nick of the person who sent the message. - * @param message The actual message. - * @param isPrivate Set to true if the response should be a private message, otherwise a notice is sent. - */ - public final void send(String sender, String message, boolean isPrivate) - { - if (isPrivate) - { - this.sendMessage(sender, message); - } - else - { - this.sendNotice(sender, message); - } - } - - /** - * Responds with the bot's help. - * - * @param sender The nick of the person who sent the private message. - * @param cmd The actual help command. - */ - public void helpResponse(String sender, String cmd) - { - final String lcmd = cmd.toLowerCase(); - - if (lcmd.endsWith(HELP_POSTING_KEYWORD)) - { - this.sendNotice(sender, Colors.BOLD + "Post a URL, by saying it on a line on its own." + Colors.BOLD); - this.sendNotice(sender, - "I will reply with a label, for example: " + Colors.BOLD + LINK_CMD + '1' + Colors.BOLD); - this.sendNotice(sender, "To add a title, use a its label and a pipe:"); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + LINK_CMD + "1:|This is the title"); - this.sendNotice(sender, "To add a comment: "); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + LINK_CMD + "1:This is a comment"); - this.sendNotice(sender, - "I will reply with a label, for example: " + Colors.BOLD + LINK_CMD + "1.1" + Colors.BOLD); - this.sendNotice(sender, "To edit a comment, use its label: "); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + LINK_CMD + "1.1:This is an edited comment"); - this.sendNotice(sender, "To delete a comment, use its label and a minus sign: "); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + LINK_CMD + "1.1:-" + Colors.BOLD); - this.sendNotice(sender, "You can also view a posting by saying its label."); - } - else if (lcmd.endsWith(VIEW_CMD)) - { - this.sendNotice(sender, "To list the current URL posts:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + VIEW_CMD + Colors.BOLD + " [" + - VIEW_ALL_KEYWORD + ']'); - } - else if (lcmd.endsWith(_channel.substring(1).toLowerCase())) - { - this.sendNotice(sender, "To list the last 5 posts from the channel's weblog:"); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + _channel.substring(1) + - Colors.BOLD); - } - else if (lcmd.endsWith(GOOGLE_CMD)) - { - this.sendNotice(sender, "To search Google:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + GOOGLE_CMD + " " + Colors.BOLD); - } - else if (lcmd.endsWith(RECAP_CMD)) - { - this.sendNotice(sender, "To list the last 10 public channel messages:"); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + RECAP_CMD + Colors.BOLD); - } - else if (lcmd.endsWith(CALC_CMD)) - { - this.sendNotice(sender, "To solve a mathematical calculation:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + CALC_CMD + " " + Colors.BOLD); - } - else if (lcmd.endsWith(LOOKUP_CMD)) - { - this.sendNotice(sender, "To perform a DNS lookup query:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + LOOKUP_CMD + " " + - Colors.BOLD); - } - else if (lcmd.endsWith(TIME_CMD)) - { - this.sendNotice(sender, "To display a country's current date/time:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + TIME_CMD + Colors.BOLD + - " []"); - - this.sendNotice(sender, "For a listing of the supported countries:"); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + TIME_CMD + Colors.BOLD); - } - else if (lcmd.endsWith(SPELL_CMD)) - { - this.sendNotice(sender, "To have Google try to correctly spell a sentence:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + SPELL_CMD + " " + Colors.BOLD); - } - else if (lcmd.endsWith(STOCK_CMD)) - { - this.sendNotice(sender, "To retrieve a stock quote:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + STOCK_CMD + " " + Colors.BOLD); - } - else if (lcmd.endsWith(DICE_CMD)) - { - this.sendNotice(sender, "To roll the dice:"); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + DICE_CMD + Colors.BOLD); - } - else if (lcmd.endsWith(WEATHER_CMD)) - { - this.sendNotice(sender, "To display weather information:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + WEATHER_CMD + Colors.BOLD + - " []"); - this.sendNotice(sender, "See: <" + Weather.STATIONS_URL + '>'); - } - else if (lcmd.endsWith(USERS_CMD)) - { - this.sendNotice(sender, "To list the users present on the channel:"); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + USERS_CMD + Colors.BOLD); - } - else if (lcmd.endsWith(INFO_CMD)) - { - this.sendNotice(sender, "To view information about the bot:"); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + INFO_CMD + Colors.BOLD); - } - else if (lcmd.endsWith(CYCLE_CMD)) - { - if (isOp(sender)) - { - this.sendNotice(sender, "To have the bot leave the channel and come back:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + "/msg " + getNick() + ' ' + CYCLE_CMD + Colors.BOLD); - } - } - else if (lcmd.endsWith(ME_CMD)) - { - if (isOp(sender)) - { - this.sendNotice(sender, "To have the bot perform an action:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + "/msg " + getNick() + ' ' + ME_CMD + " " + - Colors.BOLD); - } - } - else if (lcmd.endsWith(SAY_CMD)) - { - if (isOp(sender)) - { - this.sendNotice(sender, "To have the bot say something on the channel:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + "/msg " + getNick() + ' ' + SAY_CMD + " " + - Colors.BOLD); - } - } - else if (lcmd.indexOf(CURRENCY_CMD) != -1) - { - this.sendNotice(sender, "To convert from one currency to another:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + CURRENCY_CMD + " [100 USD to EUR]" + - Colors.BOLD); - - if (lcmd.endsWith(CURRENCY_CMD)) - { - this.sendNotice(sender, "For a listing of supported currencies:"); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + CURRENCY_CMD + Colors.BOLD); - } - } - else - { - this.sendNotice(sender, Colors.BOLD + "Type a URL on " + _channel + " to post it." + Colors.BOLD); - this.sendNotice(sender, "For more information on specific command, type:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + getNick() + ": " + HELP_CMD + " " + Colors.BOLD); - this.sendNotice(sender, "The commands are:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + CALC_CMD + ' ' + CURRENCY_CMD + ' ' + DICE_CMD + ' ' + - GOOGLE_CMD + ' ' + INFO_CMD + ' ' + _channel.substring(1) + ' ' + LOOKUP_CMD + Colors.BOLD); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + HELP_POSTING_KEYWORD + ' ' + RECAP_CMD + ' ' + SPELL_CMD + - ' ' + STOCK_CMD + ' ' + TIME_CMD + ' ' + USERS_CMD + ' ' + VIEW_CMD + Colors.BOLD); - this.sendNotice(sender, DOUBLE_INDENT + Colors.BOLD + WEATHER_CMD + Colors.BOLD); - - if (isOp(sender)) - { - this.sendNotice(sender, "The op commands are:"); - this.sendNotice(sender, - DOUBLE_INDENT + Colors.BOLD + CYCLE_CMD + ' ' + ME_CMD + ' ' + SAY_CMD + Colors.BOLD); - } - } - } - - /** - * This method is called whenever an ACTION is sent from a user. - * - * @param sender The nick of the person who sent the action. - * @param login The login of the person who sent the action. - * @param hostname The hostname of the person who sent the action. - * @param target The target of the action, be it a channel or our nick. - * @param action The action carried out by the user. - */ - protected final void onAction(String sender, String login, String hostname, String target, String action) - { - if (target.equals(_channel)) - { - recap(sender, action, true); - } - } - - /** - * This method carries out the actions to be performed when the PircBot gets disconnected. - */ - protected final void onDisconnect() - { - setVersion(_weblogURL); - - // Connect - try - { - connect(_ircServer); - } - catch (Exception e) - { - int retries = 0; - - while ((retries < MAX_RECONNECT) && !isConnected()) - { - sleep(10); - - if ((retries > 0) && (e instanceof NickAlreadyInUseException)) - { - setName(getNick() + retries); - } - - retries++; - - try - { - connect(_ircServer); - } - catch (NickAlreadyInUseException ex) - { - if (retries == MAX_RECONNECT) - { - _logger.debug("Unable to reconnect to " + _ircServer + " after " + MAX_RECONNECT + - " retries. Nickname already in use.", e); - System.exit(1); - } - } - catch (Exception ex) - { - if (retries == MAX_RECONNECT) - { - _logger.debug("Unable to reconnect to " + _ircServer + " after " + MAX_RECONNECT + " retries.", - ex); - e.printStackTrace(System.err); - System.exit(1); - } - } - } - } - - setVersion(INFO_STRS[0]); - joinChannel(getChannel()); - } - - /** - * This method is called whenever a message is sent to a channel. - * - * @param channel The channel to which the message was sent. - * @param sender The nick of the person who sent the message. - * @param login The login of the person who sent the message. - * @param hostname The hostname of the person who sent the message. - * @param message The actual message sent. - */ - protected final void onMessage(String channel, String sender, String login, String hostname, String message) - { - _logger.debug(">>> " + sender + ": " + message); - - final String lcMsg = message.toLowerCase(); - - if ((lcMsg.startsWith(LINK_MATCH)) && (lcMsg.length() > LINK_MATCH.length())) - { - final String[] cmds = message.split(" ", 2); - final String cmd = cmds[0].trim(); - boolean isBackup = false; - - final int dupIndex = findDupEntry(cmd); - - if (dupIndex == -1) - { - if (!today().equals(getToday())) - { - isBackup = true; - saveEntries(isBackup); - - _entries.clear(); - setToday(today()); - } - - if ((cmds.length > 1) && (cmds[1].trim().length() > 0)) - { - _entries.add(new EntryLink(cmd, cmds[1].trim(), sender, login)); - } - else - { - _entries.add(new EntryLink(cmd, sender, login)); - } - - final int index = _entries.size() - 1; - final EntryLink entry = (EntryLink) _entries.get(index); - this.sendNotice(channel, buildLink(index, entry)); - - saveEntries(isBackup); - } - else - { - final EntryLink entry = (EntryLink) _entries.get(dupIndex); - this.sendNotice(sender, "Duplicate >> " + buildLink(dupIndex, entry)); - } - } - else if (lcMsg.matches(getNick() + ":.*")) - { - final String[] cmds = lcMsg.split(":", 2); - final String cmd = cmds[1].trim(); - - if (cmd.startsWith(HELP_CMD)) - { - helpResponse(sender, cmd); - } - else if (cmd.equals(RECAP_CMD)) - { - recapResponse(sender, false); - } - else if (cmd.equals(USERS_CMD)) - { - usersResponse(sender, false); - } - else if (cmd.equals(INFO_CMD)) - { - infoResponse(sender, false); - } - else if (cmd.equals(DICE_CMD)) - { - final Random r = new Random(); - int i = r.nextInt(6) + 1; - int y = r.nextInt(6) + 1; - final int total = i + y; - - this.sendNotice(_channel, sender + " rolled two dice: " + i + " and " + y + " for a total of " + total); - - i = r.nextInt(6) + 1; - y = r.nextInt(6) + 1; - this.sendAction(_channel, "rolled two dice: " + i + " and " + y + " for a total of " + (i + y)); - - if (total < (i + y)) - { - this.sendAction(_channel, "wins."); - } - else if (total > (i + y)) - { - this.sendAction(_channel, "lost."); - } - else - { - this.sendAction(_channel, "tied."); - } - } - else if (cmd.equalsIgnoreCase(_channel.substring(1))) - { - feedResponse(sender); - } - else if (cmd.startsWith(CURRENCY_CMD)) - { - new Thread(new CurrencyConverter(this, sender, - cmd.substring(cmd.indexOf(CURRENCY_CMD) + CURRENCY_CMD.length()).trim(), - today())).start(); - } - else if (cmd.startsWith(LOOKUP_CMD)) - { - lookupResponse(sender, message.substring(lcMsg.indexOf(LOOKUP_CMD) + LOOKUP_CMD.length()).trim()); - } - else if (cmd.startsWith(VIEW_CMD)) - { - viewResponse(sender, cmd, false); - } - else if (cmd.startsWith(GOOGLE_CMD)) - { - googleResponse(sender, message.substring(lcMsg.indexOf(GOOGLE_CMD) + GOOGLE_CMD.length()).trim()); - } - else if (cmd.startsWith(SPELL_CMD)) - { - spellResponse(sender, message.substring(lcMsg.indexOf(SPELL_CMD) + SPELL_CMD.length()).trim()); - } - else if (cmd.startsWith(STOCK_CMD)) - { - stockResponse(sender, message.substring(lcMsg.indexOf(STOCK_CMD) + STOCK_CMD.length()).trim()); - } - else if (cmd.startsWith(CALC_CMD)) - { - final MathEvaluator me = new MathEvaluator(message.substring(lcMsg.indexOf(CALC_CMD) + - CALC_CMD.length()).trim()); - - try - { - this.sendNotice(_channel, String.valueOf(me.getValue())); - } - catch (Exception e) - { - _logger.debug("Unable to calculate: " + message, e); - } - } - else if (cmd.startsWith(TIME_CMD)) - { - timeResponse(sender, cmd, false); - } - else if (cmd.startsWith(WEATHER_CMD)) - { - weatherResponse(sender, cmd, false); - } - } - else if (message.matches(LINK_CMD + "[0-9]+:.*")) - { - final String[] cmds = message.substring(1).split(":", 2); - final int index = Integer.parseInt(cmds[0]) - 1; - - if (index < _entries.size()) - { - final String cmd = cmds[1].trim(); - - if (cmd.length() == 0) - { - final EntryLink entry = (EntryLink) _entries.get(index); - this.sendNotice(_channel, buildLink(index, entry)); - - if (entry.hasComments()) - { - final EntryComment[] comments = entry.getComments(); - - for (int i = 0; i < comments.length; i++) - { - this.sendNotice(_channel, buildComment(index, i, comments[i])); - } - } - } - else - { - if ("-".equals(cmd)) - { - final EntryLink entry = (EntryLink) _entries.get(index); - - if (entry.getLogin().equals(login) || isOp(sender)) - { - _entries.remove(index); - this.sendNotice(_channel, "Entry " + LINK_CMD + (index + 1) + " removed."); - saveEntries(false); - } - else - { - this.sendNotice(sender, "Please ask a channel op to remove this entry for you."); - } - } - else if (cmd.charAt(0) == '|') - { - if (cmd.length() > 1) - { - final EntryLink entry = (EntryLink) _entries.get(index); - entry.setTitle(cmd.substring(1)); - this.sendNotice(_channel, buildLink(index, entry)); - saveEntries(false); - } - } - else if (cmd.charAt(0) == '=') - { - if (isOp(sender)) - { - if (cmd.length() > 1) - { - final EntryLink entry = (EntryLink) _entries.get(index); - entry.setLink(cmd.substring(1)); - this.sendNotice(_channel, buildLink(index, entry)); - saveEntries(false); - } - } - else - { - this.sendNotice(sender, "Please ask a channel op to change this link for you."); - } - } - else if (cmd.charAt(0) == '?') - { - if (isOp(sender)) - { - if (cmd.length() > 1) - { - final EntryLink entry = (EntryLink) _entries.get(index); - entry.setNick(cmd.substring(1)); - this.sendNotice(_channel, buildLink(index, entry)); - saveEntries(false); - } - } - else - { - this.sendNotice(sender, "Please ask a channel op to change the author of this link for you."); - } - } - else - { - final EntryLink entry = (EntryLink) _entries.get(index); - final int cindex = entry.addComment(cmd, sender); - - final EntryComment comment = entry.getComment(cindex); - this.sendNotice(sender, buildComment(index, cindex, comment)); - saveEntries(false); - } - } - } - } - else if (message.matches(LINK_CMD + "[0-9]+\\.[0-9]+:.*")) - { - final String[] cmds = message.substring(1).split("[.:]", 3); - final int index = Integer.parseInt(cmds[0]) - 1; - - if (index < _entries.size()) - { - final EntryLink entry = (EntryLink) _entries.get(index); - final int cindex = Integer.parseInt(cmds[1]) - 1; - - if (cindex < entry.getCommentsCount()) - { - final String cmd = cmds[2].trim(); - - if (cmd.length() == 0) - { - final EntryComment comment = entry.getComment(cindex); - this.sendNotice(_channel, buildComment(index, cindex, comment)); - } - else if ("-".equals(cmd)) - { - entry.deleteComment(cindex); - this.sendNotice(_channel, "Comment " + LINK_CMD + (index + 1) + '.' + (cindex + 1) + - " removed."); - saveEntries(false); - } - else if (cmd.charAt(0) == '?') - { - if (isOp(sender)) - { - if (cmd.length() > 1) - { - final EntryComment comment = entry.getComment(cindex); - comment.setNick(cmd.substring(1)); - this.sendNotice(_channel, buildComment(index, cindex, comment)); - saveEntries(false); - } - } - else - { - this.sendNotice(sender, - "Please ask a channel op to change the author of this comment for you."); - } - } - else - { - entry.setComment(cindex, cmd, sender); - - final EntryComment comment = entry.getComment(cindex); - this.sendNotice(sender, buildComment(index, cindex, comment)); - saveEntries(false); - } - } - } - } - else - { - recap(sender, message, false); - } - } - - /** - * This method is called whenever a private message is sent to the bot. - * - * @param sender The nick of the person who sent the private message. - * @param login The login of the person who sent the private message. - * @param hostname The hostname of the person who sent the private message. - * @param message The actual message sent. - */ - protected final void onPrivateMessage(String sender, String login, String hostname, String message) - { - _logger.debug(">>> " + sender + ": " + message); - - final String lcMsg = message.toLowerCase(); - - if (lcMsg.startsWith(HELP_CMD)) - { - helpResponse(sender, message); - } - else if (lcMsg.equals(DIE_CMD)) - { - if (isOp(sender)) - { - this.sendNotice(_channel, sender + " has just signed my death sentence."); - saveEntries(true); - sleep(3); - this.quitServer("The Bot Is Out There!"); - System.exit(0); - } - } - else if (lcMsg.equals(CYCLE_CMD)) - { - this.sendNotice(_channel, sender + " has just asked me to leave. I'll be back!"); - sleep(0); - this.partChannel(_channel); - sleep(5); - this.joinChannel(_channel); - } - else if (lcMsg.equals(RECAP_CMD)) - { - recapResponse(sender, true); - } - else if (lcMsg.equals(USERS_CMD)) - { - usersResponse(sender, true); - } - else if (lcMsg.startsWith(ADDLOG_CMD) && !lcMsg.endsWith(ADDLOG_CMD)) - { - if (isOp(sender)) - { - _history.add(0, message.substring(message.indexOf(ADDLOG_CMD) + ADDLOG_CMD.length()).trim()); - this.sendMessage(sender, _history.toString()); - } - } - else if (lcMsg.startsWith(ME_CMD) && !lcMsg.endsWith(ME_CMD)) - { - if (isOp(sender)) - { - this.sendAction(_channel, message.substring(message.indexOf(ME_CMD) + ME_CMD.length()).trim()); - } - } - else if (lcMsg.startsWith(NICK_CMD) && !lcMsg.endsWith(ME_CMD)) - { - if (isOp(sender)) - { - this.changeNick(message.substring(message.indexOf(NICK_CMD) + NICK_CMD.length()).trim()); - } - } - else if (lcMsg.startsWith(SAY_CMD) && !lcMsg.endsWith(SAY_CMD)) - { - if (isOp(sender)) - { - this.sendMessage(_channel, message.substring(message.indexOf(SAY_CMD) + SAY_CMD.length()).trim()); - } - } - else if (lcMsg.startsWith(VIEW_CMD)) - { - viewResponse(sender, lcMsg, true); - } - else if (lcMsg.startsWith(TIME_CMD)) - { - timeResponse(sender, message, true); - } - else if (lcMsg.startsWith(WEATHER_CMD)) - { - weatherResponse(sender, lcMsg, true); - } - else if (lcMsg.equals(INFO_CMD)) - { - infoResponse(sender, true); - } - else if (lcMsg.equals(DEBUG_CMD)) - { - if (isOp(sender)) - { - if (_logger.isDebugEnabled()) - { - _logger.getLogger().setLevel(_loggerLevel); - } - else - { - _logger.getLogger().setLevel(Level.DEBUG); - } - - this.sendMessage(sender, "Debug logging is " + (_logger.isDebugEnabled() ? "enabled." : "disabled.")); - } - } - else - { - helpResponse(sender, ""); - } - } - - /** - * Builds an entry's link for display on the channel. - * - * @param index The entry's index. - * @param entry The {@link EntryLink entry} object. - * - * @return The entry's link. - * - * @see #buildLink(int, EntryLink, boolean) - */ - private static String buildLink(int index, EntryLink entry) - { - return buildLink(index, entry, false); - } - - /** - * Builds an entry's link for display on the channel. - * - * @param index The entry's index. - * @param entry The {@link EntryLink entry} object. - * @param isView Set to true to display the number of comments. - * - * @return The entry's link. - */ - private static String buildLink(int index, EntryLink entry, boolean isView) - { - final StringBuffer buff = new StringBuffer(LINK_CMD + (index + 1) + ": "); - - buff.append('[' + entry.getNick() + ']'); - - if (isView && entry.hasComments()) - { - buff.append("[+" + entry.getCommentsCount() + ']'); - } - - buff.append(' ' + entry.getTitle() + " <" + entry.getLink() + '>'); - - return buff.toString(); - } - - /** - * Ensures that the given location (File/URL) has a trailing slash (/) to indicate a directory. - * - * @param location The File or URL location. - * @param isUrl Set to true if the location is a URL - * - * @return The location ending with a slash. - */ - private static String ensureDir(String location, boolean isUrl) - { - if (isUrl) - { - if (location.charAt(location.length() - 1) == '/') - { - return location; - } - else - { - return location + '/'; - } - } - else - { - if (location.charAt(location.length() - 1) == File.separatorChar) - { - return location; - } - else - { - return location + File.separatorChar; - } - } - } - - /** - * Returns the current Internet (beat) Time. - * - * @return The Internet Time string. - */ - private static String internetTime() - { - final Calendar gc = Calendar.getInstance(); - - final int offset = (gc.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000)); - int hh = gc.get(Calendar.HOUR_OF_DAY); - final int mm = gc.get(Calendar.MINUTE); - final int ss = gc.get(Calendar.SECOND); - - hh -= offset; // GMT - hh += 1; // BMT - - long beats = Math.round(Math.floor((double) ((((hh * 3600) + (mm * 60) + ss) * 1000) / 86400))); - - if (beats >= 1000) - { - beats -= (long) 1000; - } - else if (beats < 0) - { - beats += (long) 1000; - } - - if (beats < 10) - { - return ("@00" + String.valueOf(beats)); - } - else if (beats < 100) - { - return ("@0" + String.valueOf(beats)); - } - - return ('@' + String.valueOf(beats)); - } - - /** - * Returns true is the specified sender is an Op on the {@link #_channel channel}. - * - * @param sender The sender. - * - * @return true, if the sender is an Op. - */ - private boolean isOp(String sender) - { - final User[] users = this.getUsers(_channel); - - User user; - - for (int i = 0; i < users.length; i++) - { - user = users[i]; - - if (user.getNick().equals(sender)) - { - return user.isOp(); - } - } - - return false; - } - - /** - * Builds an entry's comment for display on the channel. - * - * @param entryIndex The entry's index. - * @param commentIndex The comment's index. - * @param comment The {@link EntryComment comment} object. - * - * @return The entry's comment. - */ - private static String buildComment(int entryIndex, int commentIndex, EntryComment comment) - { - return (LINK_CMD + (entryIndex + 1) + '.' + (commentIndex + 1) + ": [" + comment.getNick() + "] " + - comment.getComment()); - } - - /** - * Responds the title and links from the RSS feed. - * - * @param sender The nick of the person who sent the private message. - */ - private void feedResponse(String sender) - { - if (_feedURL.length() > 0) - { - new Thread(new FeedReader(this, sender, _feedURL)).start(); - } - else - { - this.sendNotice(sender, "There is no weblog setup for this channel."); - } - } - - /** - * Returns the index of the specified duplicate entry, if any. - * - * @param link The link. - * - * @return The index or -1 if none. - */ - private int findDupEntry(String link) - { - EntryLink entry; - - for (int i = 0; i < _entries.size(); i++) - { - entry = (EntryLink) _entries.get(i); - - if (link.equals(entry.getLink())) - { - return i; - } - } - - return -1; - } - - /** - * Responds with the Google search results for the specified query. - * - * @param sender The nick of the person who sent the private message. - * @param query The Google query to execute. - */ - private void googleResponse(String sender, String query) - { - if (_isGoogleKeySet) - { - if (query.length() > 0) - { - new Thread(new GoogleSearch(this, _googleKey, sender, query, false)).start(); - } - else - { - helpResponse(sender, GOOGLE_CMD); - } - } - else - { - this.sendNotice(sender, "The Google search facility is disabled."); - } - } - - /** - * Responds with the bot's information. - * - * @param sender The nick of the person who sent the message. - * @param isPrivate Set to true is the response should be send as a private message. - */ - private void infoResponse(String sender, boolean isPrivate) - { - for (int i = 0; i < INFO_STRS.length; i++) - { - send(sender, INFO_STRS[i], isPrivate); - } - - long timeInSeconds = (System.currentTimeMillis() - START_TIME) / 1000L; - - final long days = timeInSeconds / 86400L; - timeInSeconds -= (days * 86400L); - - final long hours = timeInSeconds / 3600L; - timeInSeconds -= (hours * 3600L); - - final long minutes = timeInSeconds / 60L; - send(sender, - "Uptime: " + days + " day(s) " + hours + " hour(s) " + minutes + " minute(s) [Entries: " + - _entries.size() + ']', isPrivate); - } - - /** - * Performs a DNS lookup on the specified query. - * - * @param query The IP address or hostname. - * - * @return The lookup query result string. - * - * @exception UnknownHostException If the host is unknown. - */ - private static String lookup(String query) - throws UnknownHostException - { - final StringBuffer buffer = new StringBuffer(""); - - final InetAddress[] result = InetAddress.getAllByName(query); - String hostInfo; - - for (int i = 0; i < result.length; i++) - { - if (result[i].getHostAddress().equals(query)) - { - hostInfo = result[i].getHostName(); - - if (hostInfo.equals(query)) - { - throw new UnknownHostException(); - } - } - else - { - hostInfo = result[i].getHostAddress(); - } - - if (buffer.length() > 0) - { - buffer.append(", "); - } - - buffer.append(hostInfo); - } - - return buffer.toString(); - } - - /** - * Performs a whois IP query. - * - * @param query The IP address. - * - * @return The IP whois data, if any. - * - * @throws IOException If a connection error occurs. - */ - private static String[] whois(String query) - throws IOException - { - final WhoisClient whois = new WhoisClient(); - String[] lines; - - try - { - whois.setDefaultTimeout(CONNECT_TIMEOUT); - whois.connect(WHOIS_HOST); - whois.setSoTimeout(CONNECT_TIMEOUT); - whois.setSoLinger(false, 0); - - lines = whois.query('-' + query).split("\n"); - } - finally - { - whois.disconnect(); - } - - return lines; - } - - /** - * Stores the last 10 public messages and actions. - * - * @param sender The nick of the person who sent the private message. - * @param message The actual message sent. - * @param isAction Set to true if the message is an action. - */ - private void recap(String sender, String message, boolean isAction) - { - RECAP_ARRAY.add(HHMM_SDF.format(Calendar.getInstance().getTime()) + " -> " + sender + (isAction ? " " : ": ") + - message); - - if (RECAP_ARRAY.size() > MAX_RECAP) - { - RECAP_ARRAY.remove(0); - } - } - - /** - * Responds with the last 10 public messages. - * - * @param sender The nick of the person who sent the private message. - * @param isPrivate Set to true is the response should be send as a private message. - */ - private void recapResponse(String sender, boolean isPrivate) - { - for (int i = 0; i < RECAP_ARRAY.size(); i++) - { - send(sender, (String) RECAP_ARRAY.get(i), isPrivate); - } - } - - /** - * Saves the entries. - * - * @param isDayBackup Set the true if the daily backup file should also be created. - */ - private synchronized void saveEntries(boolean isDayBackup) - { - if ((_logsDir.length() > 0) && (_weblogURL.length() > 0)) - { - FileWriter fw = null; - - try - { - fw = new FileWriter(new File(_logsDir + "current.xml")); - - Channel rss = new Channel(); - rss.setTitle(_channel + " IRC Links"); - rss.setDescription("Links from " + _ircServer + " on " + _channel); - rss.setLink(_weblogURL); - rss.setPubDate(Calendar.getInstance().getTime()); - - EntryLink entry; - StringBuffer buff; - EntryComment comment; - Item item; - - for (int i = (_entries.size() - 1); i >= 0; --i) - { - entry = (EntryLink) _entries.get(i); - - buff = new StringBuffer(0); - - if (entry.getCommentsCount() > 0) - { - final EntryComment[] comments = entry.getComments(); - - for (int j = 0; j < comments.length; j++) - { - comment = comments[j]; - - if (j > 0) - { - buff.append("
"); - } - - buff.append(comment.getNick()).append(": ").append(comment.getComment()); - } - } - - item = new Item(); - item.setLink(entry.getLink()); - item.setDescription(buff.toString()); - item.setTitle(entry.getTitle()); - item.setPubDate(entry.getDate()); - item.setAuthor(_channel.substring(1) + '@' + _ircServer + " (" + entry.getNick() + ')'); - - rss.addItem(item); - } - - fw.write(rss.getFeed("2.0")); - - if (isDayBackup) - { - if (_backlogsURL.length() > 0) - { - fw.close(); - fw = new FileWriter(new File(_logsDir + getToday() + ".xml")); - fw.write(rss.getFeed("2.0")); - - if (_history.indexOf(getToday()) == -1) - { - _history.add(getToday()); - - while (_history.size() > MAX_BACKLOGS) - { - _history.remove(0); - } - } - - fw.close(); - fw = new FileWriter(new File(_logsDir + "nav.xml")); - rss = new Channel(); - rss.setTitle(_channel + " IRC Links Backlogs"); - rss.setDescription("Backlogs of Links from " + _ircServer + " on " + _channel); - rss.setLink(_backlogsURL); - rss.setPubDate(Calendar.getInstance().getTime()); - - String date; - - for (int i = (_history.size() - 1); i >= 0; --i) - { - date = (String) _history.get(i); - rss.addItem(_backlogsURL + date + ".xml", "Links for " + date, date); - } - - fw.write(rss.getFeed("2.0")); - } - else - { - _logger.warn("Unable to generate the backlogs feed. No property configured."); - } - } - } - catch (Exception e) - { - _logger.warn("Unable to generate the feed.", e); - } - finally - { - try - { - fw.close(); - } - catch (Exception ignore) - { - ; // Do nothing - } - } - } - else - { - _logger.warn("Unable to generate the feed. At least one of the required property is missing."); - } - - // Save the data - ObjectOutputStream oos = null; - - try - { - oos = new ObjectOutputStream(new FileOutputStream(DATA_FILE)); - - oos.writeObject(_entries.clone()); - oos.writeObject(getToday()); - oos.writeObject(_history.clone()); - } - catch (IOException e) - { - _logger.warn("Unable to save the data file.", e); - } - finally - { - try - { - if (oos != null) - { - oos.close(); - } - } - catch (IOException e) - { - _logger.debug("Unable to close the data file stream.", e); - } - } - } - - /** - * Sleeps for the specified number of seconds. - * - * @param secs The number of seconds to sleep for. - */ - private static void sleep(int secs) - { - try - { - Thread.sleep((long) (secs * 1000)); - } - catch (InterruptedException ignore) - { - ; // Do nothing - } - } - - /** - * Responds with the results of a DNS query. - * - * @param sender The nick of the person who sent the message - * @param query The hostname or IP address. - */ - private void lookupResponse(String sender, String query) - { - if (query.matches("(\\S.)+(\\S)+")) - { - try - { - this.sendNotice(_channel, lookup(query)); - } - catch (UnknownHostException e) - { - if (query.matches("(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")) - { - try - { - final String[] lines = whois(query); - - if ((lines != null) && (lines.length > 0)) - { - String line; - - for (int i = 0; i < lines.length; i++) - { - line = lines[i].trim(); - - if ((line.length() > 0) && (line.charAt(0) != '#')) - { - this.sendNotice(_channel, line); - } - } - } - else - { - this.sendNotice(_channel, "Unknown host."); - } - } - catch (IOException ioe) - { - _logger.debug("Unable to perform whois IP lookup: " + query, ioe); - this.sendNotice(_channel, "Unable to perform whois IP lookup: " + ioe.getMessage()); - } - } - else - { - this.sendNotice(_channel, "Unknown host."); - } - } - } - else - { - helpResponse(sender, LOOKUP_CMD); - } - } - - /** - * Uses Google to correctly spell a sentence. - * - * @param sender The nick of the person who sent the message - * @param spell The sentence to spell. - */ - private void spellResponse(String sender, String spell) - { - if (_isGoogleKeySet) - { - if (spell.length() > 0) - { - new Thread(new GoogleSearch(this, _googleKey, _channel, spell, true)).start(); - } - else - { - helpResponse(sender, SPELL_CMD); - } - } - else - { - this.sendNotice(_channel, "The Google spelling facility is disabled."); - } - } - - /** - * Responds with the specified stock quote. - * - * @param sender The nick of the person who sent the message. - * @param symbol The stock symbol to lookup. - */ - private void stockResponse(String sender, String symbol) - { - if (symbol.length() > 0) - { - new Thread(new StockQuote(this, sender, symbol)).start(); - } - else - { - helpResponse(sender, STOCK_CMD); - } - } - - /** - * Responds with the current time. - * - * @param sender The nick of the person who sent the message. - * @param cmd The actual time command. - * @param isPrivate Set to true is the response should be send as a private message. - */ - private void timeResponse(String sender, String cmd, boolean isPrivate) - { - boolean isInvalidTz = false; - final String tz = ((String) COUNTRIES_MAP.get((cmd.substring(cmd.indexOf(' ') + 1).trim().toUpperCase()))); - final String response; - - if (tz != null) - { - if (tz.equals(BEATS_KEYWORD)) - { - response = ("The current Internet Time is: " + internetTime() + ' ' + BEATS_KEYWORD); - } - else - { - TIME_SDF.setTimeZone(TimeZone.getTimeZone(tz)); - response = TIME_SDF.format(Calendar.getInstance().getTime()) + - tz.substring(tz.indexOf('/') + 1).replace('_', ' '); - } - } - else - { - isInvalidTz = true; - response = "The supported time zones/countries are: " + COUNTRIES_MAP.keySet().toString(); - } - - if (isPrivate) - { - this.sendMessage(sender, response); - } - else - { - if (isInvalidTz) - { - this.sendNotice(sender, response); - } - else - { - this.sendNotice(_channel, response); - } - } - } - - /** - * Returns today's date. - * - * @return Today's date in {@link #ISO_SDF ISO} format. - */ - private static String today() - { - return ISO_SDF.format(Calendar.getInstance().getTime()); - } - - /** - * Responds with the users on a channel. - * - * @param sender The nick of the person who sent the message. - * @param isPrivate Set to true is the response should be send as a private message. - */ - private void usersResponse(String sender, boolean isPrivate) - { - final User[] users = this.getUsers(_channel); - final String[] nicks = new String[users.length]; - - for (int i = 0; i < users.length; i++) - { - nicks[i] = users[i].getNick(); - } - - Arrays.sort(nicks, String.CASE_INSENSITIVE_ORDER); - - final StringBuffer buff = new StringBuffer(0); - - for (int i = 0; i < nicks.length; i++) - { - buff.append(nicks[i]).append(' '); - } - - send(sender, buff.toString(), isPrivate); - } - - /** - * Responds with the stored links. - * - * @param sender The nick of the person who sent the message. - * @param cmd The actual view command. - * @param isPrivate Set to true is the response should be send as a private message. - */ - private void viewResponse(String sender, String cmd, boolean isPrivate) - { - if (!_entries.isEmpty()) - { - final int max = _entries.size(); - int i = 0; - - if (!cmd.endsWith(VIEW_ALL_KEYWORD) && (max > MAX_ENTRIES)) - { - i = max - MAX_ENTRIES; - } - - for (; i < max; i++) - { - send(sender, buildLink(i, (EntryLink) _entries.get(i), true), isPrivate); - } - } - else - { - send(sender, "There is currently nothing to view. Why don't you post something?", isPrivate); - } - } - - /** - * Responds with weather from the specified station ID. - * - * @param sender The nick of the person who sent the message. - * @param cmd The actual weather command. - * @param isPrivate Set to true is the response should be send as a private message. - */ - private void weatherResponse(String sender, String cmd, boolean isPrivate) - { - new Thread(new Weather(this, sender, cmd.substring(WEATHER_CMD.length()).trim().toUpperCase(), isPrivate)).start(); - } -} diff --git a/src/net/thauvin/erik/mobibot/StockQuote.java b/src/net/thauvin/erik/mobibot/StockQuote.java deleted file mode 100644 index 21f25ed..0000000 --- a/src/net/thauvin/erik/mobibot/StockQuote.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * @(#)StockQuote.java - * - * Copyright (c) 2004, Erik C. Thauvin (erik@thauvin.net) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id$ - * - */ -package net.thauvin.erik.mobibot; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.methods.GetMethod; - -import java.io.IOException; - - -/** - * Retrieves a stock quote from Yahoo!. - * - * @author Erik C. Thauvin - * @version $Revision$, $Date$ - * - * @created Feb 7, 2004 - * @since 1.0 - */ -public class StockQuote implements Runnable -{ - /** - * The Yahoo! stock quote URL. - */ - private static final String YAHOO_URL = "http://finance.yahoo.com/d/quotes.csv?&f=snl1d1t1c1oghv&e=.csv&s="; - - /** - * The bot. - */ - private final Mobibot _bot; - - /** - * The nick of the person who sent the message. - */ - private final String _sender; - - /** - * The stock symbol. - */ - private final String _symbol; - - /** - * Creates a new StockQuote object. - * - * @param bot The bot. - * @param sender The nick of the person who sent the message. - * @param symbol The stock symbol. - */ - public StockQuote(Mobibot bot, String sender, String symbol) - { - _bot = bot; - _sender = sender; - _symbol = symbol; - } - - /** - * Returns the specified stock quote. - */ - public void run() - { - try - { - final HttpClient client = new HttpClient(); - client.setConnectionTimeout(Mobibot.CONNECT_TIMEOUT); - client.setTimeout(Mobibot.CONNECT_TIMEOUT); - - final GetMethod getMethod = new GetMethod(YAHOO_URL + _symbol.toUpperCase()); - client.executeMethod(getMethod); - - final String[] quote = getMethod.getResponseBodyAsString().split(","); - - if (quote.length > 0) - { - if ((quote.length > 3) && (!"\"N/A\"".equalsIgnoreCase(quote[3]))) - { - _bot.sendNotice(_bot.getChannel(), - "Symbol: " + quote[0].replaceAll("\"", "") + " [" + quote[1].replaceAll("\"", "") + - ']'); - - if (quote.length > 5) - { - _bot.sendNotice(_bot.getChannel(), "Last Trade: " + quote[2] + " (" + quote[5] + ')'); - } - else - { - _bot.sendNotice(_bot.getChannel(), "Last Trade: " + quote[2]); - } - - if (quote.length > 4) - { - _bot.sendNotice(_sender, - "Time: " + quote[3].replaceAll("\"", "") + ' ' + quote[4].replaceAll("\"", "")); - } - - if (quote.length > 6) - { - _bot.sendNotice(_sender, "Open: " + quote[6]); - } - - if (quote.length > 7) - { - _bot.sendNotice(_sender, "Day's Range: " + quote[7] + " - " + quote[8]); - } - - if (quote.length > 9) - { - _bot.sendNotice(_sender, "Volume: " + quote[9]); - } - } - else - { - _bot.sendNotice(_sender, "Invalid ticker symbol."); - } - } - else - { - _bot.sendNotice(_sender, "No data returned."); - } - } - catch (IOException e) - { - _bot.getLogger().debug("Unable to retrieve stock quote for: " + _symbol, e); - _bot.sendNotice(_sender, "An error has occurred: " + e.getMessage()); - } - } -} diff --git a/src/net/thauvin/erik/mobibot/Weather.java b/src/net/thauvin/erik/mobibot/Weather.java deleted file mode 100644 index d0f1e14..0000000 --- a/src/net/thauvin/erik/mobibot/Weather.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * @(#)Weather.java - * - * Copyright (c) 2004, Erik C. Thauvin (erik@thauvin.net) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id$ - * - */ -package net.thauvin.erik.mobibot; - -import net.sf.jweather.metar.Metar; -import net.sf.jweather.metar.SkyCondition; -import net.sf.jweather.metar.WeatherCondition; - -import java.util.Iterator; - - -/** - * Fetches the weather data from a specific station ID. - * - * @author Erik C. Thauvin - * @version $Revision$, $Date$ - * - * @created Feb 7, 2004 - * @since 1.0 - */ -public class Weather implements Runnable -{ - /** - * The URL where the stations are listed. - */ - public static final String STATIONS_URL = "http://www.rap.ucar.edu/weather/surface/stations.txt"; - - /** - * The bot. - */ - private final Mobibot _bot; - - /** - * The nick of the person who sent the message. - */ - private final String _sender; - - /** - * The station ID. - */ - private final String _station; - - /** - * The private message flag. - */ - private final boolean _isPrivate; - - /** - * Creates a new Weather object. - * - * @param bot The bot. - * @param sender The nick of the person who sent the message. - * @param station The station ID. - * @param isPrivate Set to true is the response should be send as a private message. - */ - public Weather(Mobibot bot, String sender, String station, boolean isPrivate) - { - _bot = bot; - _sender = sender; - _station = station; - _isPrivate = isPrivate; - } - - /** - * Main processing method. - */ - public void run() - { - if (_station.length() == 4) - { - final Metar metar = net.sf.jweather.Weather.getMetar(_station); - - if (metar != null) - { - Float result; - - _bot.send(_sender, "Station ID: " + metar.getStationID(), _isPrivate); - - result = metar.getWindSpeedInMPH(); - - if (result != null) - { - _bot.send(_sender, "Wind Speed: " + result + " mph, " + metar.getWindSpeedInKnots() + " knots", - _isPrivate); - } - - result = metar.getVisibility(); - - if (result != null) - { - if (!metar.getVisibilityLessThan()) - { - _bot.send(_sender, "Visibility: " + result + " mile(s)", _isPrivate); - } - else - { - _bot.send(_sender, "Visibility: < " + result + " mile(s)", _isPrivate); - } - } - - result = metar.getPressure(); - - if (result != null) - { - _bot.send(_sender, "Pressure: " + result + " in Hg", _isPrivate); - } - - result = metar.getTemperatureInCelsius(); - - if (result != null) - { - _bot.send(_sender, "Temperature: " + result + " C, " + metar.getTemperatureInFahrenheit() + " F", - _isPrivate); - } - - if (metar.getWeatherConditions() != null) - { - final Iterator it = metar.getWeatherConditions().iterator(); - - while (it.hasNext()) - { - final WeatherCondition weatherCondition = (WeatherCondition) it.next(); - _bot.send(_sender, weatherCondition.getNaturalLanguageString(), _isPrivate); - } - } - - if (metar.getSkyConditions() != null) - { - final Iterator it = metar.getSkyConditions().iterator(); - - while (it.hasNext()) - { - final SkyCondition skyCondition = (SkyCondition) it.next(); - _bot.send(_sender, skyCondition.getNaturalLanguageString(), _isPrivate); - } - } - - return; - } - } - - _bot.send(_sender, - "For a listing of the supported ICAO weather station IDs please visit: <" + STATIONS_URL + '>', - _isPrivate); - } -} diff --git a/website/index.html b/website/index.html deleted file mode 100644 index 88c3392..0000000 --- a/website/index.html +++ /dev/null @@ -1,53 +0,0 @@ - - - -mobibot - - - - -
-

mobibot

-

The #mobitopia bot

-

The latest version of mobibot is always available via CVS.

-

About mobibot

-

mobibot is the #mobitopia IRC channel bot. It is built on Paul Mutton's PircBot Java-based Framework.

-

mobibot is making extensive use of various open source libraries, including:

- -

mobibot was written by Erik C. Thauvin as a replacement for the channel's original ChumpBot.

-

Features

-

mobibot's main functionality is to capture URLs posted on the channel. The URLs are automatically gathered into a publishable RSS feed.

-

Other features include:

-
    -
  • Performing calculations
  • -
  • Converting between currencies
  • -
  • Rolling dice
  • -
  • Performing Google searches
  • -
  • Displaying the latest entries on Mobitopia.
  • -
  • Performing DNS lookups
  • -
  • Recapping public channel messages
  • -
  • Performing Google spelling queries
  • -
  • Retrieving stock quotes
  • -
  • Displaying the time in various time zones
  • -
  • Listing the users on the channel
  • -
  • Displaying weather information
  • -
-

Some of the internal features include RSS feed backlogs, rolling logs, debugging toggle and much more.

-

Using mobibot

-

To use mobibot, simply join #mobitopia on irc.freenode.net and type:

-

mobibot: help

-

mobibot will reply with a listing of the commands currently supported.

-

Licenses

-

There are various open source licenses attached to mobibot. Please refer to the licenses directory in the CVS tree for more details.

-
- - diff --git a/website/simple.css b/website/simple.css deleted file mode 100644 index 4092d3f..0000000 --- a/website/simple.css +++ /dev/null @@ -1,52 +0,0 @@ -body { - background: #ffffff; - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 13px; - color: #000000; - margin: 0px; -} - -h1 { - color: #333399; -} - -h2 { - border-bottom: 2px solid #9999cc; -} - -h3 { - padding-top: 25px; - border-bottom: 1px solid #9999cc; -} - -code { - font-family: Courier New, Courier, mono, monospace; - font-size: 12px; - color: #000066; - background-color: #ffeedd; -} - -a:hover { - color: #ff0000; - background: #eeeeff; -} - -#content { - float: none; - position: relative; - margin: 0px 10px 10px 10px; - padding: 0px 10px 10px 10px; -} - -#content p { - padding-left: 10px; -} - -#content p.note { - padding: 5px; - border: 1px solid #9999cc; - border-right: 2px solid #666699; - border-bottom: 2px solid #666699; - background: #eeeeff; - margin: 20px 50px; -} \ No newline at end of file