diff --git a/.cvsignore b/.cvsignore index b6ec88c..3369402 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,6 +1,8 @@ +DevSuite build dist log4j.properties mobibot.properties +fetcher.properties *.ser logs \ No newline at end of file diff --git a/ant/jreleaseinfo-1.2.0.jar b/ant/jreleaseinfo-1.2.0.jar new file mode 100644 index 0000000..4ff0018 Binary files /dev/null and b/ant/jreleaseinfo-1.2.0.jar differ diff --git a/build.properties b/build.properties index e30731e..763f3c5 100644 --- a/build.properties +++ b/build.properties @@ -1 +1,12 @@ -main.class=net.thauvin.erik.mobibot.Mobibot \ No newline at end of file +# Project +proj.name=mobibot +proj.version=0.2 +proj.package=net.thauvin.erik.mobibot +proj.run=${proj.package}.Mobibot + +# Locations +path.classes=build +path.src=src +path.dist=dist +path.lib=lib +path.ant=ant \ No newline at end of file diff --git a/build.xml b/build.xml index 7b71d76..d3386f6 100644 --- a/build.xml +++ b/build.xml @@ -1,10 +1,6 @@ - - - - @@ -13,12 +9,19 @@ + + + + + + + @@ -34,7 +37,7 @@ - + diff --git a/buildnum.properties b/buildnum.properties new file mode 100644 index 0000000..fe05142 --- /dev/null +++ b/buildnum.properties @@ -0,0 +1,3 @@ +#ANT Task: ch.oscg.jreleaseinfo.BuildNumberHandler +#Thu Sep 23 13:38:29 PDT 2004 +build.num.last=1 diff --git a/lib/EXML.jar b/lib/EXML.jar deleted file mode 100644 index d03257d..0000000 Binary files a/lib/EXML.jar and /dev/null differ diff --git a/lib/fetchrss.jar b/lib/fetchrss.jar deleted file mode 100644 index 75b4830..0000000 Binary files a/lib/fetchrss.jar and /dev/null differ diff --git a/lib/jdom-1.0.jar b/lib/jdom-1.0.jar new file mode 100644 index 0000000..288e64c Binary files /dev/null and b/lib/jdom-1.0.jar differ diff --git a/lib/jdom.jar b/lib/jdom.jar deleted file mode 100644 index 35850af..0000000 Binary files a/lib/jdom.jar and /dev/null differ diff --git a/lib/pircbot.jar b/lib/pircbot.jar index d936d70..ce4a42d 100644 Binary files a/lib/pircbot.jar and b/lib/pircbot.jar differ diff --git a/lib/rome-0.4.jar b/lib/rome-0.4.jar new file mode 100644 index 0000000..a2937c0 Binary files /dev/null and b/lib/rome-0.4.jar differ diff --git a/lib/rome-fetcher-0.4.jar b/lib/rome-fetcher-0.4.jar new file mode 100644 index 0000000..4ad3371 Binary files /dev/null and b/lib/rome-fetcher-0.4.jar differ diff --git a/lib/rsslibj.jar b/lib/rsslibj.jar deleted file mode 100644 index 53c784b..0000000 Binary files a/lib/rsslibj.jar and /dev/null differ diff --git a/licenses/EXML-license.txt b/licenses/EXML-license.txt deleted file mode 100644 index 9c34118..0000000 --- a/licenses/EXML-license.txt +++ /dev/null @@ -1,57 +0,0 @@ -TERMS AND CONDITIONS FOR ELECTRIC XML - Please read this license agreement carefully. Your use of Electric XML or any -related documentation indicates your acceptance of the following terms and -conditions. If you do not agree to these terms and conditions, you may not -install or use Electric XML. The term Electric XML refers to both the basic -Electric XML software and Electric XML+. -1. Ownership and License. Electric XML is owned by The Mind Electric and is -copyrighted and licensed, not sold. The Mind Electric grants you a -non-exclusive, non-transferable license to use, modify and distribute Electric -XML in both binary and source form as long as all of the following conditions -are met: - You are not bundling Electric XML or a derivative of it as part of a software - development environment such as JBuilder, WebGain or VisualAge. Note that this - restriction is targeted at IDE vendors, and does not prevent developers from - loading Electric XML into an IDE and using it during everyday development. - You are not integrating Electric XML or a derivative of it into a distributed - computing infrastructure or database platform such as WebLogic, Apache SOAP, - WebSphere, Oracle application server, or HP e-speak. Note that this - restriction is targeted at software infrastructure vendors, and does not - prevent developers from using and bundling Electric XML with applications that - run on these platforms. - You are not integrating Electric XML or a derivative of it into an alternative - to Electric XML such as Xerces or JDOM. - You must not remove any of the copyright information from the Electric XML - source code or documentation. -If you cannot meet all of these conditions, please contact us to arrange a -special custom license. -2. Term and Termination -This Agreement is effective until terminated. You may terminate this Agreement -at any time by destroying all copies of Electric XML. This Agreement will -terminate immediately without notice from The Mind Electric if you fail to -comply with any provision of this Agreement. Upon termination, you must destroy -all copies of Electric XML. -3. Warranty Disclaimer and Limitation of Liability -The Mind Electric licenses the Software to you on an "as is" basis, without -warranty of any kind. The Mind Electric hereby expressly disclaims all -warranties or conditions, either express or implied, including, but not limited -to, the implied warranties or conditions of merchantability and fitness for a -particular purpose. You are solely responsible for determining the -appropriateness of using Electric XML and assume all risks associated with the -use of it, including but not limited to the risks of program errors, damage to -or loss of data, programs or equipment, and unavailability or interruption of -operations. Some jurisdictions do not allow for the exclusion or limitation of -implied warranties, so the above limitations or exclusions may not apply to you. -The Mind Electric will not be liable for any direct damages or for any special, -incidental, or indirect damages or for any economic consequential damages -(including lost profits or savings), even if The Mind Electric has been advised -of the possibility of such damages. The Mind Electric will not be liable for the -loss of, or damage to, your records or data, or any damages claimed by you based -on a third party claim. Some jurisdictions do not allow for the exclusion or -limitation of incidental or consequential damages, so the above limitations or -exclusions may not apply to you. -4. General -This Agreement is governed by the laws of the State of Texas. This Agreement is -the only understanding and agreement we have regarding your use of Electric XML. -It supersedes all other communications, understandings or agreements we may have -had prior to this Agreement. \ No newline at end of file diff --git a/licenses/ROME License.txt b/licenses/ROME License.txt new file mode 100644 index 0000000..f43cdb1 --- /dev/null +++ b/licenses/ROME License.txt @@ -0,0 +1,14 @@ +Copyright 2004 Sun Microsystems, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + diff --git a/licenses/RSSJLib License.txt b/licenses/RSSJLib License.txt deleted file mode 100644 index b475844..0000000 --- a/licenses/RSSJLib License.txt +++ /dev/null @@ -1,83 +0,0 @@ -Apache Software License -Version 1.1 - -Copyright (c) 2000 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 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 "Apache" 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 (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 . - -Portions of this software are based upon public domain software originally -written at the National Center for Supercomputing Applications, University of -Illinois, Urbana-Champaign. - -Electric XML is owned by The Mind Electric and is copyrighted and licensed, not -sold. The Mind Electric grants you a non-exclusive, non-transferable license to -use, modify and distribute Electric XML in both binary and source form as long -as all of the following conditions are met: - -You are not bundling Electric XML or a derivative of it as part of a software -development environment such as JBuilder, WebGain or VisualAge. Note that this -restriction is targeted at IDE vendors, and does not prevent developers from -loading Electric XML into an IDE and using it during everyday development. - - -You are not integrating Electric XML or a derivative of it into a distributed -computing infrastructure or database platform such as WebLogic, Apache SOAP, -WebSphere, Oracle application server, or HP e-speak. Note that this restriction -is targeted at software infrastructure vendors, and does not prevent developers -from using and bundling Electric XML with applications that run on these -platforms. - - -You are not integrating Electric XML or a derivative of it into an alternative -to Electric XML such as Xerces or JDOM. - - -You must not remove any of the copyright information from the Electric XML -source code or documentation. - - diff --git a/licenses/fetchrss License.txt b/licenses/fetchrss License.txt deleted file mode 100644 index e22776b..0000000 --- a/licenses/fetchrss License.txt +++ /dev/null @@ -1,502 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 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. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -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 and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, 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 library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete 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 distribute a copy of this License along with the -Library. - - 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 Library or any portion -of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -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 Library, 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 Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you 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. - - If distribution of 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 satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be 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. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library 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. - - 9. 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 Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -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 with -this License. - - 11. 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 Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library 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 Library. - -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. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library 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. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser 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 Library -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 Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -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 - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "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 -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. 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 LIBRARY 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 -LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. 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 library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; 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. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! \ No newline at end of file diff --git a/mobibot.iml b/mobibot.iml index 5d6c1f0..ba3d60d 100644 --- a/mobibot.iml +++ b/mobibot.iml @@ -9,24 +9,6 @@ - - - - - - - - - - - - - - - - - - @@ -63,24 +45,6 @@ - - - - - - - - - - - - - - - - - - @@ -144,6 +108,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mobibot.ipr b/mobibot.ipr index 7c5dcf4..8feccb5 100644 --- a/mobibot.ipr +++ b/mobibot.ipr @@ -118,6 +118,29 @@ + + + + + - - - - - + + @@ -358,17 +397,17 @@ - + - + - + - - - + + + @@ -458,87 +497,80 @@ - + - - - - + + + + + + + + + + + - - - - + + + + + + - + - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + - + - + + + + + + + + + + + + + + + @@ -547,13 +579,48 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/net/thauvin/erik/mobibot/CurrencyConverter.java b/src/net/thauvin/erik/mobibot/CurrencyConverter.java index 01719b7..f13ba84 100644 --- a/src/net/thauvin/erik/mobibot/CurrencyConverter.java +++ b/src/net/thauvin/erik/mobibot/CurrencyConverter.java @@ -66,7 +66,7 @@ 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"; + private static final String EXCHANGE_TABLE_URL = "http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"; /** * The exchange rates. @@ -119,7 +119,7 @@ public class CurrencyConverter implements Runnable } // Converts specified currencies. - public void run() + public final void run() { if (EXCHANGE_RATES.isEmpty()) { @@ -150,12 +150,12 @@ public class CurrencyConverter implements Runnable 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."); + _bot.send(_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, + _bot.send(_sender, "An error has occurred while fetching the exchange rates table: " + e.getMessage()); } } @@ -170,7 +170,7 @@ public class CurrencyConverter implements Runnable { if (cmds[3].equals(cmds[1])) { - _bot.sendNotice(_sender, "You're kidding, right?"); + _bot.send(_sender, "You're kidding, right?"); } else { @@ -180,7 +180,7 @@ public class CurrencyConverter implements Runnable final double from = Double.parseDouble((String) EXCHANGE_RATES.get(cmds[1].toUpperCase())); final double to = Double.parseDouble((String) EXCHANGE_RATES.get(cmds[3].toUpperCase())); - _bot.sendNotice(_bot.getChannel(), + _bot.send(_bot.getChannel(), NumberFormat.getCurrencyInstance(Locale.US).format(amt).substring(1) + ' ' + cmds[1].toUpperCase() + " = " + NumberFormat.getCurrencyInstance(Locale.US).format((amt * to) / from) @@ -188,7 +188,7 @@ public class CurrencyConverter implements Runnable } catch (NullPointerException e) { - _bot.sendNotice(_sender, + _bot.send(_sender, "The supported currencies are: " + EXCHANGE_RATES.keySet().toString()); } } @@ -196,7 +196,7 @@ public class CurrencyConverter implements Runnable } else if (_query.equals(RATES_KEYWORD)) { - _bot.sendNotice(_sender, "Last Update: " + s_date); + _bot.send(_sender, "Last Update: " + s_date); final Iterator it = EXCHANGE_RATES.keySet().iterator(); String rate; @@ -213,19 +213,19 @@ public class CurrencyConverter implements Runnable buff.append(rate).append(": ").append(EXCHANGE_RATES.get(rate)); } - _bot.sendNotice(_sender, buff.toString()); + _bot.send(_sender, buff.toString()); } else { _bot.helpResponse(_sender, Mobibot.CURRENCY_CMD + ' ' + _query); - _bot.sendNotice(_sender, "The supported currencies are: " + EXCHANGE_RATES.keySet().toString()); + _bot.send(_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."); + _bot.send(_sender, "Sorry, but the exchange rate table is empty."); } } } diff --git a/src/net/thauvin/erik/mobibot/EntryLink.java b/src/net/thauvin/erik/mobibot/EntryLink.java index 67fe2ae..3a81c53 100644 --- a/src/net/thauvin/erik/mobibot/EntryLink.java +++ b/src/net/thauvin/erik/mobibot/EntryLink.java @@ -63,7 +63,7 @@ public class EntryLink implements Serializable /** * The creation date. */ - private final Date _date = Calendar.getInstance().getTime(); + private Date _date = Calendar.getInstance().getTime(); /** * The comments. @@ -74,6 +74,7 @@ public class EntryLink implements Serializable private String _nick = ""; private String _title = "No Title"; + /** * Creates a new entry. * @@ -88,6 +89,22 @@ public class EntryLink implements Serializable _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 date The entry date. + */ + public EntryLink(String link, String title, String nick, Date date) + { + _link = link; + _title = title; + _nick = nick; + _date = date; + } + /** * Creates a new entry. * diff --git a/src/net/thauvin/erik/mobibot/FeedReader.java b/src/net/thauvin/erik/mobibot/FeedReader.java index 2d10912..85cad19 100644 --- a/src/net/thauvin/erik/mobibot/FeedReader.java +++ b/src/net/thauvin/erik/mobibot/FeedReader.java @@ -36,20 +36,15 @@ */ 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 com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndEntryImpl; +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.fetcher.FeedFetcher; +import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher; -import org.jdom.JDOMException; +import java.net.MalformedURLException; +import java.net.URL; -import org.jdom.input.SAXBuilder; - -import java.io.IOException; -import java.io.StringReader; - -import java.util.Iterator; import java.util.List; @@ -106,58 +101,32 @@ public class FeedReader implements Runnable /** * Fetches the Feed's items. */ - public void run() + public final void run() { - List items = null; + final FeedFetcher fetcher = new HttpURLFeedFetcher(_bot.getFeedInfoCache()); try { - final Response response = new UrlLoader().load(_url, _bot.getFeedLastMod()); + final SyndFeed feed = fetcher.retrieveFeed(new URL(_url)); + SyndEntry item; + final List items = feed.getEntries(); - if (response != null) + for (int i = 0; (i < items.size()) && (i < MAX_ITEMS); i++) { - _bot.setFeedLastMod(response.getLastModified()); - - final Channel chan = new Parser().parse(new SAXBuilder().build(new StringReader(response.getBody()))); - items = chan.getItems(); - _bot.setFeedItems(items); + item = (SyndEntryImpl) items.get(i); + _bot.send(_sender, item.getTitle()); + _bot.send(_sender, TAB_INDENT + item.getLink()); } } - catch (JDOMException e) + catch (MalformedURLException e) { - _bot.getLogger().debug("Unable to parse the feed.", e); - _bot.sendNotice(_sender, "An error has occurred while parsing the feed."); + _bot.getLogger().debug("Invalid feed URL.", e); + _bot.send(_sender, "The feed URL is invalid."); } - catch (IOException e) + catch (Exception 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()); - } + _bot.send(_sender, "An error has occurred while fetching the feed: " + e.getMessage()); } } } diff --git a/src/net/thauvin/erik/mobibot/GoogleSearch.java b/src/net/thauvin/erik/mobibot/GoogleSearch.java index 3e04085..7e70375 100644 --- a/src/net/thauvin/erik/mobibot/GoogleSearch.java +++ b/src/net/thauvin/erik/mobibot/GoogleSearch.java @@ -115,7 +115,7 @@ public class GoogleSearch implements Runnable /** * Main processing method. */ - public void run() + public final void run() { GOOGLE_BEAN.setKey(_key); @@ -127,17 +127,17 @@ public class GoogleSearch implements Runnable if (Mobibot.isValidString(r)) { - _bot.sendNotice(_sender, Mobibot.unescapeXml(r)); + _bot.send(_sender, Mobibot.unescapeXml(r)); } else { - _bot.sendNotice(_sender, "You've just won our spelling bee contest."); + _bot.send(_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()); + _bot.send(_sender, "An error has occurred: " + e.getMessage()); } } else @@ -152,17 +152,17 @@ public class GoogleSearch implements Runnable { for (int i = 0; i < GOOGLE_BEAN.getResultElementsCount(); i++) { - _bot.sendNotice(_sender, + _bot.send(_sender, Mobibot.unescapeXml(GOOGLE_BEAN.getResultElementProperty(i, "title").replaceAll("<([bB]|/[bB])>", Colors.BOLD))); - _bot.sendNotice(_sender, TAB_INDENT + GOOGLE_BEAN.getResultElementProperty(i, "url")); + _bot.send(_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()); + _bot.send(_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 index c6f4d64..917d456 100644 --- a/src/net/thauvin/erik/mobibot/Mobibot.java +++ b/src/net/thauvin/erik/mobibot/Mobibot.java @@ -38,8 +38,12 @@ package net.thauvin.erik.mobibot; import com.primalworld.math.MathEvaluator; -import com.rsslibj.elements.Channel; -import com.rsslibj.elements.Item; +import com.sun.syndication.feed.synd.*; +import com.sun.syndication.fetcher.impl.FeedFetcherCache; +import com.sun.syndication.fetcher.impl.HashMapFeedInfoCache; +import com.sun.syndication.io.FeedException; +import com.sun.syndication.io.SyndFeedInput; +import com.sun.syndication.io.SyndFeedOutput; import org.apache.commons.cli.*; import org.apache.commons.logging.impl.Log4JLogger; @@ -83,7 +87,10 @@ public class Mobibot extends PircBot * The info strings. */ private static final String[] INFO_STRS = - { "Mobibot v0.1.3b12 by Erik C. Thauvin (erik@thauvin.net)", "http://www.thauvin.net/mobitopia/mobibot/" }; + { + "Mobibot v" + ReleaseInfo.getVersion() + '.' + ReleaseInfo.getBuildNumber() + + " by Erik C. Thauvin (erik@thauvin.net)", "http://www.thauvin.net/mobitopia/mobibot/" + }; /** * Debug command line argument. @@ -100,11 +107,6 @@ public class Mobibot extends PircBot */ private static final String PROPS_ARG = "properties"; - /** - * The command line agrument to specified the object serialization file where data is saved between launches. - */ - private static final String DATA_ARG = "serial"; - /** * The maximum number of times the bot will try to reconnect, if disconnected. */ @@ -353,16 +355,26 @@ public class Mobibot extends PircBot */ private static final int MESSAGE_DELAY = 1000; + /** + * The name of the file containing the current entries. + */ + private static final String CURRENT_XML = "current.xml"; + + /** + * The name of the file containing the backlog entries. + */ + private static final String NAV_XML = "nav.xml"; + + /** + * The feed info cache. + */ + private final FeedFetcherCache _feedInfoCache = HashMapFeedInfoCache.getInstance(); + /** * The logger default level. */ private final Level _loggerLevel; - /** - * The feed items. - */ - private final List _feedItems = new ArrayList(0); - /** * The logger. */ @@ -373,11 +385,6 @@ public class Mobibot extends PircBot */ private final String _channel; - /** - * The data file. - */ - private final String _data; - /** * The IRC server. */ @@ -403,9 +410,6 @@ public class Mobibot extends PircBot */ private String _backlogsURL = ""; - // The feed last modification date. - private String _feedLastMod = ""; - /** * The feed URL. */ @@ -427,70 +431,53 @@ public class Mobibot extends PircBot * * @param server The server. * @param channel The channel. - * @param data The serial data file. * @param logsDir The logs directory. */ - public Mobibot(String server, String channel, String data, String logsDir) + public Mobibot(String server, String channel, 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; - _data = data; _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); - - if (ser.exists()) + // Load the current entries, if any. + try { - ObjectInputStream ois = null; + loadEntries(_logsDir + CURRENT_XML); - try + if (!today().equals(_today)) { - ois = new ObjectInputStream(new FileInputStream(ser)); + _entries.clear(); + _today = today(); + } + } + catch (FileNotFoundException ignore) + { + ; // Do nothing. + } + catch (FeedException e) + { + _logger.error("An error occured while parsing the '" + CURRENT_XML + "' file.", e); + } - _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 - } - } - } + // Load the backlogs, if any. + try + { + loadBacklogs(_logsDir + NAV_XML); + } + catch (FileNotFoundException ignore) + { + ; // Do nothing. + } + catch (FeedException e) + { + _logger.error("An error occured while parsing the '" + NAV_XML + "' file.", e); } } @@ -524,7 +511,6 @@ public class Mobibot extends PircBot options.addOption(DEBUG_ARG.substring(0, 1), DEBUG_ARG, false, "print debug & logging data directly to the console"); options.addOption(PROPS_ARG.substring(0, 1), PROPS_ARG, true, "use alternate properties file"); - options.addOption(DATA_ARG.substring(0, 1), DATA_ARG, true, "use alternate serial data file"); // Parse the command line final CommandLineParser parser = new PosixParser(); @@ -634,8 +620,7 @@ public class Mobibot extends PircBot final String googleKey = p.getProperty("google", ""); // Create the bot - final Mobibot bot = - new Mobibot(server, channel, line.getOptionValue(DATA_ARG.charAt(0), "./mobibot.ser"), logsDir); + final Mobibot bot = new Mobibot(server, channel, logsDir); // Initialize the bot bot.setVerbose(true); @@ -653,6 +638,9 @@ public class Mobibot extends PircBot // Set the Google key bot.setGoogleKey(googleKey); + // Save the entries + bot.saveEntries(true); + // Connect try { @@ -718,49 +706,13 @@ public class Mobibot extends PircBot } /** - * Sets the feed items. + * Returns the {@link FeedFetcherCache feed info cache}. * - * @param items The feed items. + * @return The feed info cache. */ - public final synchronized void setFeedItems(List items) + public final synchronized FeedFetcherCache getFeedInfoCache() { - _feedItems.clear(); - _feedItems.addAll(items); - } - - /** - * Returns the feed items. - * - * @return The feed items. - */ - public final synchronized List getFeedItems() - { - return _feedItems; - } - - /** - * Sets the feed last modification date. - * - * @param feedLastMod The last modification date. - */ - public final synchronized void setFeedLastMod(String feedLastMod) - { - _feedLastMod = feedLastMod; - } - - /** - * Returns the feed last modification date. - * - * @return The feed modification date, or empty. - */ - public final synchronized String getFeedLastMod() - { - if (_feedLastMod != null) - { - return _feedLastMod; - } - - return ""; + return _feedInfoCache; } /** @@ -785,148 +737,158 @@ public class Mobibot extends PircBot if (lcTopic.endsWith(HELP_POSTING_KEYWORD)) { - this.sendNotice(sender, bold("Post a URL, by saying it on a line on its own.")); - this.sendNotice(sender, "I will reply with a label, for example: " + bold(LINK_CMD + '1')); - this.sendNotice(sender, "To add a title, use a its label and a pipe:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(LINK_CMD + "1:|This is the title")); - this.sendNotice(sender, "To add a comment: "); - this.sendNotice(sender, DOUBLE_INDENT + bold(LINK_CMD + "1:This is a comment")); - this.sendNotice(sender, "I will reply with a label, for example: " + bold(LINK_CMD + "1.1")); - this.sendNotice(sender, "To edit a comment, use its label: "); - this.sendNotice(sender, DOUBLE_INDENT + 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 + bold(LINK_CMD + "1.1:-")); - this.sendNotice(sender, "You can also view a posting by saying its label."); + send(sender, bold("Post a URL, by saying it on a line on its own.")); + send(sender, "I will reply with a label, for example: " + bold(LINK_CMD + '1')); + send(sender, "To add a title, use a its label and a pipe:"); + send(sender, DOUBLE_INDENT + bold(LINK_CMD + "1:|This is the title")); + send(sender, "To add a comment: "); + send(sender, DOUBLE_INDENT + bold(LINK_CMD + "1:This is a comment")); + send(sender, "I will reply with a label, for example: " + bold(LINK_CMD + "1.1")); + send(sender, "To edit a comment, use its label: "); + send(sender, DOUBLE_INDENT + bold(LINK_CMD + "1.1:This is an edited comment")); + send(sender, "To delete a comment, use its label and a minus sign: "); + send(sender, DOUBLE_INDENT + bold(LINK_CMD + "1.1:-")); + send(sender, "You can also view a posting by saying its label."); } else if (lcTopic.endsWith(VIEW_CMD)) { - this.sendNotice(sender, "To list or search the current URL posts:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + VIEW_CMD) + " [] []"); + send(sender, "To list or search the current URL posts:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + VIEW_CMD) + " [] []"); } - else if (lcTopic.endsWith(_channel.substring(1).toLowerCase())) + else if (lcTopic.endsWith(getChannel().substring(1).toLowerCase())) { - this.sendNotice(sender, "To list the last 5 posts from the channel's weblog:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + _channel.substring(1))); + send(sender, "To list the last 5 posts from the channel's weblog:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + getChannel().substring(1))); } else if (lcTopic.endsWith(GOOGLE_CMD)) { - this.sendNotice(sender, "To search Google:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + GOOGLE_CMD + " ")); + send(sender, "To search Google:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + GOOGLE_CMD + " ")); } else if (lcTopic.endsWith(RECAP_CMD)) { - this.sendNotice(sender, "To list the last 10 public channel messages:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + RECAP_CMD)); + send(sender, "To list the last 10 public channel messages:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + RECAP_CMD)); } else if (lcTopic.endsWith(CALC_CMD)) { - this.sendNotice(sender, "To solve a mathematical calculation:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + CALC_CMD + " ")); + send(sender, "To solve a mathematical calculation:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + CALC_CMD + " ")); } else if (lcTopic.endsWith(LOOKUP_CMD)) { - this.sendNotice(sender, "To perform a DNS lookup query:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + LOOKUP_CMD + " ")); + send(sender, "To perform a DNS lookup query:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + LOOKUP_CMD + " ")); } else if (lcTopic.endsWith(TIME_CMD)) { - this.sendNotice(sender, "To display a country's current date/time:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + TIME_CMD) + " []"); + send(sender, "To display a country's current date/time:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + TIME_CMD) + " []"); - this.sendNotice(sender, "For a listing of the supported countries:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + TIME_CMD)); + send(sender, "For a listing of the supported countries:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + TIME_CMD)); } else if (lcTopic.endsWith(SPELL_CMD)) { - this.sendNotice(sender, "To have Google try to correctly spell a sentence:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + SPELL_CMD + " ")); + send(sender, "To have Google try to correctly spell a sentence:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + SPELL_CMD + " ")); } else if (lcTopic.endsWith(STOCK_CMD)) { - this.sendNotice(sender, "To retrieve a stock quote:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + STOCK_CMD + " ")); + send(sender, "To retrieve a stock quote:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + STOCK_CMD + " ")); } else if (lcTopic.endsWith(DICE_CMD)) { - this.sendNotice(sender, "To roll the dice:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + DICE_CMD)); + send(sender, "To roll the dice:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + DICE_CMD)); } else if (lcTopic.endsWith(WEATHER_CMD)) { - this.sendNotice(sender, "To display weather information:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + WEATHER_CMD + " ")); - this.sendNotice(sender, - "For a listing of the ICAO station IDs, please visit: <" + Weather.STATIONS_URL + '>'); + send(sender, "To display weather information:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + WEATHER_CMD + " ")); + send(sender, "For a listing of the ICAO station IDs, please visit: <" + Weather.STATIONS_URL + '>'); } else if (lcTopic.endsWith(USERS_CMD)) { - this.sendNotice(sender, "To list the users present on the channel:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + USERS_CMD)); + send(sender, "To list the users present on the channel:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + USERS_CMD)); } else if (lcTopic.endsWith(INFO_CMD)) { - this.sendNotice(sender, "To view information about the bot:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + INFO_CMD)); + send(sender, "To view information about the bot:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + INFO_CMD)); } else if (lcTopic.endsWith(CYCLE_CMD)) { if (isOp(sender)) { - this.sendNotice(sender, "To have the bot leave the channel and come back:"); - this.sendNotice(sender, DOUBLE_INDENT + bold("/msg " + getNick() + ' ' + CYCLE_CMD)); + send(sender, "To have the bot leave the channel and come back:"); + send(sender, DOUBLE_INDENT + bold("/msg " + getNick() + ' ' + CYCLE_CMD)); } } else if (lcTopic.endsWith(ME_CMD)) { if (isOp(sender)) { - this.sendNotice(sender, "To have the bot perform an action:"); - this.sendNotice(sender, DOUBLE_INDENT + bold("/msg " + getNick() + ' ' + ME_CMD + " ")); + send(sender, "To have the bot perform an action:"); + send(sender, DOUBLE_INDENT + bold("/msg " + getNick() + ' ' + ME_CMD + " ")); } } else if (lcTopic.endsWith(SAY_CMD)) { if (isOp(sender)) { - this.sendNotice(sender, "To have the bot say something on the channel:"); - this.sendNotice(sender, DOUBLE_INDENT + bold("/msg " + getNick() + ' ' + SAY_CMD + " ")); + send(sender, "To have the bot say something on the channel:"); + send(sender, DOUBLE_INDENT + bold("/msg " + getNick() + ' ' + SAY_CMD + " ")); } } else if (lcTopic.startsWith(CURRENCY_CMD)) { - this.sendNotice(sender, "To convert from one currency to another:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + CURRENCY_CMD + " [100 USD to EUR]")); + send(sender, "To convert from one currency to another:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + CURRENCY_CMD + " [100 USD to EUR]")); if (lcTopic.endsWith(CURRENCY_CMD)) { - this.sendNotice(sender, "For a listing of supported currencies:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + CURRENCY_CMD)); + send(sender, "For a listing of supported currencies:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + CURRENCY_CMD)); } } else { - this.sendNotice(sender, bold("Type a URL on " + _channel + " to post it.")); - this.sendNotice(sender, "For more information on specific command, type:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(getNick() + ": " + HELP_CMD + " ")); - this.sendNotice(sender, "The commands are:"); - this.sendNotice(sender, - DOUBLE_INDENT + - bold(CALC_CMD + ' ' + CURRENCY_CMD + ' ' + DICE_CMD + ' ' + GOOGLE_CMD + ' ' + INFO_CMD + - ' ' + _channel.substring(1) + ' ' + LOOKUP_CMD)); - this.sendNotice(sender, - DOUBLE_INDENT + - bold(HELP_POSTING_KEYWORD + ' ' + RECAP_CMD + ' ' + SPELL_CMD + ' ' + STOCK_CMD + ' ' + - TIME_CMD + ' ' + USERS_CMD + ' ' + VIEW_CMD)); - this.sendNotice(sender, DOUBLE_INDENT + bold(WEATHER_CMD)); + send(sender, bold("Type a URL on " + getChannel() + " to post it.")); + send(sender, "For more information on specific command, type:"); + send(sender, DOUBLE_INDENT + bold(getNick() + ": " + HELP_CMD + " ")); + send(sender, "The commands are:"); + send(sender, + DOUBLE_INDENT + + bold(CALC_CMD + ' ' + CURRENCY_CMD + ' ' + DICE_CMD + ' ' + GOOGLE_CMD + ' ' + INFO_CMD + ' ' + + getChannel().substring(1) + ' ' + LOOKUP_CMD)); + send(sender, + DOUBLE_INDENT + + bold(HELP_POSTING_KEYWORD + ' ' + RECAP_CMD + ' ' + SPELL_CMD + ' ' + STOCK_CMD + ' ' + TIME_CMD + + ' ' + USERS_CMD + ' ' + VIEW_CMD)); + send(sender, DOUBLE_INDENT + bold(WEATHER_CMD)); if (isOp(sender)) { - this.sendNotice(sender, "The op commands are:"); - this.sendNotice(sender, DOUBLE_INDENT + bold(CYCLE_CMD + ' ' + ME_CMD + ' ' + SAY_CMD)); + send(sender, "The op commands are:"); + send(sender, DOUBLE_INDENT + bold(CYCLE_CMD + ' ' + ME_CMD + ' ' + SAY_CMD)); } } } + /** + * Sends a private notice. + * + * @param sender The nick of the person who sent the message. + * @param message The actual message. + */ + public final void send(String sender, String message) + { + send(sender, message, false); + } + /** * Sends a private message or notice. * @@ -938,57 +900,24 @@ public class Mobibot extends PircBot { if (isPrivate) { + if (_logger.isDebugEnabled()) + { + _logger.debug("Sending message to " + sender + ": " + message); + } + this.sendMessage(sender, message); } else { + if (_logger.isDebugEnabled()) + { + _logger.debug("Sending notice to " + sender + ": " + message); + } + this.sendNotice(sender, message); } } - /** - * Copies a file - * - * @param in The source file. - * @param out The destination file - * - * @throws IOException If the file could not be copied. - */ - public void copyFile(File in, File out) - throws IOException - { - FileChannel inChannel; - FileChannel outChannel; - - inChannel = new FileInputStream(in).getChannel(); - outChannel = new FileOutputStream(out).getChannel(); - - try - { - inChannel.transferTo(0, inChannel.size(), outChannel); - } - finally - { - try - { - inChannel.close(); - } - catch (IOException ignore) - { - ; // Do nothing - } - - try - { - outChannel.close(); - } - catch (IOException ignore) - { - ; // Do nothing - } - } - } - /** * This method is called whenever an ACTION is sent from a user. * @@ -1000,7 +929,7 @@ public class Mobibot extends PircBot */ protected final void onAction(String sender, String login, String hostname, String target, String action) { - if (target.equals(_channel)) + if (target.equals(getChannel())) { recap(sender, action, true); } @@ -1063,7 +992,10 @@ public class Mobibot extends PircBot */ protected final void onMessage(String channel, String sender, String login, String hostname, String message) { - _logger.debug(">>> " + sender + ": " + message); + if (_logger.isDebugEnabled()) + { + _logger.debug(">>> " + sender + ": " + message); + } if (message.matches(LINK_MATCH)) { @@ -1095,14 +1027,14 @@ public class Mobibot extends PircBot final int index = _entries.size() - 1; final EntryLink entry = (EntryLink) _entries.get(index); - this.sendNotice(channel, buildLink(index, entry)); + send(channel, buildLink(index, entry)); saveEntries(isBackup); } else { final EntryLink entry = (EntryLink) _entries.get(dupIndex); - this.sendNotice(sender, "Duplicate >> " + buildLink(dupIndex, entry)); + send(sender, "Duplicate >> " + buildLink(dupIndex, entry)); } } else if (message.matches(getNickPattern() + ":.*")) @@ -1124,13 +1056,13 @@ public class Mobibot extends PircBot else if (cmd.equals(PING_CMD)) { final String[] pings = - { - "is barely alive.", "is trying to stay awake.", "has gone fishing.", - "is somewhere over the rainbow.", "has fallen and can't get up.", - "is running. You better go chase it.", "has just spontantiously combusted.", - "is talking to itself... don't interrupt. That's rude.", "is bartending at an AA meeting.", - "is hibernating.", "is saving energy: apathetic mode activated.", "is busy. Go away!" - }; + { + "is barely alive.", "is trying to stay awake.", "has gone fishing.", + "is somewhere over the rainbow.", "has fallen and can't get up.", + "is running. You better go chase it.", "has just spontantiously combusted.", + "is talking to itself... don't interrupt. That's rude.", "is bartending at an AA meeting.", + "is hibernating.", "is saving energy: apathetic mode activated.", "is busy. Go away!" + }; final Random r = new Random(); @@ -1159,26 +1091,26 @@ public class Mobibot extends PircBot 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); + send(getChannel(), 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)); + this.sendAction(getChannel(), "rolled two dice: " + i + " and " + y + " for a total of " + (i + y)); if (total < (i + y)) { - this.sendAction(_channel, "wins."); + this.sendAction(getChannel(), "wins."); } else if (total > (i + y)) { - this.sendAction(_channel, "lost."); + this.sendAction(getChannel(), "lost."); } else { - this.sendAction(_channel, "tied."); + this.sendAction(getChannel(), "tied."); } } - else if (cmd.equalsIgnoreCase(_channel.substring(1))) + else if (cmd.equalsIgnoreCase(getChannel().substring(1))) { feedResponse(sender); } @@ -1214,7 +1146,7 @@ public class Mobibot extends PircBot try { - this.sendNotice(_channel, String.valueOf(me.getValue())); + send(getChannel(), String.valueOf(me.getValue())); } catch (Exception e) { @@ -1247,7 +1179,7 @@ public class Mobibot extends PircBot if (cmd.length() == 0) { final EntryLink entry = (EntryLink) _entries.get(index); - this.sendNotice(_channel, buildLink(index, entry)); + send(getChannel(), buildLink(index, entry)); if (entry.hasComments()) { @@ -1255,7 +1187,7 @@ public class Mobibot extends PircBot for (int i = 0; i < comments.length; i++) { - this.sendNotice(_channel, buildComment(index, i, comments[i])); + send(getChannel(), buildComment(index, i, comments[i])); } } } @@ -1268,12 +1200,12 @@ public class Mobibot extends PircBot if (entry.getLogin().equals(login) || isOp(sender)) { _entries.remove(index); - this.sendNotice(_channel, "Entry " + LINK_CMD + (index + 1) + " removed."); + send(getChannel(), "Entry " + LINK_CMD + (index + 1) + " removed."); saveEntries(false); } else { - this.sendNotice(sender, "Please ask a channel op to remove this entry for you."); + send(sender, "Please ask a channel op to remove this entry for you."); } } else if (cmd.charAt(0) == '|') @@ -1282,7 +1214,7 @@ public class Mobibot extends PircBot { final EntryLink entry = (EntryLink) _entries.get(index); entry.setTitle(cmd.substring(1)); - this.sendNotice(_channel, buildLink(index, entry)); + send(getChannel(), buildLink(index, entry)); saveEntries(false); } } @@ -1297,13 +1229,13 @@ public class Mobibot extends PircBot if (link.matches(LINK_MATCH)) { entry.setLink(link); - this.sendNotice(_channel, buildLink(index, entry)); + send(getChannel(), buildLink(index, entry)); saveEntries(false); } } else { - this.sendNotice(sender, "Please ask a channel op to change this link for you."); + send(sender, "Please ask a channel op to change this link for you."); } } else if (cmd.charAt(0) == '?') @@ -1314,13 +1246,13 @@ public class Mobibot extends PircBot { final EntryLink entry = (EntryLink) _entries.get(index); entry.setNick(cmd.substring(1)); - this.sendNotice(_channel, buildLink(index, entry)); + send(getChannel(), buildLink(index, entry)); saveEntries(false); } } else { - this.sendNotice(sender, "Please ask a channel op to change the author of this link for you."); + send(sender, "Please ask a channel op to change the author of this link for you."); } } else @@ -1329,7 +1261,7 @@ public class Mobibot extends PircBot final int cindex = entry.addComment(cmd, sender); final EntryComment comment = entry.getComment(cindex); - this.sendNotice(sender, buildComment(index, cindex, comment)); + send(sender, buildComment(index, cindex, comment)); saveEntries(false); } } @@ -1352,13 +1284,12 @@ public class Mobibot extends PircBot if (cmd.length() == 0) { final EntryComment comment = entry.getComment(cindex); - this.sendNotice(_channel, buildComment(index, cindex, comment)); + send(getChannel(), buildComment(index, cindex, comment)); } else if ("-".equals(cmd)) { entry.deleteComment(cindex); - this.sendNotice(_channel, "Comment " + LINK_CMD + (index + 1) + '.' + (cindex + 1) + - " removed."); + send(getChannel(), "Comment " + LINK_CMD + (index + 1) + '.' + (cindex + 1) + " removed."); saveEntries(false); } else if (cmd.charAt(0) == '?') @@ -1369,14 +1300,13 @@ public class Mobibot extends PircBot { final EntryComment comment = entry.getComment(cindex); comment.setNick(cmd.substring(1)); - this.sendNotice(_channel, buildComment(index, cindex, comment)); + send(getChannel(), buildComment(index, cindex, comment)); saveEntries(false); } } else { - this.sendNotice(sender, - "Please ask a channel op to change the author of this comment for you."); + send(sender, "Please ask a channel op to change the author of this comment for you."); } } else @@ -1384,7 +1314,7 @@ public class Mobibot extends PircBot entry.setComment(cindex, cmd, sender); final EntryComment comment = entry.getComment(cindex); - this.sendNotice(sender, buildComment(index, cindex, comment)); + send(sender, buildComment(index, cindex, comment)); saveEntries(false); } } @@ -1406,7 +1336,10 @@ public class Mobibot extends PircBot */ protected final void onPrivateMessage(String sender, String login, String hostname, String message) { - _logger.debug(">>> " + sender + ": " + message); + if (_logger.isDebugEnabled()) + { + _logger.debug(">>> " + sender + ": " + message); + } final String[] cmds = message.split(" ", 2); final String cmd = cmds[0].toLowerCase(); @@ -1421,7 +1354,7 @@ public class Mobibot extends PircBot { helpResponse(sender, args); } - else if (cmd.equals("kill")) + else if ("kill".equals(cmd)) { if (isOp(sender)) { @@ -1433,7 +1366,7 @@ public class Mobibot extends PircBot { if (isOp(sender)) { - this.sendNotice(_channel, sender + " has just signed my death sentence."); + send(getChannel(), sender + " has just signed my death sentence."); saveEntries(true); sleep(3); this.quitServer("The Bot Is Out There!"); @@ -1442,11 +1375,11 @@ public class Mobibot extends PircBot } else if (cmd.equals(CYCLE_CMD)) { - this.sendNotice(_channel, sender + " has just asked me to leave. I'll be back!"); + send(getChannel(), sender + " has just asked me to leave. I'll be back!"); sleep(0); - this.partChannel(_channel); + this.partChannel(getChannel()); sleep(5); - this.joinChannel(_channel); + this.joinChannel(getChannel()); } else if (cmd.equals(RECAP_CMD)) { @@ -1470,7 +1403,7 @@ public class Mobibot extends PircBot { if (cmds.length > 1) { - this.sendAction(_channel, args); + this.sendAction(getChannel(), args); } else { @@ -1491,7 +1424,7 @@ public class Mobibot extends PircBot { if (cmds.length > 1) { - this.sendMessage(_channel, args); + this.sendMessage(getChannel(), args); } else { @@ -1649,6 +1582,49 @@ public class Mobibot extends PircBot return buff.toString(); } + /** + * Copies a file. + * + * @param in The source file. + * @param out The destination file. + * + * @throws IOException If the file could not be copied. + */ + private void copyFile(File in, File out) + throws IOException + { + final FileChannel inChannel; + final FileChannel outChannel; + + inChannel = new FileInputStream(in).getChannel(); + outChannel = new FileOutputStream(out).getChannel(); + + try + { + inChannel.transferTo(0L, inChannel.size(), outChannel); + } + finally + { + try + { + inChannel.close(); + } + catch (IOException ignore) + { + ; // Do nothing + } + + try + { + outChannel.close(); + } + catch (IOException ignore) + { + ; // Do nothing + } + } + } + /** * Ensures that the given location (File/URL) has a trailing slash (/) to indicate a directory. * @@ -1732,7 +1708,7 @@ public class Mobibot extends PircBot */ private boolean isOp(String sender) { - final User[] users = this.getUsers(_channel); + final User[] users = this.getUsers(getChannel()); User user; @@ -1777,7 +1753,7 @@ public class Mobibot extends PircBot } else { - this.sendNotice(sender, "There is no weblog setup for this channel."); + send(sender, "There is no weblog setup for this channel."); } } @@ -1826,7 +1802,7 @@ public class Mobibot extends PircBot } else { - this.sendNotice(sender, "The Google search facility is disabled."); + send(sender, "The Google search facility is disabled."); } } @@ -1972,24 +1948,33 @@ public class Mobibot extends PircBot */ private synchronized void saveEntries(boolean isDayBackup) { + if (_logger.isDebugEnabled()) + { + _logger.debug("Saving..."); + } + if (isValidString(_logsDir) && isValidString(_weblogURL)) { FileWriter fw = null; try { - fw = new FileWriter(new File(_logsDir + "current.xml")); + fw = new FileWriter(new File(_logsDir + CURRENT_XML)); - Channel rss = new Channel(); - rss.setTitle(_channel + " IRC Links"); - rss.setDescription("Links from " + _ircServer + " on " + _channel); + SyndFeed rss = new SyndFeedImpl(); + rss.setFeedType("rss_2.0"); + rss.setTitle(getChannel() + " IRC Links"); + rss.setDescription("Links from " + _ircServer + " on " + getChannel()); rss.setLink(_weblogURL); - rss.setPubDate(Calendar.getInstance().getTime()); + rss.setPublishedDate(Calendar.getInstance().getTime()); + rss.setLanguage("en"); EntryLink entry; StringBuffer buff; EntryComment comment; - Item item; + final List items = new ArrayList(); + SyndEntry item; + SyndContent description; for (int i = (_entries.size() - 1); i >= 0; --i) { @@ -2014,26 +1999,36 @@ public class Mobibot extends PircBot } } - item = new Item(); + item = new SyndEntryImpl(); item.setLink(entry.getLink()); - item.setDescription(buff.toString()); + description = new SyndContentImpl(); + description.setValue(buff.toString()); + item.setDescription(description); item.setTitle(entry.getTitle()); - item.setPubDate(entry.getDate()); - item.setAuthor(_channel.substring(1) + '@' + _ircServer + " (" + entry.getNick() + ')'); + item.setPublishedDate(entry.getDate()); + item.setAuthor(getChannel().substring(1) + '@' + _ircServer + " (" + entry.getNick() + ')'); - rss.addItem(item); + items.add(item); } - fw.write(rss.getFeed("2.0")); + rss.setEntries(items); + + if (_logger.isDebugEnabled()) + { + _logger.debug("Writing the entries feed."); + } + + final SyndFeedOutput output = new SyndFeedOutput(); + output.output(rss, fw); + fw.close(); + + fw = new FileWriter(new File(_logsDir + getToday() + ".xml")); + output.output(rss, fw); if (isDayBackup) { if (isValidString(_backlogsURL)) { - fw.close(); - fw = new FileWriter(new File(_logsDir + getToday() + ".xml")); - fw.write(rss.getFeed("2.0")); - if (_history.indexOf(getToday()) == -1) { _history.add(getToday()); @@ -2045,22 +2040,39 @@ public class Mobibot extends PircBot } 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); + fw = new FileWriter(new File(_logsDir + NAV_XML)); + rss = new SyndFeedImpl(); + rss.setFeedType("rss_2.0"); + rss.setTitle(getChannel() + " IRC Links Backlogs"); + rss.setDescription("Backlogs of Links from " + _ircServer + " on " + getChannel()); rss.setLink(_backlogsURL); - rss.setPubDate(Calendar.getInstance().getTime()); + rss.setPublishedDate(Calendar.getInstance().getTime()); String date; + items.clear(); for (int i = (_history.size() - 1); i >= 0; --i) { date = (String) _history.get(i); - rss.addItem(_backlogsURL + date + ".xml", "Links for " + date, date); + + item = new SyndEntryImpl(); + item.setLink(_backlogsURL + date + ".xml"); + item.setTitle(date); + description = new SyndContentImpl(); + description.setValue("Links for " + date); + item.setDescription(description); + + items.add(item); } - fw.write(rss.getFeed("2.0")); + rss.setEntries(items); + + if (_logger.isDebugEnabled()) + { + _logger.debug("Writing the backlog feed."); + } + + output.output(rss, fw); } else { @@ -2088,45 +2100,6 @@ public class Mobibot extends PircBot { _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)); - - 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); - } - } - - try - { - copyFile(new File(_data), new File(_data + ".bak")); - } - catch (IOException e) - { - _logger.warn("Unable to backup the data file.", e); - } } /** @@ -2158,7 +2131,7 @@ public class Mobibot extends PircBot { try { - this.sendNotice(_channel, lookup(query)); + send(getChannel(), lookup(query)); } catch (UnknownHostException e) { @@ -2178,24 +2151,24 @@ public class Mobibot extends PircBot if ((line.length() > 0) && (line.charAt(0) != '#')) { - this.sendNotice(_channel, line); + send(getChannel(), line); } } } else { - this.sendNotice(_channel, "Unknown host."); + send(getChannel(), "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()); + send(getChannel(), "Unable to perform whois IP lookup: " + ioe.getMessage()); } } else { - this.sendNotice(_channel, "Unknown host."); + send(getChannel(), "Unknown host."); } } } @@ -2217,7 +2190,7 @@ public class Mobibot extends PircBot { if (spell.length() > 0) { - new Thread(new GoogleSearch(this, _googleKey, _channel, spell, true)).start(); + new Thread(new GoogleSearch(this, _googleKey, getChannel(), spell, true)).start(); } else { @@ -2226,7 +2199,7 @@ public class Mobibot extends PircBot } else { - this.sendNotice(_channel, "The Google spelling facility is disabled."); + send(getChannel(), "The Google spelling facility is disabled."); } } @@ -2289,11 +2262,11 @@ public class Mobibot extends PircBot { if (isInvalidTz) { - this.sendNotice(sender, response); + send(sender, response); } else { - this.sendNotice(_channel, response); + send(getChannel(), response); } } } @@ -2313,7 +2286,7 @@ public class Mobibot extends PircBot * * @return The nickname regexp pattern. */ - private final String getNickPattern() + private String getNickPattern() { final StringBuffer buff = new StringBuffer(0); final String nick = getNick(); @@ -2336,6 +2309,80 @@ public class Mobibot extends PircBot return buff.toString(); } + /** + * Loads the backlogs. + * + * @param file The file containing the backlogs. + * + * @throws FileNotFoundException If the file was not found. + * @throws FeedException If an error occurred while reading the feed. + */ + private void loadBacklogs(String file) + throws FileNotFoundException, FeedException + { + _history.clear(); + + SyndFeedInput input = new SyndFeedInput(); + SyndFeed feed = input.build(new InputStreamReader(new FileInputStream(new File(file)))); + + List items = feed.getEntries(); + SyndEntry item; + + for (int i = items.size() - 1; i >= 0; i--) + { + item = (SyndEntryImpl) items.get(i); + _history.add(item.getTitle()); + } + } + + /** + * Loads the current entries. + * + * @param file The file containing the current entries. + * + * @throws FileNotFoundException If the file was not found. + * @throws FeedException If an error occurred while reading the feed. + */ + private void loadEntries(String file) + throws FileNotFoundException, FeedException + { + _entries.clear(); + + SyndFeedInput input = new SyndFeedInput(); + SyndFeed feed = input.build(new InputStreamReader(new FileInputStream(new File(file)))); + + setToday(ISO_SDF.format(feed.getPublishedDate())); + + List items = feed.getEntries(); + SyndEntry item; + SyndContent description; + String[] comments; + String[] comment; + String author; + EntryLink entry; + + for (int i = items.size() - 1; i >= 0; i--) + { + item = (SyndEntryImpl) items.get(i); + author = item.getAuthor().substring(item.getAuthor().lastIndexOf('(') + 1, item.getAuthor().length() - 1); + entry = new EntryLink(item.getLink(), item.getTitle(), author, item.getPublishedDate()); + description = item.getDescription(); + comments = description.getValue().split("
"); + + for (int j = 0; j < comments.length; j++) + { + comment = comments[j].split(":"); + + if (comment.length == 2) + { + entry.addComment(comment[1].trim(), comment[0]); + } + } + + _entries.add(entry); + } + } + /** * Responds with the users on a channel. * @@ -2344,7 +2391,7 @@ public class Mobibot extends PircBot */ private void usersResponse(String sender, boolean isPrivate) { - final User[] users = this.getUsers(_channel); + final User[] users = this.getUsers(getChannel()); final String[] nicks = new String[users.length]; for (int i = 0; i < users.length; i++) diff --git a/src/net/thauvin/erik/mobibot/ReleaseInfo.java b/src/net/thauvin/erik/mobibot/ReleaseInfo.java new file mode 100644 index 0000000..9dfefb6 --- /dev/null +++ b/src/net/thauvin/erik/mobibot/ReleaseInfo.java @@ -0,0 +1,51 @@ +/* Created by JReleaseInfo AntTask from Open Source Competence Group */ +/* Creation date Thu Sep 23 13:38:29 PDT 2004 */ +package net.thauvin.erik.mobibot; + +import java.util.Date; + +/** + * This class provides information gathered from the build environment. + * + * @author JReleaseInfo AntTask + */ +public class ReleaseInfo { + + + /** buildDate (set during build process to 1095971909156L). */ + private static Date buildDate = new Date(1095971909156L); + + /** + * Get buildDate (set during build process to Thu Sep 23 13:38:29 PDT 2004). + * @return Date buildDate + */ + public static final Date getBuildDate() { return buildDate; } + + + /** + * Get buildNumber (set during build process to 1). + * @return int buildNumber + */ + public static final int getBuildNumber() { return 1; } + + + /** version (set during build process to "0.2"). */ + private static String version = new String("0.2"); + + /** + * Get version (set during build process to "0.2"). + * @return String version + */ + public static final String getVersion() { return version; } + + + /** project (set during build process to "mobibot"). */ + private static String project = new String("mobibot"); + + /** + * Get project (set during build process to "mobibot"). + * @return String project + */ + public static final String getProject() { return project; } + +} diff --git a/src/net/thauvin/erik/mobibot/StockQuote.java b/src/net/thauvin/erik/mobibot/StockQuote.java index 21f25ed..f71ff4b 100644 --- a/src/net/thauvin/erik/mobibot/StockQuote.java +++ b/src/net/thauvin/erik/mobibot/StockQuote.java @@ -90,7 +90,7 @@ public class StockQuote implements Runnable /** * Returns the specified stock quote. */ - public void run() + public final void run() { try { @@ -107,54 +107,54 @@ public class StockQuote implements Runnable { if ((quote.length > 3) && (!"\"N/A\"".equalsIgnoreCase(quote[3]))) { - _bot.sendNotice(_bot.getChannel(), + _bot.send(_bot.getChannel(), "Symbol: " + quote[0].replaceAll("\"", "") + " [" + quote[1].replaceAll("\"", "") + ']'); if (quote.length > 5) { - _bot.sendNotice(_bot.getChannel(), "Last Trade: " + quote[2] + " (" + quote[5] + ')'); + _bot.send(_bot.getChannel(), "Last Trade: " + quote[2] + " (" + quote[5] + ')'); } else { - _bot.sendNotice(_bot.getChannel(), "Last Trade: " + quote[2]); + _bot.send(_bot.getChannel(), "Last Trade: " + quote[2]); } if (quote.length > 4) { - _bot.sendNotice(_sender, + _bot.send(_sender, "Time: " + quote[3].replaceAll("\"", "") + ' ' + quote[4].replaceAll("\"", "")); } if (quote.length > 6) { - _bot.sendNotice(_sender, "Open: " + quote[6]); + _bot.send(_sender, "Open: " + quote[6]); } if (quote.length > 7) { - _bot.sendNotice(_sender, "Day's Range: " + quote[7] + " - " + quote[8]); + _bot.send(_sender, "Day's Range: " + quote[7] + " - " + quote[8]); } if (quote.length > 9) { - _bot.sendNotice(_sender, "Volume: " + quote[9]); + _bot.send(_sender, "Volume: " + quote[9]); } } else { - _bot.sendNotice(_sender, "Invalid ticker symbol."); + _bot.send(_sender, "Invalid ticker symbol."); } } else { - _bot.sendNotice(_sender, "No data returned."); + _bot.send(_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()); + _bot.send(_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 index 6ff9e1c..35d1807 100644 --- a/src/net/thauvin/erik/mobibot/Weather.java +++ b/src/net/thauvin/erik/mobibot/Weather.java @@ -98,7 +98,7 @@ public class Weather implements Runnable /** * Main processing method. */ - public void run() + public final void run() { if (_station.length() == 4) { diff --git a/website/index.html b/website/index.html index 140fe3a..95eb61f 100644 --- a/website/index.html +++ b/website/index.html @@ -17,12 +17,11 @@
  • Commons CLI
  • Commons HTTPClient
  • Commons Logging
  • -
  • Commons Net
  • -
  • fetchrss
  • +
  • Commons Net
  • Google Tag Library
  • JWeather
  • -
  • MathEvaluator
  • -
  • RSSLibJ
  • +
  • MathEvaluator
  • +
  • Rome
  • mobibot was written by Erik C. Thauvin as a replacement for the channel's original ChumpBot.

    Features