Moved most commands to modules.

This commit is contained in:
Erik C. Thauvin 2016-07-02 02:27:18 -07:00
parent b120e1da87
commit 015a368bd1
24 changed files with 1197 additions and 1436 deletions

View file

@ -1,12 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="mobibot" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.version="0.6.1-beta+008" type="JAVA_MODULE" version="4"> <module external.linked.project.id="mobibot" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.version="0.6.1-beta+008" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true"> <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/../../build/classes/main" />
<output-test url="file://$MODULE_DIR$/../../build/classes/test" />
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$/../.."> <content url="file://$MODULE_DIR$/../..">
<sourceFolder url="file://$MODULE_DIR$/../../src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/../../src/annotationProcessor/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/../../src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/../../src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/../../src/generated/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/../../.gradle" /> <excludeFolder url="file://$MODULE_DIR$/../../.gradle" />
<excludeFolder url="file://$MODULE_DIR$/../../build" /> <excludeFolder url="file://$MODULE_DIR$/../../build" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Gradle: commons-lang:commons-lang:2.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Gradle: commons-collections:commons-collections:3.2.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.apache.velocity:velocity:1.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Gradle: net.thauvin.erik:semver:0.9.5-beta" level="project" />
<orderEntry type="library" name="Gradle: org.slf4j:slf4j-api:1.7.16" level="project" />
<orderEntry type="library" name="Gradle: org.jdom:jdom2:2.0.6" level="project" />
<orderEntry type="library" name="Gradle: com.rometools:rome-utils:1.6.1" level="project" />
<orderEntry type="library" name="Gradle: net.sf.delicious-java:delicious:1.14" level="project" />
<orderEntry type="library" name="Gradle: org.twitter4j:twitter4j-core:4.0.4" level="project" />
<orderEntry type="library" name="Gradle: net.objecthunter:exp4j:0.4.7" level="project" />
<orderEntry type="library" name="Gradle: net.sourceforge.jweather:jweather:0.3.0" level="project" />
<orderEntry type="library" name="Gradle: org.ostermiller:utils:1.07.00" level="project" />
<orderEntry type="library" name="Gradle: org.json:json:20160212" level="project" />
<orderEntry type="library" name="Gradle: com.rometools:rome:1.6.1" level="project" />
<orderEntry type="library" name="Gradle: org.jsoup:jsoup:1.9.2" level="project" />
<orderEntry type="library" name="Gradle: oro:oro:2.0.8" level="project" />
<orderEntry type="library" name="Gradle: commons-httpclient:commons-httpclient:3.1" level="project" />
<orderEntry type="library" name="Gradle: commons-cli:commons-cli:1.3.1" level="project" />
<orderEntry type="library" name="Gradle: commons-net:commons-net:3.5" level="project" />
<orderEntry type="library" name="Gradle: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Gradle: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" name="Gradle: pircbot:pircbot:1.5.0" level="project" />
</component> </component>
</module> </module>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="mobibot:annotationProcessor" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="0.6.1-beta+008" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/../../build/classes/annotationProcessor" />
<exclude-output />
<content url="file://$MODULE_DIR$/../../src/annotationProcessor">
<sourceFolder url="file://$MODULE_DIR$/../../src/annotationProcessor/resources" type="java-resource" />
</content>
<content url="file://$MODULE_DIR$/../../src/generated">
<sourceFolder url="file://$MODULE_DIR$/../../src/generated/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="mobibot:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="0.6.1-beta+008" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/../../build/classes/main" />
<exclude-output />
<content url="file://$MODULE_DIR$/../../src/main">
<sourceFolder url="file://$MODULE_DIR$/../../src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../src/main/resources" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Gradle: pircbot:pircbot:1.5.0" level="project" />
<orderEntry type="library" name="Gradle: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" name="Gradle: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Gradle: commons-net:commons-net:3.5" level="project" />
<orderEntry type="library" name="Gradle: commons-cli:commons-cli:1.3.1" level="project" />
<orderEntry type="library" name="Gradle: commons-httpclient:commons-httpclient:3.1" level="project" />
<orderEntry type="library" name="Gradle: oro:oro:2.0.8" level="project" />
<orderEntry type="library" name="Gradle: org.jsoup:jsoup:1.9.2" level="project" />
<orderEntry type="library" name="Gradle: com.rometools:rome:1.6.1" level="project" />
<orderEntry type="library" name="Gradle: org.json:json:20160212" level="project" />
<orderEntry type="library" name="Gradle: org.ostermiller:utils:1.07.00" level="project" />
<orderEntry type="library" name="Gradle: net.sourceforge.jweather:jweather:0.3.0" level="project" />
<orderEntry type="library" name="Gradle: net.objecthunter:exp4j:0.4.7" level="project" />
<orderEntry type="library" name="Gradle: org.twitter4j:twitter4j-core:4.0.4" level="project" />
<orderEntry type="library" name="Gradle: net.sf.delicious-java:delicious:1.14" level="project" />
<orderEntry type="library" name="Gradle: com.rometools:rome-utils:1.6.1" level="project" />
<orderEntry type="library" name="Gradle: org.jdom:jdom2:2.0.6" level="project" />
<orderEntry type="library" name="Gradle: org.slf4j:slf4j-api:1.7.16" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Gradle: commons-lang:commons-lang:2.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Gradle: net.thauvin.erik:semver:0.9.5-beta" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.apache.velocity:velocity:1.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Gradle: commons-collections:commons-collections:3.2.1" level="project" />
</component>
</module>

View file

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="mobibot:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="0.6.1-beta+008" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output-test url="file://$MODULE_DIR$/../../build/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$/../../src/test">
<sourceFolder url="file://$MODULE_DIR$/../../src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/../../src/test/resources" type="java-test-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="mobibot_main" />
<orderEntry type="library" name="Gradle: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Gradle: pircbot:pircbot:1.5.0" level="project" />
<orderEntry type="library" name="Gradle: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" name="Gradle: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Gradle: commons-net:commons-net:3.5" level="project" />
<orderEntry type="library" name="Gradle: commons-cli:commons-cli:1.3.1" level="project" />
<orderEntry type="library" name="Gradle: commons-httpclient:commons-httpclient:3.1" level="project" />
<orderEntry type="library" name="Gradle: oro:oro:2.0.8" level="project" />
<orderEntry type="library" name="Gradle: org.jsoup:jsoup:1.9.2" level="project" />
<orderEntry type="library" name="Gradle: com.rometools:rome:1.6.1" level="project" />
<orderEntry type="library" name="Gradle: org.json:json:20160212" level="project" />
<orderEntry type="library" name="Gradle: org.ostermiller:utils:1.07.00" level="project" />
<orderEntry type="library" name="Gradle: net.sourceforge.jweather:jweather:0.3.0" level="project" />
<orderEntry type="library" name="Gradle: net.objecthunter:exp4j:0.4.7" level="project" />
<orderEntry type="library" name="Gradle: org.twitter4j:twitter4j-core:4.0.4" level="project" />
<orderEntry type="library" name="Gradle: net.sf.delicious-java:delicious:1.14" level="project" />
<orderEntry type="library" name="Gradle: com.rometools:rome-utils:1.6.1" level="project" />
<orderEntry type="library" name="Gradle: org.jdom:jdom2:2.0.6" level="project" />
<orderEntry type="library" name="Gradle: org.slf4j:slf4j-api:1.7.16" level="project" />
</component>
<component name="TestModuleProperties" production-module="mobibot_main" />
</module>

View file

@ -63,6 +63,7 @@ dependencies {
compile 'org.jsoup:jsoup:1.9.2' compile 'org.jsoup:jsoup:1.9.2'
compile 'com.rometools:rome:1.6.1' compile 'com.rometools:rome:1.6.1'
compile 'org.slf4j:slf4j-log4j12:1.7.21'
compile 'org.json:json:20160212' compile 'org.json:json:20160212'
compile 'org.ostermiller:utils:1.07.00' compile 'org.ostermiller:utils:1.07.00'

View file

@ -1,146 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="BSFConsole"> <component name="ClientPropertiesManager">
<sendcommandbycontrolenter>false</sendcommandbycontrolenter> <properties class="javax.swing.AbstractButton">
<restoresystemstreams>false</restoresystemstreams> <property name="hideActionText" class="java.lang.Boolean" />
<outwaitsforerr>false</outwaitsforerr> </properties>
<errwaitsforout>false</errwaitsforout> <properties class="javax.swing.JComponent">
<storedupsinrecentcommands>false</storedupsinrecentcommands> <property name="html.disable" class="java.lang.Boolean" />
<moduleforclasspath /> </properties>
<includeoutputpath>false</includeoutputpath> <properties class="javax.swing.JEditorPane">
<includetestsoutputpath>false</includetestsoutputpath> <property name="JEditorPane.w3cLengthUnits" class="java.lang.Boolean" />
<languages> <property name="JEditorPane.honorDisplayProperties" class="java.lang.Boolean" />
<language name="ant" engine="org.kos.bsfconsoleplugin.languages.AntConsoleBSFEngine" /> <property name="charset" class="java.lang.String" />
<language name="netrexx" engine="org.apache.bsf.engines.netrexx.NetRexxEngine" /> </properties>
<language name="xslt" engine="org.apache.bsf.engines.xslt.XSLTEngine" /> <properties class="javax.swing.JList">
<language name="beanbasic" engine="org.apache.bsf.engines.beanbasic.BeanBasicEngine" /> <property name="List.isFileList" class="java.lang.Boolean" />
<language name="beanshell" engine="bsh.util.BeanShellBSFEngine" /> </properties>
<language name="bml" engine="org.apache.bml.ext.BMLEngine" /> <properties class="javax.swing.JPasswordField">
<language name="groovy" engine="org.codehaus.groovy.bsf.GroovyEngine" /> <property name="JPasswordField.cutCopyAllowed" class="java.lang.Boolean" />
<language name="jacl" engine="org.apache.bsf.engines.jacl.JaclEngine" /> </properties>
<language name="java" engine="org.apache.bsf.engines.java.JavaEngine" /> <properties class="javax.swing.JSlider">
<language name="javaclass" engine="org.apache.bsf.engines.javaclass.JavaClassEngine" /> <property name="Slider.paintThumbArrowShape" class="java.lang.Boolean" />
<language name="javascript" engine="org.apache.bsf.engines.javascript.JavaScriptEngine" /> <property name="JSlider.isFilled" class="java.lang.Boolean" />
<language name="jpython" engine="org.apache.bsf.engines.jpython.JPythonEngine" /> </properties>
<language name="jscript" engine="org.apache.bsf.engines.activescript.ActiveScriptEngine" /> <properties class="javax.swing.JTable">
<language name="judoscript" engine="com.judoscript.BSFJudoEngine" /> <property name="Table.isFileList" class="java.lang.Boolean" />
<language name="jython" engine="org.apache.bsf.engines.jython.JythonEngine" /> <property name="JTable.autoStartsEdit" class="java.lang.Boolean" />
<language name="lotusscript" engine="org.apache.bsf.engines.lotusscript.LsEngine" /> <property name="terminateEditOnFocusLost" class="java.lang.Boolean" />
<language name="perl" engine="org.apache.bsf.engines.perl.PerlEngine" /> </properties>
<language name="perlscript" engine="org.apache.bsf.engines.activescript.ActiveScriptEngine" /> <properties class="javax.swing.JToolBar">
<language name="pnuts" engine="pnuts.ext.PnutsBSFEngine" /> <property name="JToolBar.isRollover" class="java.lang.Boolean" />
<language name="ruby" engine="org.jruby.javasupport.bsf.JRubyEngine" /> </properties>
<language name="vbscript" engine="org.apache.bsf.engines.activescript.ActiveScriptEngine" /> <properties class="javax.swing.JTree">
</languages> <property name="JTree.lineStyle" class="java.lang.String" />
<startupscripts /> </properties>
<preferredrecentcommandsdividerlocations> <properties class="javax.swing.text.JTextComponent">
<dividerlocationd language="beanshell" position="1028" /> <property name="caretAspectRatio" class="java.lang.Double" />
</preferredrecentcommandsdividerlocations> <property name="caretWidth" class="java.lang.Integer" />
<BSFConsoleSearchOptions searchfromcursor="false"> </properties>
<recentsearches />
</BSFConsoleSearchOptions>
</component>
<component name="BuildJarProjectSettings">
<option name="BUILD_JARS_ON_MAKE" value="false" />
</component>
<component name="CodeStyleProjectProfileManger">
<option name="PROJECT_PROFILE" />
<option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
</component> </component>
<component name="CompilerConfiguration"> <component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" /> <option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions> <resourceExtensions />
<entry name=".+\.(properties|xml|html|dtd|tld)" />
<entry name=".+\.(gif|png|jpeg|jpg)" />
</resourceExtensions>
<wildcardResourcePatterns> <wildcardResourcePatterns>
<entry name="?*.properties" /> <entry name="!?*.java" />
<entry name="?*.xml" /> <entry name="!?*.form" />
<entry name="?*.html" /> <entry name="!?*.class" />
<entry name="?*.dtd" /> <entry name="!?*.groovy" />
<entry name="?*.tld" /> <entry name="!?*.scala" />
<entry name="?*.gif" /> <entry name="!?*.flex" />
<entry name="?*.png" /> <entry name="!?*.kt" />
<entry name="?*.jpeg" /> <entry name="!?*.clj" />
<entry name="?*.jpg" /> <entry name="!?*.aj" />
</wildcardResourcePatterns> </wildcardResourcePatterns>
<annotationProcessing> <annotationProcessing>
<profile default="true" name="Default" enabled="false"> <profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" /> <processorPath useClasspath="true" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel>
<module name="mobibot_annotationProcessor" target="1.8" />
<module name="mobibot_main" target="1.8" />
<module name="mobibot_test" target="1.8" />
</bytecodeTargetLevel>
</component>
<component name="CopyrightManager" default="Mobibot">
<copyright>
<option name="notice" value="&amp;#36;file.fileName&#10;&#10;Copyright (c) 2004-&amp;#36;today.year, Erik C. Thauvin (erik@thauvin.net)&#10;All rights reserved.&#10;&#10;Redistribution and use in source and binary forms, with or without&#10;modification, are permitted provided that the following conditions are met:&#10;&#10; Redistributions of source code must retain the above copyright notice, this&#10; list of conditions and the following disclaimer.&#10;&#10; Redistributions in binary form must reproduce the above copyright notice,&#10; this list of conditions and the following disclaimer in the documentation&#10; and/or other materials provided with the distribution.&#10;&#10; Neither the name of this project nor the names of its contributors may be&#10; used to endorse or promote products derived from this software without&#10; specific prior written permission.&#10;&#10;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;&#10;AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE&#10;IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE&#10;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE&#10;FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL&#10;DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR&#10;SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER&#10;CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,&#10;OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE&#10;OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." />
<option name="keyword" value="Copyright" />
<option name="allowReplaceKeyword" value="Erik C. Thauvin" />
<option name="myName" value="Mobibot" />
<option name="myLocal" value="true" />
</copyright>
<module2copyright>
<element module="Source" copyright="Mobibot" />
</module2copyright>
<LanguageOptions name="__TEMPLATE__">
<option name="addBlankAfter" value="false" />
</LanguageOptions>
</component>
<component name="DependenciesAnalyzeManager">
<option name="myForwardDirection" value="false" />
</component> </component>
<component name="CopyrightManager" default="" />
<component name="DependencyValidationManager"> <component name="DependencyValidationManager">
<scope name="Source" pattern="file[mobibot_annotationProcessor]:java/net/thauvin/erik/mobibot/*||file[mobibot_main]:java/net/thauvin/erik/mobibot/*" /> <scope name="Source" pattern="file[mobibot]:src/generated/java//*||file[mobibot]:src/main/java//*" />
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</component> </component>
<component name="EclipseCompilerSettings"> <component name="Encoding">
<option name="GENERATE_NO_WARNINGS" value="true" />
<option name="DEPRECATION" value="false" />
</component>
<component name="EclipseEmbeddedCompilerSettings">
<option name="DEBUGGING_INFO" value="true" />
<option name="GENERATE_NO_WARNINGS" value="true" />
<option name="DEPRECATION" value="false" />
<option name="ADDITIONAL_OPTIONS_STRING" value="" />
<option name="MAXIMUM_HEAP_SIZE" value="128" />
</component>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
<file url="PROJECT" charset="UTF-8" /> <file url="PROJECT" charset="UTF-8" />
</component> </component>
<component name="EntryPointsManager"> <component name="EntryPointsManager">
<entry_points version="2.0" /> <entry_points version="2.0" />
</component> </component>
<component name="ExportToHTMLSettings"> <component name="GradleLocalSettings">
<option name="PRINT_LINE_NUMBERS" value="false" /> <option name="modificationStamps">
<option name="OPEN_IN_BROWSER" value="false" /> <map>
<option name="OUTPUT_DIRECTORY" /> <entry key="K:/GitHub/CompileOnlyPlugin" value="2933943731758" />
</component> <entry key="K:/ect/groovy/SshotCleaner" value="2892856534549" />
<component name="FrameworkDetectionExcludesConfiguration"> <entry key="K:/ect/java/Captcha" value="2894636758390" />
<file type="web" url="file://$PROJECT_DIR$" /> <entry key="K:/ect/java/FileSplitter" value="2846829504112" />
<entry key="K:/ect/java/GZIPFilter" value="2894567636586" />
<entry key="K:/ect/java/Lotto" value="2894619520256" />
<entry key="K:/ect/java/SshotCleaner" value="1446415498070" />
<entry key="K:/ect/java/TorrentCleaner" value="2894593616839" />
<entry key="K:/ect/java/click" value="2894595659515" />
<entry key="K:/ect/java/iFit2Workout" value="2894645931218" />
<entry key="$PROJECT_DIR$/../HttpStatus" value="2906561643260" />
<entry key="$PROJECT_DIR$/../SemanticVersion" value="2905451385982" />
<entry key="$PROJECT_DIR$" value="2865248599040" />
<entry key="$PROJECT_DIR$/../semver" value="2905990126118" />
</map>
</option>
<option name="externalProjectsViewState">
<projects_view />
</option>
</component> </component>
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="createEmptyContentRootDirectories" value="true" />
<option name="distributionType" value="LOCAL" /> <option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="C:/gradle" /> <option name="gradleHome" value="C:/gradle" />
<option name="gradleJvm" value="#JAVA_HOME" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />
</set> </set>
</option> </option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>
<component name="IdProvider" IDEtalkID="ADF4C98C99466E4EF52C8D21B83FF938" />
<component name="InspectionProjectProfileManager"> <component name="InspectionProjectProfileManager">
<profile version="1.0"> <profile version="1.0">
<option name="myName" value="Project Default" /> <option name="myName" value="Project Default" />
<option name="myLocal" value="true" />
<inspection_tool class="FieldMayBeFinal" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true"> <inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
<option name="TOP_LEVEL_CLASS_OPTIONS"> <option name="TOP_LEVEL_CLASS_OPTIONS">
<value> <value>
@ -172,239 +143,172 @@
<option name="IGNORE_POINT_TO_ITSELF" value="false" /> <option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="created" /> <option name="myAdditionalJavadocTags" value="created" />
</inspection_tool> </inspection_tool>
<inspection_tool class="LocalCanBeFinal" enabled="true" level="WARNING" enabled_by_default="true">
<option name="REPORT_VARIABLES" value="true" />
<option name="REPORT_PARAMETERS" value="false" />
<option name="REPORT_CATCH_PARAMETERS" value="false" />
</inspection_tool>
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false"> <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" /> <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" /> <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
</inspection_tool> </inspection_tool>
<inspection_tool class="UnnecessarySemicolon" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="UnnecessarySemicolon" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="WeakerAccess" enabled="true" level="WARNING" enabled_by_default="true">
<option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="true" />
<option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="false" />
<option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" />
</inspection_tool>
</profile> </profile>
<option name="PROJECT_PROFILE" /> <option name="PROJECT_PROFILE" />
<option name="USE_PROJECT_PROFILE" value="false" /> <option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" /> <version value="1.0" />
</component> </component>
<component name="JavadocGenerationManager"> <component name="MavenImportPreferences">
<option name="OUTPUT_DIRECTORY" /> <option name="generalSettings">
<option name="OPTION_SCOPE" value="protected" /> <MavenGeneralSettings>
<option name="OPTION_HIERARCHY" value="true" /> <option name="mavenHome" value="Bundled (Maven 3)" />
<option name="OPTION_NAVIGATOR" value="true" /> </MavenGeneralSettings>
<option name="OPTION_INDEX" value="true" />
<option name="OPTION_SEPARATE_INDEX" value="true" />
<option name="OPTION_DOCUMENT_TAG_USE" value="true" />
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="true" />
<option name="OPTION_DOCUMENT_TAG_VERSION" value="true" />
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
<option name="OPTION_DEPRECATED_LIST" value="true" />
<option name="OTHER_OPTIONS" />
<option name="HEAP_SIZE" />
<option name="LOCALE" />
<option name="OPEN_IN_BROWSER" value="true" />
</component>
<component name="LogConsolePreferences">
<option name="FILTER_ERRORS" value="false" />
<option name="FILTER_WARNINGS" value="false" />
<option name="FILTER_INFO" value="true" />
<option name="CUSTOM_FILTER" />
</component>
<component name="PDMPlugin">
<option name="skipTestSources" value="false" />
</component>
<component name="PEExternalization">
<option name="IGNORE_METHOD_NAMES" value="" />
<option name="IGNORE_METHOD_NAMES_ENABLED" value="false" />
<option name="IGNORE_CLASS_CONSTRUCTORS">
<value>
<option class="Exception" includeInheritors="true" />
</value>
</option> </option>
<option name="IGNORE_CLASS_CONSTRUCTOR_NAMES_ENABLED" value="true" />
<option name="IGNORE_CLASS_METHODS_ENABLED" value="true" />
<option name="IGNORE_STRINGS_CONTAINS_ONLY_ENABLED" value="true" />
<option name="IGNORE_STRINGS_CONTAINS_ONLY_WHITESPACES" value="true" />
<option name="IGNORE_STRINGS_CONTAINS_ONLY_PUNCTUATIONS" value="true" />
<option name="IGNORE_STRINGS_CONTAINS_ONLY_SPECIFIED_ENABLED" value="true" />
<option name="IGNORE_STRINGS_CONTAINS_ONLY_SPECIFIED" value="" />
<option name="IGNORE_CLASS_METHODS">
<value>
<option class="Exception" includeInheritors="false" />
<option class="java.util.ResourceBundle" includeInheritors="true" />
</value>
</option>
<option name="IGNORE_CONSTANTS_DECLARATIONS" value="true" />
</component> </component>
<component name="Palette2"> <component name="ProjectInspectionProfilesVisibleTreeState">
<group name="Swing"> <entry key="Project Default">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> <profile-state>
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> <expanded-state>
</item> <State>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> <id />
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> </State>
</item> <State>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false"> <id>Android Lint</id>
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> </State>
</item> <State>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true"> <id>Java</id>
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> </State>
</item> <State>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false"> <id>Portability issuesJava</id>
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> </State>
<initial-values> </expanded-state>
<property name="text" value="Button" /> </profile-state>
</initial-values> </entry>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component> </component>
<component name="ProjectCodeStyleSettingsManager"> <component name="ProjectLevelVcsManager" settingsEditedManually="false">
<option name="PER_PROJECT_SETTINGS"> <OptionsSetting value="true" id="Add" />
<value> <OptionsSetting value="true" id="Remove" />
<XML> <OptionsSetting value="true" id="Checkout" />
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> <OptionsSetting value="true" id="Update" />
</XML> <OptionsSetting value="true" id="Status" />
</value> <OptionsSetting value="true" id="Edit" />
</option> <ConfirmationsSetting value="0" id="Add" />
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Erik's Code Style" /> <ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectDetails">
<option name="projectName" value="mobibot" />
</component>
<component name="ProjectDictionaryState">
<dictionary name="erik">
<words>
<w>mobibot</w>
</words>
</dictionary>
</component> </component>
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/mobibot.iml" filepath="$PROJECT_DIR$/.idea/modules/mobibot.iml" /> <module fileurl="file://$PROJECT_DIR$/.idea/modules/mobibot.iml" filepath="$PROJECT_DIR$/.idea/modules/mobibot.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/mobibot_annotationProcessor.iml" filepath="$PROJECT_DIR$/.idea/modules/mobibot_annotationProcessor.iml" group="mobibot" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/mobibot_main.iml" filepath="$PROJECT_DIR$/.idea/modules/mobibot_main.iml" group="mobibot" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/mobibot_test.iml" filepath="$PROJECT_DIR$/.idea/modules/mobibot_test.iml" group="mobibot" />
</modules> </modules>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8.x" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8.x" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ResourceManagerContainer"> <component name="PropertiesComponent">
<option name="myResourceBundles"> <property name="GoToClass.includeLibraries" value="false" />
<value> <property name="GoToClass.toSaveIncludeLibraries" value="false" />
<list size="0" /> <property name="GoToFile.includeJavaFiles" value="false" />
</value> <property name="MemberChooser.sorted" value="false" />
</option> <property name="MemberChooser.showClasses" value="true" />
<property name="MemberChooser.copyJavadoc" value="false" />
<property name="settings.editor.selected.configurable" value="Errors" />
<property name="settings.editor.splitter.proportion" value="0.2" />
</component> </component>
<component name="SvnBranchConfigurationManager"> <component name="RunManager">
<option name="mySupportsUserInfoFilter" value="true" /> <configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin">
<module name="" />
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
<option name="PROGRAM_PARAMETERS" />
<method />
</configuration>
<configuration default="true" type="Applet" factoryName="Applet">
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<module />
<method />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
<method />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
<method />
</configuration>
</component> </component>
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" /> <mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
<component name="WebServicesPlugin" addRequiredLibraries="true" />
<component name="com.intellij.jsf.UserDefinedFacesConfigs">
<option name="USER_DEFINED_CONFIGS">
<value>
<list size="0" />
</value>
</option>
</component>
<component name="libraryTable"> <component name="libraryTable">
<library name="Gradle: com.rometools:rome-utils:1.6.1"> <library name="Gradle: com.rometools:rome-utils:1.6.1">
<CLASSES> <CLASSES>
@ -614,4 +518,20 @@
</SOURCES> </SOURCES>
</library> </library>
</component> </component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8.x</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project> </project>

View file

@ -13,11 +13,11 @@ import java.util.Date;
* Annotation Processor</a> * Annotation Processor</a>
*/ */
public final class ReleaseInfo { public final class ReleaseInfo {
private final static String buildmeta = "008"; private final static String buildmeta = "001";
private final static Date date = new Date(1467076393978L); private final static Date date = new Date(1467451308717L);
private final static int major = 0; private final static int major = 0;
private final static int minor = 6; private final static int minor = 6;
private final static int patch = 1; private final static int patch = 5;
private final static String prerelease = "beta"; private final static String prerelease = "beta";
private final static String project = "mobibot"; private final static String project = "mobibot";

View file

@ -45,21 +45,6 @@ final class Commands
*/ */
public static final String ADDLOG_CMD = "addlog"; public static final String ADDLOG_CMD = "addlog";
/**
* The math command.
*/
public static final String CALC_CMD = "calc";
/**
* The currency command.
*/
public static final String CURRENCY_CMD = "currency";
/**
* The rates keyword.
*/
public static final String CURRENCY_RATES_KEYWORD = "rates";
/** /**
* The cycle command. * The cycle command.
*/ */
@ -75,21 +60,11 @@ final class Commands
*/ */
public static final String DEBUG_CMD = "debug"; public static final String DEBUG_CMD = "debug";
/**
* The dices command.
*/
public static final String DICE_CMD = "dice";
/** /**
* The die command. * The die command.
*/ */
public static final String DIE_CMD = "die"; public static final String DIE_CMD = "die";
/**
* The Google command.
*/
public static final String GOOGLE_CMD = "google";
/** /**
* Help command line argument. * Help command line argument.
*/ */
@ -125,21 +100,11 @@ final class Commands
*/ */
public static final String INFO_CMD = "info"; public static final String INFO_CMD = "info";
/**
* The joke command.
*/
public static final String JOKE_CMD = "joke";
/** /**
* The link command. * The link command.
*/ */
public static final String LINK_CMD = "L"; public static final String LINK_CMD = "L";
/**
* The lookup command.
*/
public static final String LOOKUP_CMD = "lookup";
/** /**
* The me command. * The me command.
*/ */
@ -155,16 +120,6 @@ final class Commands
*/ */
public static final String NICK_CMD = "nick"; public static final String NICK_CMD = "nick";
/**
* The ping command.
*/
public static final String PING_CMD = "ping";
/**
* The pong command.
*/
public static final String PONG_CMD = "pong";
/** /**
* Properties command line argument. * Properties command line argument.
*/ */
@ -180,11 +135,6 @@ final class Commands
*/ */
public static final String SAY_CMD = "say"; public static final String SAY_CMD = "say";
/**
* The stock command.
*/
public static final String STOCK_CMD = "stock";
/** /**
* The {@link #TELL_CMD} all command. * The {@link #TELL_CMD} all command.
*/ */
@ -200,16 +150,6 @@ final class Commands
*/ */
public static final String TELL_DEL_CMD = "del"; public static final String TELL_DEL_CMD = "del";
/**
* The time command.
*/
public static final String TIME_CMD = "time";
/**
* The Twitter command.
*/
public static final String TWITTER_CMD = "twitter";
/** /**
* The users command. * The users command.
*/ */
@ -230,16 +170,6 @@ final class Commands
*/ */
public static final String VIEW_CMD = "view"; public static final String VIEW_CMD = "view";
/**
* The war command.
*/
public static final String WAR_CMD = "war";
/**
* The weather command.
*/
public static final String WEATHER_CMD = "weather";
/** /**
* Disables the default constructor. * Disables the default constructor.
* *

File diff suppressed because it is too large Load diff

View file

@ -34,10 +34,6 @@ package net.thauvin.erik.mobibot;
import org.jibble.pircbot.Colors; import org.jibble.pircbot.Colors;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
@ -48,7 +44,7 @@ import java.util.Calendar;
* @created 2014-04-26 * @created 2014-04-26
* @since 1.0 * @since 1.0
*/ */
final class Utils final public class Utils
{ {
/** /**
* The timestamp simple date format. * The timestamp simple date format.
@ -58,12 +54,12 @@ final class Utils
/** /**
* The ISO (YYYY-MM-DD) simple date format. * The ISO (YYYY-MM-DD) simple date format.
*/ */
static final SimpleDateFormat ISO_SDF = new SimpleDateFormat("yyyy-MM-dd"); public static final SimpleDateFormat ISO_SDF = new SimpleDateFormat("yyyy-MM-dd");
/** /**
* The UTC (yyyy-MM-dd HH:mm) simple date format. * The UTC (yyyy-MM-dd HH:mm) simple date format.
*/ */
static final SimpleDateFormat UTC_SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm"); public static final SimpleDateFormat UTC_SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm");
/** /**
* Disables the default constructor. * Disables the default constructor.
@ -191,71 +187,6 @@ final class Utils
return (Commands.LINK_CMD + (entryIndex + 1) + "T: " + entry.getDeliciousTags().replaceAll(",", ", ")); return (Commands.LINK_CMD + (entryIndex + 1) + "T: " + entry.getDeliciousTags().replaceAll(",", ", "));
} }
/**
* Copies a file.
*
* @param in The source file.
* @param out The destination file.
*
* @throws java.io.IOException If the file could not be copied.
*/
@SuppressWarnings("UnusedDeclaration")
public static void copyFile(final File in, final File out)
throws IOException
{
FileChannel inChannel = null;
FileChannel outChannel = null;
FileInputStream input = null;
FileOutputStream output = null;
try
{
input = new FileInputStream(in);
output = new FileOutputStream(out);
inChannel = input.getChannel();
outChannel = output.getChannel();
inChannel.transferTo(0L, inChannel.size(), outChannel);
}
finally
{
try
{
if (inChannel != null)
{
inChannel.close();
}
if (input != null)
{
input.close();
}
}
catch (Exception ignore)
{
; // Do nothing
}
try
{
if (outChannel != null)
{
outChannel.close();
}
if (output != null)
{
output.close();
}
}
catch (Exception ignore)
{
; // Do nothing
}
}
}
/** /**
* Ensures that the given location (File/URL) has a trailing slash (<code>/</code>) to indicate a directory. * Ensures that the given location (File/URL) has a trailing slash (<code>/</code>) to indicate a directory.
* *
@ -264,7 +195,7 @@ final class Utils
* *
* @return The location ending with a slash. * @return The location ending with a slash.
*/ */
public static String ensureDir(final String location, final boolean isUrl) static String ensureDir(final String location, final boolean isUrl)
{ {
if (isUrl) if (isUrl)
{ {

View file

@ -0,0 +1,138 @@
/*
* Module.java
*
* Copyright (c) 2004-2016, 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 this project 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 HOLDER 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.
*/
package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import net.thauvin.erik.mobibot.Utils;
import java.util.*;
/**
* The <code>Module</code> class.
*
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2016-07-01
* @since 1.0
*/
public abstract class AbstractModule
{
final List<String> commands = new ArrayList<>();
final Map<String, String> properties = new HashMap<>();
/**
* Responds to a command.
*
* @param bot The bot's instance.
* @param sender The sender.
* @param args The command arguments.
* @param isPrivate Set to <code>true</code> if the response should be sent as a private message.
*/
public abstract void commandResponse(final Mobibot bot, final String sender, final String args,
final boolean isPrivate);
/**
* Returns the module's commands, if any.
*
* @return The commands.
*/
public List<String> getCommands()
{
return commands;
}
/**
* Returns the module's property keys.
*
* @return The keys.
*/
public Set<String> getPropertyKeys()
{
return properties.keySet();
}
/**
* Returns <code>true</code> if the module has properties.
*
* @return <code>true</code> or <code>false</code> .
*/
public boolean hasProperties()
{
return !properties.isEmpty();
}
/**
* Responds with the module's help.
*
* @param bot The bot's instance.
* @param sender The sender.
* @param args The help arguments.
* @param isPrivate Set to <code>true</code> if the response should be sent as a private message.
*/
public abstract void helpResponse(final Mobibot bot, final String sender, final String args,
final boolean isPrivate);
/**
* Returns <code>true</code> if the module is enabled.
*
* @return <code>true</code> or <code>false</code>
*/
public boolean isEnabled()
{
return true;
}
/**
* Returns <codde>true</codde> if the module responds to private messages.
*
* @return <code>true</code> or <code>false</code>
*/
public boolean isPrivateMsgEnabled()
{
return false;
}
/**
* Sets a property key and value.
*
* @param key The key.
* @param value The value.
*/
public void setProperty(final String key, final String value)
{
if (Utils.isValidString(key))
{
properties.put(key, value);
}
}
}

View file

@ -0,0 +1,98 @@
/*
* Calc.java
*
* Copyright (c) 2004-2016, 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 this project 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 HOLDER 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.
*/
package net.thauvin.erik.mobibot.modules;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
import net.thauvin.erik.mobibot.Mobibot;
import net.thauvin.erik.mobibot.Utils;
import java.text.DecimalFormat;
/**
* The Calc module.
*
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2016-07-01
* @since 1.0
*/
public class Calc extends AbstractModule
{
/**
* The Calc command.
*/
private static final String CALC_CMD = "calc";
/**
* The default constructor.
*/
public Calc()
{
commands.add(CALC_CMD);
}
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
if (Utils.isValidString(args))
{
final DecimalFormat decimalFormat = new DecimalFormat("#.##");
try
{
final Expression calc = new ExpressionBuilder(args).build();
bot.send(bot.getChannel(), args.replaceAll(" ", "") + " = " + decimalFormat.format(calc.evaluate()));
}
catch (Exception e)
{
if (bot.getLogger().isDebugEnabled())
{
bot.getLogger().debug("Unable to calculate: " + args, e);
}
bot.send(bot.getChannel(), "No idea. This is the kind of math I don't get.");
}
}
else
{
helpResponse(bot, sender, args, isPrivate);
}
}
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
bot.send(sender, "To solve a mathematical calculation:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + CALC_CMD + " <calculation>"));
}
}

View file

@ -29,8 +29,10 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot; package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import net.thauvin.erik.mobibot.Utils;
import org.jdom2.Document; import org.jdom2.Document;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.JDOMException; import org.jdom2.JDOMException;
@ -46,14 +48,24 @@ import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
/** /**
* Processes the {@link Commands#CURRENCY_CMD} command. * The CurrentConverter module.
* *
* @author Erik C. Thauvin * @author Erik C. Thauvin
* @created Feb 11, 2004 * @created Feb 11, 2004
* @since 1.0 * @since 1.0
*/ */
class CurrencyConverter implements Runnable final public class CurrencyConverter extends AbstractModule
{ {
/**
* The currency command.
*/
private static final String CURRENCY_CMD = "currency";
/**
* The rates keyword.
*/
private static final String CURRENCY_RATES_KEYWORD = "rates";
/** /**
* The exchange rates. * The exchange rates.
*/ */
@ -64,40 +76,54 @@ class CurrencyConverter implements Runnable
*/ */
private 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 bot.
*/
private final Mobibot bot;
/** /**
* The last exchange rates table publication date. * The last exchange rates table publication date.
*/ */
private String pubDate = ""; private String pubDate = "";
/**
* The actual currency query.
*/
private String query;
/**
* The nick of the person who sent the message.
*/
private String sender;
/** /**
* Creates a new {@link CurrencyConverter} instance. * Creates a new {@link CurrencyConverter} instance.
*
* @param bot The bot's instance.
*/ */
public CurrencyConverter(final Mobibot bot) public CurrencyConverter()
{ {
this.bot = bot; commands.add(CURRENCY_CMD);
}
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
synchronized (this)
{
if (!pubDate.equals(Utils.today()))
{
EXCHANGE_RATES.clear();
}
}
new Thread(() -> {
run(bot, sender, args);
}).start();
}
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
bot.send(sender, "To convert from one currency to another:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + CURRENCY_CMD + " [100 USD to EUR]"));
if (args.endsWith(CURRENCY_CMD))
{
bot.send(sender, "For a listing of currency rates:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + CURRENCY_CMD) + ' ' + CURRENCY_RATES_KEYWORD);
bot.send(sender, "For a listing of supported currencies:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + CURRENCY_CMD));
}
} }
/** /**
* Converts the specified currencies. * Converts the specified currencies.
*/ */
public final void run() private void run(final Mobibot bot, final String sender, final String query)
{ {
if (Utils.isValidString(sender)) if (Utils.isValidString(sender))
{ {
@ -183,7 +209,7 @@ class CurrencyConverter implements Runnable
} }
} }
} }
else if (query.equals(Commands.CURRENCY_RATES_KEYWORD)) else if (query.equals(CURRENCY_RATES_KEYWORD))
{ {
bot.send(sender, "Last Update: " + pubDate); bot.send(sender, "Last Update: " + pubDate);
@ -204,27 +230,9 @@ class CurrencyConverter implements Runnable
} }
else else
{ {
bot.helpResponse(sender, Commands.CURRENCY_CMD + ' ' + query); helpResponse(bot, sender, CURRENCY_CMD + ' ' + query, true);
bot.send(sender, "The supported currencies are: " + EXCHANGE_RATES.keySet().toString()); bot.send(sender, "The supported currencies are: " + EXCHANGE_RATES.keySet().toString());
} }
} }
} }
}
/**
* Sets the query.
*
* @param sender The nick of the person who sent the message.
* @param query The currency query.
*/
public synchronized void setQuery(final String sender, final String query)
{
this.query = query;
this.sender = sender;
if (!pubDate.equals(Utils.today()))
{
EXCHANGE_RATES.clear();
}
}
}

View file

@ -29,37 +29,45 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot; package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import net.thauvin.erik.mobibot.Utils;
import java.util.Random; import java.util.Random;
/** /**
* Processes the {@link Commands#DICE_CMD} command. * The Dice module.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2014-04-28 * @created 2014-04-28
* @since 1.0 * @since 1.0
*/ */
final class Dice final public class Dice extends AbstractModule
{ {
/** /**
* Disables the default constructor. * The dice command.
*
* @throws UnsupportedOperationException If the constructor is called.
*/ */
private Dice() private final String DICE_CMD = "dice";
throws UnsupportedOperationException
/**
* The default constructor.
*/
public Dice()
{ {
throw new UnsupportedOperationException("Illegal constructor call."); commands.add(DICE_CMD);
} }
/** /**
* Rolls the dice. * Rolls the dice.
* *
* @param bot The bot's instance. * @param bot The bot's instance.
* @param sender The sender's nickname. * @param sender The sender.
* @param args The command arguments.
* @param isPrivate Set to <code>true</code> if the response should be sent as a private message.
*/ */
public static void roll(final Mobibot bot, final String sender) @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{ {
final Random r = new Random(); final Random r = new Random();
@ -91,4 +99,17 @@ final class Dice
bot.action("tied."); bot.action("tied.");
} }
} }
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
bot.send(sender, "To roll the dice:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + DICE_CMD));
}
@Override
public boolean isEnabled()
{
return true;
}
} }

View file

@ -29,8 +29,10 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot; package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import net.thauvin.erik.mobibot.Utils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -41,67 +43,78 @@ import java.net.URLConnection;
import java.net.URLEncoder; import java.net.URLEncoder;
/** /**
* Processes the {@link Commands#GOOGLE_CMD} command. * The GoogleSearch module.
* *
* @author Erik C. Thauvin * @author Erik C. Thauvin
* @created Feb 7, 2004 * @created Feb 7, 2004
* @since 1.0 * @since 1.0
*/ */
class GoogleSearch implements Runnable final public class GoogleSearch extends AbstractModule
{ {
/**
* The Google API Key property.
*/
private static final String GOOGLE_API_KEY_PROP = "google-api-key";
/**
* The google command.
*/
private static final String GOOGLE_CMD = "google";
/**
* The Google Custom Search Engine ID property.
*/
private static final String GOOGLE_CSE_KEY_PROP = "google-cse-cx";
/** /**
* The tab indent (4 spaces). * The tab indent (4 spaces).
*/ */
private static final String TAB_INDENT = " "; private static final String TAB_INDENT = " ";
/**
* The bot.
*/
private final Mobibot bot;
/**
* The Google Custom Search Engine ID.
*/
private final String cseCx;
/**
* The search query.
*/
private final String query;
/**
* The nick of the person who sent the message.
*/
private final String sender;
/** /**
* Creates a new {@link GoogleSearch} instance. * Creates a new {@link GoogleSearch} instance.
*
* @param bot The bot's instance.
* @param cseCx The Google Custom Search Engine ID.
* @param sender The nick of the person who sent the message.
* @param query The Google query
*/ */
public GoogleSearch(final Mobibot bot, final String cseCx, final String sender, final String query) public GoogleSearch()
{ {
this.bot = bot; commands.add(GOOGLE_CMD);
this.cseCx = cseCx; properties.put(GOOGLE_API_KEY_PROP, "");
this.sender = sender; properties.put(GOOGLE_CSE_KEY_PROP, "");
this.query = query; }
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
if (isEnabled() && args.length() > 0)
{
if (args.length() > 0)
{
new Thread(() -> {
run(bot, sender, args);
}).start();
}
else
{
helpResponse(bot, sender, args, isPrivate);
}
}
else
{
helpResponse(bot, sender, args, isPrivate);
}
} }
/** /**
* Searches Google. * Searches Google.
*/ */
public final void run() private void run(final Mobibot bot, final String sender, final String query)
{ {
try try
{ {
final String query = URLEncoder.encode(this.query, "UTF-8"); final String q = URLEncoder.encode(query, "UTF-8");
final URL url = final URL url =
new URL("https://www.googleapis.com/customsearch/v1?key=" + bot.getGoogleApiKey() + "&cx=" + cseCx new URL("https://www.googleapis.com/customsearch/v1?key=" + properties.get(GOOGLE_API_KEY_PROP)
+ "&q=" + query + "&filter=1&num=5&alt=json"); + "&cx=" + properties.get(GOOGLE_CSE_KEY_PROP) + "&q=" + q + "&filter=1&num=5&alt=json");
final URLConnection conn = url.openConnection(); final URLConnection conn = url.openConnection();
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
@ -131,4 +144,25 @@ class GoogleSearch implements Runnable
bot.send(sender, "An error has occurred: " + e.getMessage()); bot.send(sender, "An error has occurred: " + e.getMessage());
} }
} }
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
if (isEnabled())
{
bot.send(sender, "To search Google:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + GOOGLE_CMD + " <query>"));
}
else
{
bot.send(sender, "The Google searching facility is disabled.");
}
}
@Override
public boolean isEnabled()
{
return Utils.isValidString(properties.get(GOOGLE_API_KEY_PROP)) && Utils
.isValidString(properties.get(GOOGLE_CSE_KEY_PROP));
}
} }

View file

@ -29,8 +29,9 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot; package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import org.jibble.pircbot.Colors; import org.jibble.pircbot.Colors;
import org.json.JSONObject; import org.json.JSONObject;
@ -40,47 +41,53 @@ import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
/** /**
* Processes the {@link Commands#JOKE_CMD} command. * The Joke module.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2014-04-20 * @created 2014-04-20
* @since 1.0 * @since 1.0
*/ */
class Joke implements Runnable final public class Joke extends AbstractModule
{ {
/**
* The joke command.
*/
private static final String JOKE_CMD = "joke";
/** /**
* The ICNDB URL. * The ICNDB URL.
*/ */
private static final String JOKE_URL = private static final String JOKE_URL =
"http://api.icndb.com/jokes/random?escape=javascript&exclude=[explicit]&limitTo=[nerdy]"; "http://api.icndb.com/jokes/random?escape=javascript&exclude=[explicit]&limitTo=[nerdy]";
/**
* The bot's instance.
*/
private final Mobibot bot;
/**
* The nick of the person who sent the message.
*/
private final String sender;
/** /**
* Creates a new {@link Joke} instance. * Creates a new {@link Joke} instance.
*
* @param bot The bot's instance.
* @param sender The nick of the person who sent the message.
*/ */
public Joke(final Mobibot bot, final String sender) public Joke()
{ {
this.bot = bot; commands.add(JOKE_CMD);
this.sender = sender; }
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
new Thread(() -> {
run(bot, sender);
}).start();
}
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
bot.send(sender, "To retrieve a random joke:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + JOKE_CMD));
} }
/** /**
* Returns a random joke from <a href="http://www.icndb.com/">The Internet Chuck Norris Database</a> * Returns a random joke from <a href="http://www.icndb.com/">The Internet Chuck Norris Database</a>
*/ */
public final void run() private void run(final Mobibot bot, final String sender)
{ {
try try
{ {

View file

@ -29,8 +29,9 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot; package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import org.apache.commons.net.whois.WhoisClient; import org.apache.commons.net.whois.WhoisClient;
import java.io.IOException; import java.io.IOException;
@ -38,14 +39,18 @@ import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
/** /**
* Processes the {@link Commands#LOOKUP_CMD} command. * The Lookup module.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2014-04-26 * @created 2014-04-26
* @since 1.0 * @since 1.0
*/ */
final class Lookup final public class Lookup extends AbstractModule
{ {
/**
* THe lookup command.
*/
private static final String LOOKUP_CMD = "lookup";
/** /**
* The whois host. * The whois host.
@ -53,14 +58,78 @@ final class Lookup
private static final String WHOIS_HOST = "whois.arin.net"; private static final String WHOIS_HOST = "whois.arin.net";
/** /**
* Disables the default constructor. * The default constructor
*
* @throws UnsupportedOperationException If the constructor is called.
*/ */
private Lookup() public Lookup()
throws UnsupportedOperationException
{ {
throw new UnsupportedOperationException("Illegal constructor call."); commands.add(LOOKUP_CMD);
}
/**
* Process a command.
*
* @param bot The bot's instance.
* @param sender The sender.
* @param args The command arguments.
* @param isPrivate Set to <code>true</code> if the response should be sent as a private message.
*/
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
if (args.matches("(\\S.)+(\\S)+"))
{
try
{
bot.send(bot.getChannel(), Lookup.lookup(args));
}
catch (UnknownHostException ignore)
{
if (args.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 = Lookup.whois(args);
if ((lines != null) && (lines.length > 0))
{
String line;
for (final String rawLine : lines)
{
line = rawLine.trim();
if ((line.length() > 0) && (line.charAt(0) != '#'))
{
bot.send(bot.getChannel(), line);
}
}
}
else
{
bot.send(bot.getChannel(), "Unknown host.");
}
}
catch (IOException ioe)
{
if (bot.getLogger().isDebugEnabled())
{
bot.getLogger().debug("Unable to perform whois IP lookup: " + args, ioe);
}
bot.send(bot.getChannel(), "Unable to perform whois IP lookup: " + ioe.getMessage());
}
}
else
{
bot.send(bot.getChannel(), "Unknown host.");
}
}
}
else
{
helpResponse(bot, sender, args, true);
}
} }
/** /**
@ -72,7 +141,7 @@ final class Lookup
* *
* @throws java.net.UnknownHostException If the host is unknown. * @throws java.net.UnknownHostException If the host is unknown.
*/ */
public static String lookup(final String query) private static String lookup(final String query)
throws UnknownHostException throws UnknownHostException
{ {
final StringBuilder buffer = new StringBuilder(""); final StringBuilder buffer = new StringBuilder("");
@ -116,7 +185,7 @@ final class Lookup
* *
* @throws java.io.IOException If a connection error occurs. * @throws java.io.IOException If a connection error occurs.
*/ */
public static String[] whois(final String query) private static String[] whois(final String query)
throws IOException throws IOException
{ {
return whois(query, WHOIS_HOST); return whois(query, WHOIS_HOST);
@ -155,4 +224,11 @@ final class Lookup
return lines; return lines;
} }
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
bot.send(sender, "To perform a DNS lookup query:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + LOOKUP_CMD + " <ip address or hostname>"));
}
} }

View file

@ -0,0 +1,67 @@
/*
* Ping.java
*
* Copyright (c) 2016 Erik C. Thauvin (http://erik.thauvin.net/)
* All rights reserved.
*/
package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
* The <code>Ping</code> class.
*
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2016-07-02
* @since 1.0
*/
public class Ping extends AbstractModule
{
/**
* The ping responses.
*/
private static final List<String> PINGS = Arrays.asList("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 spontaneously 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!");
/**
* The ping command.
*/
private static final String PING_CMD = "ping";
/**
* The default constructor.
*/
public Ping()
{
commands.add(PING_CMD);
}
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
final Random r = new Random();
bot.action(PINGS.get(r.nextInt(PINGS.size())));
}
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
bot.send(sender, "To ping the bot:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + PING_CMD));
}
}

View file

@ -29,61 +29,68 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot; package net.thauvin.erik.mobibot.modules;
import com.Ostermiller.util.CSVParser; import com.Ostermiller.util.CSVParser;
import net.thauvin.erik.mobibot.Mobibot;
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.GetMethod;
import java.io.IOException; import java.io.IOException;
/** /**
* Processes the {@link Commands#STOCK_CMD} command. * The StockQuote module.
* *
* @author Erik C. Thauvin * @author Erik C. Thauvin
* @created Feb 7, 2004 * @created Feb 7, 2004
* @since 1.0 * @since 1.0
*/ */
class StockQuote implements Runnable final public class StockQuote extends AbstractModule
{ {
/**
* The quote command.
*/
private static final String STOCK_CMD = "stock";
/** /**
* The Yahoo! stock quote URL. * The Yahoo! stock quote URL.
*/ */
private static final String YAHOO_URL = "http://finance.yahoo.com/d/quotes.csv?&f=snl1d1t1c1oghv&e=.csv&s="; 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 {@link StockQuote} instance. * Creates a new {@link StockQuote} instance.
*
* @param bot The bot's instance.
* @param sender The nick of the person who sent the message.
* @param symbol The stock symbol.
*/ */
public StockQuote(final Mobibot bot, final String sender, final String symbol) public StockQuote()
{ {
this.bot = bot; commands.add(STOCK_CMD);
this.sender = sender; }
this.symbol = symbol;
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
if (args.length() > 0)
{
new Thread(() -> {
run(bot, sender, args);
}).start();
}
else
{
helpResponse(bot, sender, args, isPrivate);
}
}
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
bot.send(sender, "To retrieve a stock quote:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + STOCK_CMD + " <symbol[.country code]>"));
} }
/** /**
* Returns the specified stock quote from Yahoo! * Returns the specified stock quote from Yahoo!
*/ */
public final void run() private void run(final Mobibot bot, final String sender, final String symbol)
{ {
try try
{ {

View file

@ -29,89 +29,97 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot; package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import net.thauvin.erik.mobibot.Utils;
import twitter4j.Status; import twitter4j.Status;
import twitter4j.TwitterFactory; import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder; import twitter4j.conf.ConfigurationBuilder;
/** /**
* Processes the {@link Commands#TWITTER_CMD} command. * The Twitter module.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created Sept 10, 2008 * @created Sept 10, 2008
* @since 1.0 * @since 1.0
*/ */
class Twitter implements Runnable final public class Twitter extends AbstractModule
{ {
/** private final static String CONSUMER_KEY_PROP = "twitter-consumerKey";
* The Twitter access token.
*/ private final static String CONSUMER_SECRET_PROP = "twitter-consumerSecret";
private final String accessToken;
private final static String TOKEN_PROP = "twitter-token";
private final static String TOKEN_SECRET_PROP = "twitter-tokenSecret";
/** /**
* The Twitter access token secret. * The twitter command.
*/ */
private final String accessTokenSecret; private final static String TWITTER_CMD = "twitter";
/**
* The bot.
*/
private final Mobibot bot;
/**
* The Twitter consumer key.
*/
private final String consumerKey;
/**
* The Twitter consumer secret.
*/
private final String consumerSecret;
/**
* The Twitter message.
*/
private final String message;
/**
* The nick of the person who sent the message.
*/
private final String sender;
/** /**
* Creates a new {@link Twitter} instance. * Creates a new {@link Twitter} instance.
*
* @param bot The bot's instance.
* @param sender The nick of the person who sent the message.
* @param consumerKey The Twitter consumer key.
* @param consumerSecret The Twitter consumer secret.
* @param accessToken The Twitter access token.
* @param accessTokenSecret The Twitter access token secret.
* @param message The Twitter message.
*/ */
public Twitter(final Mobibot bot, final String sender, final String consumerKey, final String consumerSecret, public Twitter()
final String accessToken, final String accessTokenSecret, final String message)
{ {
this.bot = bot; commands.add(TWITTER_CMD);
this.consumerKey = consumerKey; properties.put(CONSUMER_SECRET_PROP, "");
this.consumerSecret = consumerSecret; properties.put(CONSUMER_KEY_PROP, "");
this.accessToken = accessToken; properties.put(TOKEN_PROP, "");
this.accessTokenSecret = accessTokenSecret; properties.put(TOKEN_SECRET_PROP, "");
this.message = message; }
this.sender = sender;
@Override
public boolean isEnabled()
{
return Utils.isValidString(properties.get(CONSUMER_KEY_PROP)) && Utils
.isValidString(properties.get(CONSUMER_SECRET_PROP)) && Utils.isValidString(properties.get(TOKEN_PROP))
&& Utils.isValidString(properties.get(TOKEN_SECRET_PROP));
}
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
if (isEnabled() && args.length() > 0)
{
new Thread(() -> {
run(bot, sender, args);
}).start();
}
else
{
helpResponse(bot, sender, args, isPrivate);
}
}
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
if (isEnabled())
{
bot.send(sender, "To post to Twitter:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + TWITTER_CMD + " <message>"));
}
else
{
bot.send(sender, "The Twitter posting facility is disabled.");
}
} }
/** /**
* Posts to twitter. * Posts to twitter.
*/ */
public final void run() private void run(final Mobibot bot, final String sender, final String message)
{ {
try try
{ {
final ConfigurationBuilder cb = new ConfigurationBuilder(); final ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret) cb.setDebugEnabled(true).setOAuthConsumerKey(properties.get(CONSUMER_KEY_PROP))
.setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessTokenSecret); .setOAuthConsumerSecret(properties.get(CONSUMER_SECRET_PROP))
.setOAuthAccessToken(properties.get(TOKEN_PROP))
.setOAuthAccessTokenSecret(properties.get(TOKEN_SECRET_PROP));
final TwitterFactory tf = new TwitterFactory(cb.build()); final TwitterFactory tf = new TwitterFactory(cb.build());
final twitter4j.Twitter twitter = tf.getInstance(); final twitter4j.Twitter twitter = tf.getInstance();

View file

@ -29,48 +29,56 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot; package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import net.thauvin.erik.mobibot.Utils;
import java.util.Random; import java.util.Random;
/** /**
* Processes the {@link Commands#WAR_CMD} command. * The War module.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2014-04-28 * @created 2014-04-28
* @since 1.0 * @since 1.0
*/ */
final class War final public class War extends AbstractModule
{ {
/** /**
* The deck of card for the {@link net.thauvin.erik.mobibot.Commands#WAR_CMD war} command. * The war command.
*/
private static final String WAR_CMD = "war";
/**
* The deck of card.
*/ */
private static final String[] WAR_DECK = private static final String[] WAR_DECK =
new String[]{"Ace", "King", "Queen", "Jack", "10", "9", "8", "7", "6", "5", "4", "3", "2"}; new String[]{"Ace", "King", "Queen", "Jack", "10", "9", "8", "7", "6", "5", "4", "3", "2"};
/** /**
* The suits for the deck of card for the {@link Commands#WAR_CMD war} command. * The suits for the deck of card.
*/ */
private static final String[] WAR_SUITS = new String[]{"Hearts", "Spades", "Diamonds", "Clubs"}; private static final String[] WAR_SUITS = new String[]{"Hearts", "Spades", "Diamonds", "Clubs"};
/** /**
* Disables the default constructor. * The default constructor.
*
* @throws UnsupportedOperationException If the constructor is called.
*/ */
private War() public War()
throws UnsupportedOperationException
{ {
throw new UnsupportedOperationException("Illegal constructor call."); commands.add(WAR_CMD);
} }
/** /**
* Plays war. * Plays war.
* *
* @param bot The bot's instance. * @param bot The bot's instance.
* @param sender The sender's nickname. * @param sender The sender.
* @param args The command arguments.
* @param isPrivate Set to <code>true</code> if the response should be sent as a private message.
*/ */
public static void play(final Mobibot bot, final String sender) @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{ {
final Random r = new Random(); final Random r = new Random();
@ -102,9 +110,12 @@ final class War
{ {
bot.action("wins."); bot.action("wins.");
} }
else }
{
bot.action("tied."); @Override
} public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
bot.send(sender, "To play war:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + WAR_CMD));
} }
} }

View file

@ -29,74 +29,75 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot; package net.thauvin.erik.mobibot.modules;
import net.sf.jweather.metar.Metar; import net.sf.jweather.metar.Metar;
import net.sf.jweather.metar.SkyCondition; import net.sf.jweather.metar.SkyCondition;
import net.sf.jweather.metar.WeatherCondition; import net.sf.jweather.metar.WeatherCondition;
import net.thauvin.erik.mobibot.Mobibot;
import net.thauvin.erik.mobibot.Utils;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Date; import java.util.Date;
/** /**
* Processes the {@link Commands#LOOKUP_CMD} command. * The Weather module
* *
* @author Erik C. Thauvin * @author Erik C. Thauvin
* @created Feb 7, 2004 * @created Feb 7, 2004
* @since 1.0 * @since 1.0
*/ */
class Weather implements Runnable final public class Weather extends AbstractModule
{ {
/**
* The URL where the stations are listed.
*/
public static final String STATIONS_URL = "http://www.rap.ucar.edu/weather/surface/stations.txt";
/** /**
* The decimal number format. * The decimal number format.
*/ */
private static final DecimalFormat NUMBER_FORMAT = new DecimalFormat("0.##"); private static final DecimalFormat NUMBER_FORMAT = new DecimalFormat("0.##");
/** /**
* The bot. * The URL where the stations are listed.
*/ */
private final Mobibot bot; private static final String STATIONS_URL = "http://www.rap.ucar.edu/weather/surface/stations.txt";
/** /**
* The private message flag. * THe weather command.
*/ */
private final boolean isPrivate; private static final String WEATHER_CMD = "weather";
/**
* The nick of the person who sent the message.
*/
private final String sender;
/**
* The station ID.
*/
private final String station;
/** /**
* Creates a new {@link Weather} instance. * Creates a new {@link Weather} instance.
*
* @param bot The bot's instance.
* @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(final Mobibot bot, final String sender, final String station, final boolean isPrivate) public Weather()
{ {
this.bot = bot; commands.add(WEATHER_CMD);
this.sender = sender; }
this.station = station.toUpperCase();
this.isPrivate = isPrivate; @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
new Thread(() -> {
run(bot, sender, args.toUpperCase(), isPrivate);
}).start();
}
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
bot.send(sender, "To display weather information:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + WEATHER_CMD + " <station id>"));
bot.send(sender, "For a listing of the ICAO station IDs, please visit: " + STATIONS_URL);
}
@Override
public boolean isPrivateMsgEnabled()
{
return true;
} }
/** /**
* Fetches the weather data from a specific station ID. * Fetches the weather data from a specific station ID.
*/ */
public final void run() private void run(final Mobibot bot, final String sender, final String station, final boolean isPrivate)
{ {
if (station.length() == 4) if (station.length() == 4)
{ {
@ -177,6 +178,6 @@ class Weather implements Runnable
} }
} }
bot.helpResponse(sender, Commands.WEATHER_CMD); helpResponse(bot, sender, station, isPrivate);
} }
} }

View file

@ -29,7 +29,10 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot; package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Mobibot;
import net.thauvin.erik.mobibot.Utils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
@ -38,13 +41,13 @@ import java.util.TimeZone;
import java.util.TreeMap; import java.util.TreeMap;
/** /**
* The {@link Commands#TIME_CMD} command. * The WorldTime module.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2014-04-27 * @created 2014-04-27
* @since 1.0 * @since 1.0
*/ */
class WorldTime final public class WorldTime extends AbstractModule
{ {
/** /**
* The beats (Internet Time) keyword. * The beats (Internet Time) keyword.
@ -52,12 +55,17 @@ class WorldTime
private static final String BEATS_KEYWORD = ".beats"; private static final String BEATS_KEYWORD = ".beats";
/** /**
* The countries supported by the {@link net.thauvin.erik.mobibot.Commands#TIME_CMD time} command. * The supported countries.
*/ */
private static final Map<String, String> COUNTRIES_MAP = new TreeMap<>(); private static final Map<String, String> COUNTRIES_MAP = new TreeMap<>();
/** /**
* The date/time format for the {@link net.thauvin.erik.mobibot.Commands#TIME_CMD time} command. * The time command.
*/
private static final String TIME_CMD = "time";
/**
* The date/time format.
*/ */
private static final SimpleDateFormat TIME_SDF = private static final SimpleDateFormat TIME_SDF =
new SimpleDateFormat("'The time is 'HH:mm' on 'EEEE, d MMMM yyyy' in '"); new SimpleDateFormat("'The time is 'HH:mm' on 'EEEE, d MMMM yyyy' in '");
@ -67,6 +75,8 @@ class WorldTime
*/ */
public WorldTime() public WorldTime()
{ {
commands.add(TIME_CMD);
// Initialize the countries map // Initialize the countries map
COUNTRIES_MAP.put("AU", "Australia/Sydney"); COUNTRIES_MAP.put("AU", "Australia/Sydney");
COUNTRIES_MAP.put("BE", "Europe/Brussels"); COUNTRIES_MAP.put("BE", "Europe/Brussels");
@ -140,12 +150,13 @@ class WorldTime
/** /**
* Responds with the current time in the specified timezone/country. * Responds with the current time in the specified timezone/country.
* *
* @param bot The bot instance. * @param bot The bot's instance.
* @param sender The nick of the person who sent the message. * @param sender The sender.
* @param args The time command arguments. * @param args The command arguments.
* @param isPrivate Set to true is the response should be send as a private message. * @param isPrivate Set to <code>true</code> if the response should be sent as a private message.
*/ */
public final void timeResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{ {
boolean isInvalidTz = false; boolean isInvalidTz = false;
final String tz = (COUNTRIES_MAP.get((args.substring(args.indexOf(' ') + 1).trim().toUpperCase()))); final String tz = (COUNTRIES_MAP.get((args.substring(args.indexOf(' ') + 1).trim().toUpperCase())));
@ -167,7 +178,7 @@ class WorldTime
else else
{ {
isInvalidTz = true; isInvalidTz = true;
response = "The supported time zones/countries are: " + COUNTRIES_MAP.keySet().toString(); response = "The supported time zones are: " + COUNTRIES_MAP.keySet().toString();
} }
if (isPrivate) if (isPrivate)
@ -186,4 +197,20 @@ class WorldTime
} }
} }
} }
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
{
bot.send(sender, "To display a country's current date/time:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + TIME_CMD) + " [<country code>]");
bot.send(sender, "For a listing of the supported countries:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + TIME_CMD));
}
@Override
public boolean isPrivateMsgEnabled()
{
return true;
}
} }

View file

@ -3,6 +3,6 @@
version.project=mobibot version.project=mobibot
version.major=0 version.major=0
version.minor=6 version.minor=6
version.patch=1 version.patch=5
version.prerelease=beta version.prerelease=beta
version.buildmeta=008 version.buildmeta=001