Browse Source

1. Several fixes

master
Rubenlagu 11 years ago
committed by Rubenlagus
parent
commit
5b669c50e0
  1. 240
      .idea/workspace.xml
  2. 3
      src/main/java/org/telegram/database/CreationStrings.java
  3. 43
      src/main/java/org/telegram/database/DatabaseManager.java
  4. 4
      src/main/java/org/telegram/services/BotLogger.java
  5. 10
      src/main/java/org/telegram/updatesreceivers/UpdatesThread.java

240
.idea/workspace.xml

@ -3,7 +3,10 @@
<component name="ChangeListManager">
<list default="true" id="cc3252dd-ba1f-404e-b603-ef880b5c3341" name="Default" comment="1. Several fixes">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/org/telegram/BotConfig.java" afterPath="$PROJECT_DIR$/src/main/java/org/telegram/BotConfig.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/org/telegram/services/BotLogger.java" afterPath="$PROJECT_DIR$/src/main/java/org/telegram/services/BotLogger.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/org/telegram/BuildVars.java" afterPath="$PROJECT_DIR$/src/main/java/org/telegram/BuildVars.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/org/telegram/database/CreationStrings.java" afterPath="$PROJECT_DIR$/src/main/java/org/telegram/database/CreationStrings.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/org/telegram/database/DatabaseManager.java" afterPath="$PROJECT_DIR$/src/main/java/org/telegram/database/DatabaseManager.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/org/telegram/Main.java" afterPath="$PROJECT_DIR$/src/main/java/org/telegram/Main.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/org/telegram/updatesreceivers/UpdatesThread.java" afterPath="$PROJECT_DIR$/src/main/java/org/telegram/updatesreceivers/UpdatesThread.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
@ -30,16 +33,28 @@
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="UpdatesThread.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/updatesreceivers/UpdatesThread.java">
<file leaf-file-name="DatabaseManager.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/database/DatabaseManager.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.19642857">
<caret line="70" column="54" selection-start-line="70" selection-start-column="54" selection-end-line="70" selection-end-column="54" />
<state vertical-scroll-proportion="0.0">
<caret line="339" column="31" selection-start-line="339" selection-start-column="31" selection-end-line="339" selection-end-column="31" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Main.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.5090498">
<caret line="15" column="34" selection-start-line="15" selection-start-column="34" selection-end-line="15" selection-end-column="34" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
@ -81,8 +96,6 @@
<option value="$PROJECT_DIR$/src/main/java/org/telegram/methods/SendMessage.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/games/FivesTools.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/Commands.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/database/CreationStrings.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/database/DatabaseManager.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/UpdatesThread.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/Server.java" />
<option value="$PROJECT_DIR$/pom.xml" />
@ -123,8 +136,10 @@
<option value="$PROJECT_DIR$/src/main/java/org/telegram/services/WeatherService.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/updatesreceivers/Webhook.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/SenderHelper.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/services/BotLogger.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/updatesreceivers/UpdatesThread.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/database/CreationStrings.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/database/DatabaseManager.java" />
<option value="$PROJECT_DIR$/src/main/java/org/telegram/services/BotLogger.java" />
</list>
</option>
</component>
@ -257,6 +272,8 @@
</navigator>
<panes>
<pane id="PackagesPane" />
<pane id="Scope" />
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<PATH>
@ -423,10 +440,38 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="BotAPi" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="BotAPi" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="main" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="java" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="telegram" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="database" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
@ -845,7 +890,8 @@
<workItem from="1435164520307" duration="6553000" />
<workItem from="1435251996845" duration="12896000" />
<workItem from="1435324180717" duration="607000" />
<workItem from="1435326170366" duration="34000" />
<workItem from="1435326170366" duration="240000" />
<workItem from="1435347109974" duration="1424000" />
</task>
<task id="LOCAL-00001" summary="First Commit:&#10;1. Transifex bot&#10;2. Weather bot">
<created>1434854005227</created>
@ -979,11 +1025,17 @@
<option name="project" value="LOCAL" />
<updated>1435324633695</updated>
</task>
<option name="localTasksCounter" value="23" />
<task id="LOCAL-00023" summary="1. Several fixes">
<created>1435326238547</created>
<option name="number" value="00023" />
<option name="project" value="LOCAL" />
<updated>1435326238547</updated>
</task>
<option name="localTasksCounter" value="24" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="104850000" />
<option name="totallyTimeSpent" value="106480000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
@ -1005,9 +1057,11 @@
<window_info id="Bean Validation" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32857144" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Java Enterprise" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.27793697" sideWeight="0.4939577" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39971346" sideWeight="0.5060423" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.19561933" sideWeight="0.1718377" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3295129" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
@ -1016,30 +1070,28 @@
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32930514" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.19561933" sideWeight="0.8281623" order="0" side_tool="false" content_ui="combo" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3295129" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3295129" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.27793697" sideWeight="0.4939577" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3295129" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
</layout>
<layout-to-restore>
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Statistic" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Java Enterprise" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="13" side_tool="false" content_ui="tabs" />
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.19561933" sideWeight="0.5" order="3" side_tool="false" content_ui="combo" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="7" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3295129" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="7" side_tool="false" content_ui="combo" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
@ -1051,8 +1103,8 @@
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3295129" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="12" side_tool="false" content_ui="tabs" />
</layout-to-restore>
</component>
@ -1086,9 +1138,9 @@
<MESSAGE value="1. Support for webhooks" />
<MESSAGE value="1. Fix JSON deserialization" />
<MESSAGE value="1. Fix webhooks, they only allow port 443" />
<MESSAGE value="1. Several fixes" />
<MESSAGE value="1. Fixed loggin levels" />
<option name="LAST_COMMIT_MESSAGE" value="1. Fixed loggin levels" />
<MESSAGE value="1. Several fixes" />
<option name="LAST_COMMIT_MESSAGE" value="1. Several fixes" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
@ -1119,13 +1171,13 @@
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/org/telegram/updatesreceivers/UpdatesThread.java</url>
<line>113</line>
<line>114</line>
<properties />
<option name="timeStamp" value="134" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/org/telegram/updatesreceivers/UpdatesThread.java</url>
<line>107</line>
<line>108</line>
<properties />
<option name="timeStamp" value="135" />
</line-breakpoint>
@ -1148,28 +1200,6 @@
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/methods/Constants.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="9" column="70" selection-start-line="9" selection-start-column="42" selection-end-line="9" selection-end-column="70" />
<folding />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/org/glassfish/grizzly/grizzly-framework/2.3.19/grizzly-framework-2.3.19-sources.jar!/org/glassfish/grizzly/nio/NIOTransport.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.33248082">
<caret line="603" column="28" selection-start-line="603" selection-start-column="28" selection-end-line="603" selection-end-column="28" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/org/glassfish/grizzly/grizzly-framework/2.3.19/grizzly-framework-2.3.19-sources.jar!/org/glassfish/grizzly/nio/DefaultSelectorHandler.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-3.3503835">
<caret line="88" column="11" selection-start-line="88" selection-start-column="11" selection-end-line="88" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/org/glassfish/grizzly/grizzly-http-server/2.3.19/grizzly-http-server-2.3.19-sources.jar!/org/glassfish/grizzly/http/server/NetworkListener.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.34526855">
@ -1296,18 +1326,10 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/database/ConectionDB.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.3318182">
<caret line="21" column="25" selection-start-line="21" selection-start-column="0" selection-end-line="22" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/CustomMessages.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="50" column="100" selection-start-line="50" selection-start-column="100" selection-end-line="50" selection-end-column="100" />
<folding />
</state>
</provider>
</entry>
@ -1369,13 +1391,6 @@
</state>
</provider>
</entry>
<entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/src.zip!/java/util/logging/Logger.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.33248082">
<caret line="1514" column="0" selection-start-line="1514" selection-start-column="0" selection-end-line="1514" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/BuildVars.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.16624041">
@ -1403,26 +1418,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.33482143">
<caret line="15" column="0" selection-start-line="15" selection-start-column="0" selection-end-line="15" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/2662015.log">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.79004663">
<caret line="1176" column="36" selection-start-line="1176" selection-start-column="36" selection-end-line="1176" selection-end-column="36" />
</state>
</provider>
<provider editor-type-id="com.intellij.database.editor.CsvTableFileEditorProvider">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/services/TransifexService.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.4047619">
@ -1452,7 +1447,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.20089285">
<caret line="9" column="91" selection-start-line="9" selection-start-column="47" selection-end-line="9" selection-end-column="91" />
<folding />
</state>
</provider>
</entry>
@ -1476,17 +1470,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.33437014">
<caret line="25" column="10" selection-start-line="25" selection-start-column="9" selection-end-line="25" selection-end-column="10" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/services/BotLogger.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.22686568">
<caret line="47" column="13" selection-start-line="47" selection-start-column="13" selection-end-line="47" selection-end-column="13" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -1512,7 +1495,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.2238806">
<caret line="14" column="7" selection-start-line="14" selection-start-column="7" selection-end-line="14" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
@ -1544,18 +1526,86 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.26865673">
<caret line="14" column="0" selection-start-line="14" selection-start-column="0" selection-end-line="14" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/database/DatabaseManager.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.8214286">
<caret line="320" column="4" selection-start-line="320" selection-start-column="4" selection-end-line="320" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/database/ConectionDB.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.15625">
<caret line="22" column="40" selection-start-line="22" selection-start-column="40" selection-end-line="22" selection-end-column="40" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/database/CreationStrings.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.27149323">
<caret line="11" column="42" selection-start-line="11" selection-start-column="31" selection-end-line="11" selection-end-column="51" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/updatesreceivers/UpdatesThread.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.19642857">
<caret line="70" column="54" selection-start-line="70" selection-start-column="54" selection-end-line="70" selection-end-column="54" />
<state vertical-scroll-proportion="0.7058824">
<caret line="54" column="83" selection-start-line="54" selection-start-column="83" selection-end-line="54" selection-end-column="83" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/2662015.log">
<provider editor-type-id="com.intellij.database.editor.CsvTableFileEditorProvider">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="56.517857">
<caret line="2" column="49" selection-start-line="2" selection-start-column="49" selection-end-line="2" selection-end-column="49" />
<folding />
</state>
</provider>
</entry>
<entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/src.zip!/java/util/logging/Logger.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.9434389">
<caret line="490" column="25" selection-start-line="490" selection-start-column="25" selection-end-line="490" selection-end-column="25" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/services/BotLogger.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.072289154">
<caret line="2" column="16" selection-start-line="2" selection-start-column="16" selection-end-line="2" selection-end-column="16" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/database/DatabaseManager.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="339" column="31" selection-start-line="339" selection-start-column="31" selection-end-line="339" selection-end-column="31" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/org/telegram/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.5090498">
<caret line="15" column="34" selection-start-line="15" selection-start-column="34" selection-end-line="15" selection-end-column="34" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>

3
src/main/java/org/telegram/database/CreationStrings.java

@ -9,7 +9,7 @@ package org.telegram.database;
public class CreationStrings {
public static final int version = 3;
public static final String createVersionTable = "CREATE TABLE IF NOT EXISTS Versions(ID INTEGER PRIMARY KEY AUTO_INCREMENT, Version INTEGER);";
public static final String insertCurrentVersion = "INSERT IGNORE INTO Versions (Version) VALUES(" + version + ");";
public static final String insertCurrentVersion = "INSERT IGNORE INTO Versions (Version) VALUES(%d);";
public static final String createFilesTable = "CREATE TABLE IF NOT EXISTS Files (fileId VARCHAR(100) PRIMARY KEY, userId INTEGER NOT NULL, caption TEXT NOT NULL)";
public static final String createUsersForFilesTable = "CREATE TABLE IF NOT EXISTS FilesUsers (userId INTEGER PRIMARY KEY, status INTEGER NOT NULL DEFAULT 0)";
public static final String createRecentWeatherTable = "CREATE TABLE IF NOT EXISTS RecentWeather (ID INTEGER PRIMARY KEY AUTO_INCREMENT, userId INTEGER NOT NULL, " +
@ -17,6 +17,7 @@ public class CreationStrings {
"CONSTRAINT unique_cistyuser UNIQUE (userId,cityId))";
public static final String createDirectionsDatabase = "CREATE TABLE IF NOT EXISTS Directions (userId INTEGER PRIMARY KEY, status INTEGER NOT NULL, " +
"messageId INTEGER NOT NULL DEFAULT 0, origin VARCHAR(100));";
public static final String createLastUpdateDatabase = "CREATE TABLE IF NOT EXISTS LastUpdate (token STRING PRIMARY KEY, updateId INTEGER NOT NULL DEFAULT -1);";
/*public static final String createOperatingSystemsVersion = "CREATE TABLE IF NOT EXISTS OperatingSystems (operatingSystem VARCHAR(20) PRIMARY KEY);";

43
src/main/java/org/telegram/database/DatabaseManager.java

@ -73,6 +73,9 @@ public class DatabaseManager {
if (currentVersion == 2) {
currentVersion = updateToVersion3();
}
if (currentVersion == 3) {
currentVersion = updateToVersion4();
}
connetion.commitTransaction();
} catch (SQLException e) {
log.error(e);
@ -81,20 +84,26 @@ public class DatabaseManager {
private int updateToVersion2() throws SQLException {
connetion.executeQuery(CreationStrings.createRecentWeatherTable);
connetion.executeQuery("INSERT IGNORE INTO Versions (Version) VALUES(2);");
connetion.executeQuery(String.format(CreationStrings.insertCurrentVersion, 2));
return 2;
}
private int updateToVersion3() throws SQLException {
connetion.executeQuery(CreationStrings.createDirectionsDatabase);
connetion.executeQuery("INSERT IGNORE INTO Versions (Version) VALUES(3);");
connetion.executeQuery(String.format(CreationStrings.insertCurrentVersion, 3));
return 2;
}
private int updateToVersion4() throws SQLException {
connetion.executeQuery(CreationStrings.createLastUpdateDatabase);
connetion.executeQuery(String.format(CreationStrings.insertCurrentVersion, 4));
return 4;
}
private int createNewTables() throws SQLException {
connetion.executeQuery(CreationStrings.createVersionTable);
connetion.executeQuery(CreationStrings.createFilesTable);
connetion.executeQuery(CreationStrings.insertCurrentVersion);
connetion.executeQuery(String.format(CreationStrings.insertCurrentVersion, CreationStrings.version));
connetion.executeQuery(CreationStrings.createUsersForFilesTable);
connetion.executeQuery(CreationStrings.createRecentWeatherTable);
connetion.executeQuery(CreationStrings.createDirectionsDatabase);
@ -317,4 +326,32 @@ public class DatabaseManager {
}
return updatedRows > 0;
}
public boolean putLastUpdate(String token, Integer updateId) {
int updatedRows = 0;
try {
final PreparedStatement preparedStatement = connetion.getPreparedStatement("REPLACE INTO LastUpdate (token, updateId) VALUES(?, ?)");
preparedStatement.setString(1, token);
preparedStatement.setInt(2, updateId);
updatedRows = preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
return updatedRows > 0;
}
public Integer getLastUpdate(String token) {
Integer updateId = -1;
try {
final PreparedStatement preparedStatement = connetion.getPreparedStatement("SELECT updateId FROM LastUpdate WHERE token = ?");
preparedStatement.setString(1, token);
final ResultSet result = preparedStatement.executeQuery();
if (result.next()) {
updateId = result.getInt("updateId");
}
} catch (SQLException e) {
e.printStackTrace();
}
return updateId;
}
}

4
src/main/java/org/telegram/services/BotLogger.java

@ -65,8 +65,6 @@ public class BotLogger {
file.createNewFile();
}
logginFile = new PrintWriter(new BufferedWriter(new FileWriter(currentFileName, true)));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
@ -330,7 +328,7 @@ public class BotLogger {
}
private void logMsgToFile(Level level, String msg, String dateForLog) {
dateForLog += level.toString() + " - " + msg;
dateForLog += " [" + logger.getName() + "]" + level.toString() + " - " + msg;
logsToFile.add(dateForLog);
synchronized (logsToFile) {
logsToFile.notifyAll();

10
src/main/java/org/telegram/updatesreceivers/UpdatesThread.java

@ -1,5 +1,6 @@
package org.telegram.updatesreceivers;
import com.sun.corba.se.impl.oa.toa.TOA;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
@ -17,6 +18,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.telegram.BuildVars;
import org.telegram.api.Update;
import org.telegram.database.DatabaseManager;
import org.telegram.methods.Constants;
import org.telegram.methods.GetUpdates;
import org.telegram.methods.SendMessage;
@ -50,7 +52,7 @@ public class UpdatesThread {
public UpdatesThread(String token, UpdatesCallback callback) {
this.token = token;
this.callback = callback;
this.lastReceivedUpdate = -1;
this.lastReceivedUpdate = DatabaseManager.getInstance().getLastUpdate(this.token);
this.readerThread = new ReaderThread();
this.readerThread.start();
this.handlerThread = new HandlerThread();
@ -132,6 +134,7 @@ public class UpdatesThread {
public void run() {
setPriority(Thread.MIN_PRIORITY);
while(true) {
try {
Update update = receivedUpdates.poll();
if (update == null) {
synchronized (receivedUpdates) {
@ -147,8 +150,11 @@ public class UpdatesThread {
}
}
}
DatabaseManager.getInstance().putLastUpdate(token, update.getUpdateId());
callback.onUpdateReceived(update);
} catch (Exception e) {
log.error(e);
}
}
}
}

Loading…
Cancel
Save