Compare commits

..

1 Commits

Author SHA1 Message Date
eaa670a135 Added foo dev for Mastodon API. 2018-05-22 08:54:44 +02:00
144 changed files with 2867 additions and 7714 deletions

View File

@ -12,18 +12,16 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/Logs/log4j-1.2.17.jar"/> <classpathentry kind="lib" path="lib/Logs/log4j-1.2.17.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.5.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-log4j12-1.7.5.jar"/>
<classpathentry kind="lib" path="lib/UnitTesting/hamcrest-core-1.3.jar"/> <classpathentry kind="lib" path="lib/UnitTesting/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="lib/UnitTesting/junit-4.11.jar"/>
<classpathentry kind="lib" path="lib/commons-cli-1.4.jar"/> <classpathentry kind="lib" path="lib/commons-cli-1.4.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.4.jar"/> <classpathentry kind="lib" path="lib/commons-codec-1.4.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/> <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.5.jar" sourcepath="lib/commons-io-2.5-src.jar"/> <classpathentry kind="lib" path="lib/commons-io-2.5.jar" sourcepath="lib/commons-io-2.5-src.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.4.jar" sourcepath="lib/commons-lang3-3.4-src.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/> <classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/httpclient-4.5.jar"/> <classpathentry kind="lib" path="lib/httpclient-4.5.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.4.1.jar"/> <classpathentry kind="lib" path="lib/httpcore-4.4.1.jar"/>
@ -31,15 +29,16 @@
<classpathentry kind="lib" path="lib/pircbot-1.5.0.jar" sourcepath="lib/pircbot-1.5.0-sources.zip"/> <classpathentry kind="lib" path="lib/pircbot-1.5.0.jar" sourcepath="lib/pircbot-1.5.0-sources.zip"/>
<classpathentry kind="lib" path="lib/scribe-1.3.7.jar"/> <classpathentry kind="lib" path="lib/scribe-1.3.7.jar"/>
<classpathentry kind="lib" path="lib/quartz-2.2.3.jar" sourcepath="lib/quartz-2.2.3-source.zip"/> <classpathentry kind="lib" path="lib/quartz-2.2.3.jar" sourcepath="lib/quartz-2.2.3-source.zip"/>
<classpathentry kind="lib" path="lib/devinsy-strings-0.4.4.jar" sourcepath="lib/devinsy-strings-0.4.4-sources.zip"/>
<classpathentry kind="lib" path="lib/twitter4j-async-4.0.4.jar" sourcepath="lib/twitter4j-async-4.0.4-src.zip"/> <classpathentry kind="lib" path="lib/twitter4j-async-4.0.4.jar" sourcepath="lib/twitter4j-async-4.0.4-src.zip"/>
<classpathentry kind="lib" path="lib/twitter4j-core-4.0.4.jar" sourcepath="lib/twitter4j-core-4.0.4-src.zip"/> <classpathentry kind="lib" path="lib/twitter4j-core-4.0.4.jar" sourcepath="lib/twitter4j-core-4.0.4-src.zip"/>
<classpathentry kind="lib" path="lib/twitter4j-media-support-4.0.4.jar" sourcepath="lib/twitter4j-media-support-4.0.4-src.zip"/> <classpathentry kind="lib" path="lib/twitter4j-media-support-4.0.4.jar" sourcepath="lib/twitter4j-media-support-4.0.4-src.zip"/>
<classpathentry kind="lib" path="lib/twitter4j-stream-4.0.4.jar" sourcepath="lib/twitter4j-stream-4.0.4-src.zip"/> <classpathentry kind="lib" path="lib/twitter4j-stream-4.0.4.jar" sourcepath="lib/twitter4j-stream-4.0.4-src.zip"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.25.jar" sourcepath="lib/Logs/slf4j-api-1.7.25-sources.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<classpathentry kind="lib" path="lib/Logs/slf4j-log4j12-1.7.25.jar" sourcepath="lib/Logs/slf4j-log4j12-1.7.25-sources.jar"/> <attributes>
<classpathentry kind="lib" path="lib/UnitTesting/junit-4.12.jar" sourcepath="lib/UnitTesting/junit-4.12-sources.jar"/> <attribute name="maven.pomderived" value="true"/>
<classpathentry kind="lib" path="lib/devinsy-strings-0.8.2.jar" sourcepath="lib/devinsy-strings-0.8.2-sources.zip"/> </attributes>
<classpathentry kind="lib" path="lib/commons-lang3-3.8.jar" sourcepath="lib/commons-lang3-3.8-sources.jar"/> </classpathentry>
<classpathentry kind="lib" path="lib/json-simple-1.1.1.jar" sourcepath="lib/json-simple-1.1.1-source.zip"/> <classpathentry kind="lib" path="lib/mastodon4j.jar"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

1
.gitignore vendored
View File

@ -4,4 +4,3 @@
/bin/ /bin/
/dist/ /dist/
/build/ /build/
*~

View File

@ -17,9 +17,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@ -33,7 +33,6 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
@ -77,7 +76,6 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
@ -110,10 +108,8 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=enabled org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.source=11
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
@ -121,20 +117,17 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0 org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=49 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=49
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
@ -220,12 +213,11 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
@ -256,8 +248,6 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
@ -282,17 +272,13 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
@ -340,8 +326,6 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
@ -378,12 +362,9 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
@ -409,11 +390,7 @@ org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_on_off_tags=false org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter

View File

@ -13,38 +13,28 @@ cleanup.always_use_this_for_non_static_field_access=true
cleanup.always_use_this_for_non_static_method_access=false cleanup.always_use_this_for_non_static_method_access=false
cleanup.convert_functional_interfaces=false cleanup.convert_functional_interfaces=false
cleanup.convert_to_enhanced_for_loop=false cleanup.convert_to_enhanced_for_loop=false
cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
cleanup.correct_indentation=false cleanup.correct_indentation=false
cleanup.format_source_code=true cleanup.format_source_code=true
cleanup.format_source_code_changes_only=false cleanup.format_source_code_changes_only=false
cleanup.insert_inferred_type_arguments=false cleanup.insert_inferred_type_arguments=false
cleanup.lazy_logical_operator=false
cleanup.make_local_variable_final=false cleanup.make_local_variable_final=false
cleanup.make_parameters_final=true cleanup.make_parameters_final=true
cleanup.make_private_fields_final=false cleanup.make_private_fields_final=false
cleanup.make_type_abstract_if_missing_method=false cleanup.make_type_abstract_if_missing_method=false
cleanup.make_variable_declarations_final=true cleanup.make_variable_declarations_final=true
cleanup.merge_conditional_blocks=false
cleanup.never_use_blocks=false cleanup.never_use_blocks=false
cleanup.never_use_parentheses_in_expressions=true cleanup.never_use_parentheses_in_expressions=true
cleanup.number_suffix=false
cleanup.objects_equals=false
cleanup.organize_imports=false cleanup.organize_imports=false
cleanup.precompile_regex=false
cleanup.push_down_negation=false
cleanup.qualify_static_field_accesses_with_declaring_class=false cleanup.qualify_static_field_accesses_with_declaring_class=false
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
cleanup.qualify_static_member_accesses_with_declaring_class=true cleanup.qualify_static_member_accesses_with_declaring_class=true
cleanup.qualify_static_method_accesses_with_declaring_class=false cleanup.qualify_static_method_accesses_with_declaring_class=false
cleanup.remove_private_constructors=true cleanup.remove_private_constructors=true
cleanup.remove_redundant_modifiers=false cleanup.remove_redundant_type_arguments=true
cleanup.remove_redundant_semicolons=false
cleanup.remove_redundant_type_arguments=false
cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces=true
cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_all=true
cleanup.remove_trailing_whitespaces_ignore_empty=false cleanup.remove_trailing_whitespaces_ignore_empty=false
cleanup.remove_unnecessary_array_creation=false
cleanup.remove_unnecessary_casts=true cleanup.remove_unnecessary_casts=true
cleanup.remove_unnecessary_nls_tags=true cleanup.remove_unnecessary_nls_tags=true
cleanup.remove_unused_imports=true cleanup.remove_unused_imports=true
@ -53,14 +43,11 @@ cleanup.remove_unused_private_fields=true
cleanup.remove_unused_private_members=false cleanup.remove_unused_private_members=false
cleanup.remove_unused_private_methods=true cleanup.remove_unused_private_methods=true
cleanup.remove_unused_private_types=true cleanup.remove_unused_private_types=true
cleanup.simplify_lambda_expression_and_method_ref=false
cleanup.sort_members=true cleanup.sort_members=true
cleanup.sort_members_all=false cleanup.sort_members_all=false
cleanup.use_anonymous_class_creation=false cleanup.use_anonymous_class_creation=false
cleanup.use_autoboxing=false
cleanup.use_blocks=true cleanup.use_blocks=true
cleanup.use_blocks_only_for_return_and_throw=false cleanup.use_blocks_only_for_return_and_throw=false
cleanup.use_directly_map_method=false
cleanup.use_lambda=true cleanup.use_lambda=true
cleanup.use_parentheses_in_expressions=false cleanup.use_parentheses_in_expressions=false
cleanup.use_this_for_non_static_field_access=true cleanup.use_this_for_non_static_field_access=true
@ -68,8 +55,6 @@ cleanup.use_this_for_non_static_field_access_only_if_necessary=false
cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access=false
cleanup.use_this_for_non_static_method_access_only_if_necessary=true cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup.use_type_arguments=false cleanup.use_type_arguments=false
cleanup.use_unboxing=false
cleanup.use_var=false
cleanup_profile=_Hebdobot cleanup_profile=_Hebdobot
cleanup_settings_version=2 cleanup_settings_version=2
eclipse.preferences.version=1 eclipse.preferences.version=1
@ -77,7 +62,6 @@ editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_Hebdobot formatter_profile=_Hebdobot
formatter_settings_version=12 formatter_settings_version=12
jautodoc.cleanup.add_header=false jautodoc.cleanup.add_header=false
jautodoc.cleanup.javadoc=false
jautodoc.cleanup.replace_header=false jautodoc.cleanup.replace_header=false
org.eclipse.jdt.ui.exception.name=exception org.eclipse.jdt.ui.exception.name=exception
org.eclipse.jdt.ui.gettersetter.use.is=true org.eclipse.jdt.ui.gettersetter.use.is=true

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<faceted-project> <faceted-project>
<installed facet="java" version="11"/> <runtime name="jdk1.8.0_92"/>
<installed facet="java" version="1.8"/>
</faceted-project> </faceted-project>

View File

@ -1,6 +1,6 @@
* Changed license from GNU GPL v3 to GNU AGPL v3+. * Changed license from GNU GPL v3 to GNU AGPL v3.
Le 08/01/2018 à 01:07, aeris a écrit : Le 08/01/2018 à 01:07, aeris a écrit :
> From: aeris <aeris@imirhil.fr> > From: aeris <aeris@imirhil.fr>
@ -32,5 +32,5 @@ Le 08/01/2018 à 01:07, aeris a écrit :
* change Java version to 1.8 * change Java version to 1.8
* anonymized Twitter API key * anonymized Twitter API key
* replaced Maven with Ant * eplaced Maven with Ant
* no more code injection * no more code injection

View File

@ -1,62 +0,0 @@
# Hebdobot
Hebdobot est le bot de gestion de la revue hebdomadaire de l'April.
Présentation de la revue hebdomadaire : https://www.april.org/revues-hebdomadaires-april
La revue hebdo dispose d'un bot IRC qui gère les logs et la synthèse de la revue hebdo : Hebdobot.
Hebdobot est un logiciel libre sous licence GNU AGPLv3+ édité par l'April dont le projet est géré ici : https://agir.april.org/projects/hebdobot.
Résultat de la commande !aide :
```
15:26 <Hebdobot> Bienvenue cpm_screen
15:26 <Hebdobot> Je suis Hebdobot-dev, le robot de gestion des revues hebdomadaires de l'APRIL.
15:26 <Hebdobot> Voici les commandes que je comprends :
15:26 <Hebdobot>
15:26 <Hebdobot> !aide,!help : afficher cette aide
15:26 <Hebdobot> !début : commencer une nouvelle revue
15:26 <Hebdobot> # titre : démarrer un sujet individuel
15:26 <Hebdobot> ## titre : démarrer un sujet collectif
15:26 <Hebdobot> % message : traiter comme un commentaire
15:26 <Hebdobot> !courant : afficher le sujet en cours
15:26 <Hebdobot> !manquants : afficher qui n'a pas participé sur le dernier sujet
15:26 <Hebdobot> !fin : terminer la revue en cours
15:26 <Hebdobot> !stop : abandonner la revue en cours
15:26 <Hebdobot> !licence : afficher la licence du logiciel Hebdobot et le lien vers ses sources
15:26 <Hebdobot> !record : affiche le record de participation à la revue
15:26 <Hebdobot> !stats : statistiques sur les précédentes revues
15:26 <Hebdobot> !version : afficher la version d'Hebdobot
15:26 <Hebdobot>
15:26 <Hebdobot> Autres commandes de dialogue : !bonjour, !date, !hello, !merci, !salut
```
À la fin de la revue, une synthèse est accessible via un site de pastes et des statistiques de la revue sont affichées.
## Build
### Dépendances
```bash
apt install ant default-jdk
```
### Build
```bash
./build.sh
```
## License
Hebdobot is a free software released on GNU AGPLv3+
## Logo
The currently cute logo is "Kids ABC Letter H" by "X posid" released on CC0 Public Domain license.
Location: hebdobot/resources/logo/
Source: https://www.publicdomainpictures.net/en/view-image.php?image=154863&picture=kids-abc-letter-h

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Fri Dec 31 11:53:11 CET 2021 #Sat May 19 15:38:35 CEST 2018
build.number=8 build.number=11

View File

@ -1,3 +1,3 @@
product.name=hebdobot product.name=hebdobot
product.revision.major=2 product.revision.major=2
product.revision.minor=11 product.revision.minor=0

View File

@ -41,11 +41,11 @@ function build_snapshot
# Java version check. # Java version check.
javaVersionCheck=`javac -version 2>&1` javaVersionCheck=`javac -version 2>&1`
if [[ "$javaVersionCheck" =~ ^.*\ 11. ]]; then if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
echo "Java 11 version requirement..... OK" echo "Java 8 version requirement..... OK"
let "okCount+=1" let "okCount+=1"
else else
echo "Java 11 version requirement..... MISSING" echo "Java 8 version requirement..... MISSING"
fi fi
if [ "$okCount" == 3 ]; then if [ "$okCount" == 3 ]; then
@ -83,11 +83,11 @@ function build_local
# Java version check. # Java version check.
javaVersionCheck=`javac -version 2>&1` javaVersionCheck=`javac -version 2>&1`
if [[ "$javaVersionCheck" =~ ^.*\ 11. ]]; then if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
echo "Java 11 version requirement..... OK" echo "Java 8 version requirement..... OK"
let "okCount+=1" let "okCount+=1"
else else
echo "Java 11 version requirement..... MISSING" echo "Java 8 version requirement..... MISSING"
fi fi
if [ "$okCount" == 3 ]; then if [ "$okCount" == 3 ]; then
@ -125,11 +125,11 @@ function build_tagandpush
# Java version check. # Java version check.
javaVersionCheck=`javac -version 2>&1` javaVersionCheck=`javac -version 2>&1`
if [[ "$javaVersionCheck" =~ ^.*\ 11. ]]; then if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
echo "Java 11 version requirement..... OK" echo "Java 8 version requirement..... OK"
let "okCount+=1" let "okCount+=1"
else else
echo "Java 11 version requirement..... MISSING" echo "Java 8 version requirement..... MISSING"
fi fi
# Git check. # Git check.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/commons-lang3-3.4.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/mastodon4j-javadoc.jar Normal file

Binary file not shown.

BIN
lib/mastodon4j-sources.jar Normal file

Binary file not shown.

BIN
lib/mastodon4j.jar Normal file

Binary file not shown.

View File

@ -12,11 +12,9 @@ irc.host=irc.freenode.org
irc.port=6667 irc.port=6667
irc.name=Hebdobot irc.name=Hebdobot
irc.channel=#april-test irc.channel=#april-test
irc.identify.nick=
irc.identify.password=
# Privatebin settings. # Pastebin settings.
#privatebin.url=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #pastebin.apiKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# Twitter settings. # Twitter settings.
#twitter.consumerKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #twitter.consumerKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@ -39,7 +37,7 @@ irc.identify.password=
notify.at15.cron=0 45 11 ? * * notify.at15.cron=0 45 11 ? * *
notify.at15.irc=Revue hebdomadaire dans 15 minutes notify.at15.irc=Revue hebdomadaire dans 15 minutes
notify.at15.twitter=Revue hebdomadaire April à 12h sur notre salon : http://april.org/salon-irc-de-lapril\nCette revue ne dure qu\'une quinzaine de minutes et permet d\'avoir une idée des actions en cours et à venir.\nVous pouvez aussi juste nous faire un coucou. Et ça met en appétit :) notify.at15.twitter=Revue hebdomadaire April à 12h sur notre salon : http://april.org/salon-irc-de-lapril\nCette revue ne dure qu\'une quinzaine de minutes et permet d\'avoir une idée des actions en cours et à venir.\nVous pouvez aussi juste nous faire un coucou. Et ça met en appétit :)
notify.at15.image=/srv/foo/photo-pizza.jpg notify.at5.image=/srv/foo/photo-pizza.jpg
#notify.at30.cron=0 30 11 ? * * #notify.at30.cron=0 30 11 ? * *
#notify.at30.irc=Revue hebdomadaire dans 30 minutes #notify.at30.irc=Revue hebdomadaire dans 30 minutes

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 KiB

View File

@ -1 +0,0 @@
Travaux réalisés par Antoine Bardelli en avril 2020.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 KiB

View File

@ -1,6 +0,0 @@
Toutes les photos présentes ici sont sous licence libre.
Les métadonnées des images contiennent les informations utiles.
Pour ajouter des métadonnées à de nouvelles photos :
exiftool -use MWG -P -m -overwrite_original_in_place -Copyright="$copyright" nouvellephoto.jpg
exiftool -use MWG -P -m -overwrite_original_in_place -Creator="$artist" nouvellephoto.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 641 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 380 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 666 KiB

View File

@ -1,7 +0,0 @@
Source:
https://www.publicdomainpictures.net/en/view-image.php?image=154863&picture=kids-abc-letter-h
License:
License: CC0 Public Domain
X posid has released this “Kids ABC Letter H” image under Public Domain license. It means that you can use and modify it for your personal and commercial projects. If you intend to use an image you find here for commercial use, please be aware that some photos do require a model or a property release. Pictures featuring products should be used with care.

View File

@ -14,11 +14,11 @@ fi
# Java version check. # Java version check.
javaVersionCheck=`java -version 2>&1` javaVersionCheck=`java -version 2>&1`
if [[ "$javaVersionCheck" =~ ^.*\ 11. ]]; then if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
echo "Java 11 version requirement..... OK" echo "Java 8 version requirement..... OK"
let "okCount+=1" let "okCount+=1"
else else
echo "Java 11 version requirement..... MISSING" echo "Java 8 version requirement..... MISSING"
fi fi
if [ "$okCount" == 2 ]; then if [ "$okCount" == 2 ]; then

View File

@ -1,6 +1,6 @@
/** /**
* Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr> * Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
* Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
* *
* This file is part of (April) Hebdobot. * This file is part of (April) Hebdobot.
* *

View File

@ -1,583 +0,0 @@
/**
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalTime;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.hooks.AnnivHook;
import org.april.hebdobot.bot.hooks.BadCommandHook;
import org.april.hebdobot.bot.hooks.CancelPreviousInputHook;
import org.april.hebdobot.bot.hooks.ChronoHook;
import org.april.hebdobot.bot.hooks.CollectiveSubjectHook;
import org.april.hebdobot.bot.hooks.CommentHook;
import org.april.hebdobot.bot.hooks.CurrentHook;
import org.april.hebdobot.bot.hooks.DateHook;
import org.april.hebdobot.bot.hooks.DefaultHook;
import org.april.hebdobot.bot.hooks.FinishReviewHook;
import org.april.hebdobot.bot.hooks.HelloHook;
import org.april.hebdobot.bot.hooks.HelpHook;
import org.april.hebdobot.bot.hooks.Hooker;
import org.april.hebdobot.bot.hooks.IndividualSubjectHook;
import org.april.hebdobot.bot.hooks.InputReviewHook;
import org.april.hebdobot.bot.hooks.LicenseHook;
import org.april.hebdobot.bot.hooks.ListenAlexandrieHook;
import org.april.hebdobot.bot.hooks.MissingHook;
import org.april.hebdobot.bot.hooks.RecordHook;
import org.april.hebdobot.bot.hooks.StartReviewHook;
import org.april.hebdobot.bot.hooks.StatsHook;
import org.april.hebdobot.bot.hooks.StatusHook;
import org.april.hebdobot.bot.hooks.StopReviewHook;
import org.april.hebdobot.bot.hooks.ThanksHook;
import org.april.hebdobot.bot.hooks.VersionHook;
import org.april.hebdobot.bot.review.Message;
import org.april.hebdobot.bot.review.Review;
import org.april.hebdobot.cron.CronManager;
import org.april.hebdobot.cron.CronSettings;
import org.april.hebdobot.identica.IdenticaSettings;
import org.april.hebdobot.privatebin.PrivatebinSettings;
import org.april.hebdobot.twitter.TwitterClient;
import org.april.hebdobot.twitter.TwitterSettings;
import org.april.hebdobot.util.Chrono;
import org.jibble.pircbot.IrcException;
import org.jibble.pircbot.NickAlreadyInUseException;
import org.jibble.pircbot.PircBot;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import twitter4j.TwitterException;
/**
* The Class Hebdobot.
*/
public class Hebdobot extends PircBot
{
private static final Logger logger = LoggerFactory.getLogger(Hebdobot.class);
private File homeDirectory;
private String host;
private int port;
private String channel;
private String identifyNick;
private String identifyPassword;
private File reviewDirectory;
private String reviewFileSuffix;
private LocalTime reviewWaitTime;
private Review review;
private Chrono chrono;
private IdenticaSettings identicaSettings;
private PrivatebinSettings privatebinSettings;
private TwitterSettings twitterSettings;
private CronSettings cronSettings;
private UserAliases aliases;
private CronManager cronManager;
private Hooker hooker;
/**
* Instantiates a new hebdobot.
*
* @param host
* the host
* @param port
* the port
* @param nickname
* the nickname
* @param channel
* the channel
* @param homeDirectory
* the home directory
* @param reviewDirectory
* the review directory
* @param identifyNick
* the identify nick
* @param identifyPassword
* the identify password
*/
public Hebdobot(final String host, final int port, final String nickname, final String channel, final File homeDirectory,
final File reviewDirectory, final String identifyNick, final String identifyPassword)
{
this.homeDirectory = homeDirectory;
this.host = host;
this.port = port;
this.channel = channel;
this.setName(nickname);
this.identifyNick = identifyNick;
this.identifyPassword = identifyPassword;
this.reviewDirectory = reviewDirectory;
this.reviewFileSuffix = null;
this.reviewWaitTime = null;
this.review = null;
this.chrono = new Chrono();
this.identicaSettings = new IdenticaSettings();
this.privatebinSettings = new PrivatebinSettings();
this.twitterSettings = new TwitterSettings();
this.cronSettings = new CronSettings();
this.aliases = new UserAliases();
this.cronManager = null;
//
this.hooker = new Hooker();
this.hooker.add(new ListenAlexandrieHook());
this.hooker.add(new CancelPreviousInputHook());
this.hooker.add(new ChronoHook());
this.hooker.add(new CollectiveSubjectHook());
this.hooker.add(new CommentHook());
this.hooker.add(new CurrentHook());
this.hooker.add(new FinishReviewHook());
this.hooker.add(new HelpHook());
this.hooker.add(new IndividualSubjectHook());
this.hooker.add(new MissingHook());
this.hooker.add(new RecordHook());
this.hooker.add(new StartReviewHook());
this.hooker.add(new StopReviewHook());
this.hooker.add(new StatsHook());
this.hooker.add(new StatusHook());
this.hooker.add(new AnnivHook());
this.hooker.add(new DateHook());
this.hooker.add(new HelloHook());
this.hooker.add(new LicenseHook());
this.hooker.add(new ThanksHook());
this.hooker.add(new VersionHook());
this.hooker.add(new BadCommandHook());
this.hooker.add(new InputReviewHook());
this.hooker.add(new DefaultHook());
}
/**
* Check anniversary.
*/
public void checkReviewAnniversary()
{
LocalDate now = LocalDate.now();
LocalDate creation = LocalDate.of(2010, 04, 30);
LocalDate anniv = LocalDate.of(now.getYear(), creation.getMonth(), creation.getDayOfMonth());
logger.debug("now ={}", now.toString());
logger.debug("creation={}", creation.toString());
logger.debug("anniv ={}", anniv.toString());
if ((!now.isBefore(anniv)) && (now.isBefore(anniv.plusDays(7))))
{
logger.info("Review anniversary detected.");
int year = anniv.getYear() - creation.getYear();
sendMessage("% \\o/ Joyeux " + year + "e anniversaire la revue hebdo \\o/");
}
}
/**
* Close.
*/
public void close()
{
this.disconnect();
this.dispose();
}
/**
* End review.
*/
public void endReview()
{
this.review.endReview();
this.chrono.reset();
}
/**
* Gets the aliases.
*
* @return the aliases
*/
public UserAliases getAliases()
{
return this.aliases;
}
public Chrono getChrono()
{
return this.chrono;
}
public CronManager getCronManager()
{
return this.cronManager;
}
/**
* Gets the cron settings.
*
* @return the cron settings
*/
public CronSettings getCronSettings()
{
return this.cronSettings;
}
/**
* Gets the help.
*
* @param source
* the source
* @return the help
* @throws HebdobotException
* the hebdobot exception
*/
public StringList getHelp(final String source) throws HebdobotException
{
StringList result;
if (source == null)
{
result = null;
}
else
{
result = this.hooker.attemptHelp(source);
}
//
return result;
}
/**
* Gets the home directory.
*
* @return the home directory
*/
public File getHomeDirectory()
{
return this.homeDirectory;
}
/**
* Gets the identica settings.
*
* @return the identica settings
*/
public IdenticaSettings getIdenticaSettings()
{
return this.identicaSettings;
}
/**
* Gets the privatebin settings.
*
* @return the privatebin settings
*/
public PrivatebinSettings getPrivatebinSettings()
{
return this.privatebinSettings;
}
public Review getReview()
{
return this.review;
}
public File getReviewDirectory()
{
return this.reviewDirectory;
}
public String getReviewFileSuffix()
{
return this.reviewFileSuffix;
}
public LocalTime getReviewWaitTime()
{
return this.reviewWaitTime;
}
/**
* Gets the twitter settings.
*
* @return the twitter settings
*/
public TwitterSettings getTwitterSettings()
{
return this.twitterSettings;
}
/**
* Notify irc.
*
* @param message
* the message
*/
public void notifyIrc(final String message)
{
sendMessage(message);
}
/**
* Notify twitter.
*
* @param message
* the message
*/
public void notifyTwitter(final String message)
{
notifyTwitter(message, null);
}
/**
* Notify twitter.
*
* @param message
* the message
* @param imageFile
* the image file
*/
public void notifyTwitter(final String message, final File imageFile)
{
if ((this.twitterSettings.isValid()) && (StringUtils.isNotBlank(message)))
{
try
{
TwitterClient twitter = new TwitterClient(this.twitterSettings.getConsumerKey(), this.twitterSettings.getConsumerSecret(),
this.twitterSettings.getAccessToken(), this.twitterSettings.getAccessTokenSecret());
twitter.tweet(message, imageFile);
}
catch (TwitterException exception)
{
logger.error("Error in tweet", exception);
sendMessage("(pour information, la notification par Tweet a échoué : " + exception.getErrorMessage() + ")");
}
}
}
/* (non-Javadoc)
* @see org.jibble.pircbot.PircBot#onMessage(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
protected void onMessage(final String channel, final String sender, final String login, final String hostname, final String message)
{
logger.debug("Message received - channel : {}, sender : {}, message : {}", channel, sender, message);
if (channel.equalsIgnoreCase(this.channel))
{
String text = message.trim();
if (this.review != null)
{
this.review.addRaw(new Message(sender, text));
}
text = text.replaceAll("^" + getName().replace("[", "\\[").replaceAll("]", "\\]") + "[,:]\\s*", "!");
try
{
this.hooker.attemptProcess(this, channel, sender, login, hostname, text);
}
catch (Exception exception)
{
logger.error("Error managing post.", exception);
sendMessage("/me a choppé un bug : ", exception.getMessage());
}
}
}
/* (non-Javadoc)
* @see org.jibble.pircbot.PircBot#onPrivateMessage(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
protected void onPrivateMessage(final String sender, final String login, final String hostname, final String message)
{
logger.debug("Private message received - sender : {}, message : {}", sender, message);
String text = message.trim();
if (text.startsWith("!"))
{
logger.info("!??? caught.");
// Command unknown.
sendMessage(sender, "vos commandes dans le salon public");
}
else
{
// Nothing to say.
}
}
/**
* Run.
*
* @throws HebdobotException
* the hebdobot exception
*/
public void run() throws HebdobotException
{
//
try
{
logger.info("Cron initializing.");
{
this.cronManager = new CronManager(this, this.cronSettings);
this.cronManager.start();
}
logger.info("Cron initialized.");
}
catch (SchedulerException | ParseException exception)
{
throw new HebdobotException("Error in cron settings.", exception);
}
// Manage "Caused by: java.net.UnknownHostException: irc.freenode.org".
boolean ended = false;
while (!ended)
{
try
{
logger.info("Bot connection.");
this.connect(this.host, this.port);
logger.info("Bot connected.");
ended = true;
}
catch (NickAlreadyInUseException exception)
{
throw new HebdobotException(exception);
}
catch (IOException exception)
{
logger.error("IOException during connection ", exception);
try
{
Thread.sleep(200000);
}
catch (InterruptedException subException)
{
logger.error("Exception during sleep ", subException);
}
}
catch (IrcException exception)
{
throw new HebdobotException(exception);
}
}
//
if (this.identifyPassword == null)
{
logger.info("Skipped identify.");
}
else
{
logger.info("Apply identify.");
sendMessage("NickServ", "identify " + this.identifyNick + " " + this.identifyPassword);
logger.info("Applied identify.");
}
logger.info("Bot joining channel ({}).", this.channel);
this.joinChannel(this.channel);
logger.info("Bot ready.");
}
/**
* Send chrono message.
*/
public void sendChronoMessage()
{
if (this.review == null)
{
sendMessage("% durée du point : pas de revue en cours.");
}
else if (this.review.isEmpty())
{
sendMessage("% durée du point : pas de point en cours.");
}
else
{
String topicTitle = this.review.getCurrentTopic().getTitle();
String chronoValue = this.chrono.toString();
sendMessage(String.format("%% durée du point %s : %s", topicTitle, chronoValue));
}
}
/**
* Send message.
*
* @param message
* the message
*/
public void sendMessage(final String message)
{
logger.debug("Send message : {}", message);
this.sendMessage(this.channel, message);
if (this.review != null)
{
this.review.addRaw(new Message("Hebdobot", message));
}
}
/**
* Sets the home directory.
*
* @param homeDirectory
* the new home directory
*/
public void setHomeDirectory(final File homeDirectory)
{
this.homeDirectory = homeDirectory;
}
public void setReview(final Review review)
{
this.review = review;
}
public void setReviewDirectory(final File reviewDirectory)
{
this.reviewDirectory = reviewDirectory;
}
public void setReviewFileSuffix(final String reviewFileSuffix)
{
this.reviewFileSuffix = reviewFileSuffix;
}
public void setReviewWaitTime(final LocalTime reviewWaitTime)
{
this.reviewWaitTime = reviewWaitTime;
}
/**
* Stop review.
*/
public void stopReview()
{
setReview(null);
this.chrono.reset();
}
}

View File

@ -1,103 +0,0 @@
/**
* Copyright (C) 2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class AnnivHook.
*/
public class AnnivHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(AnnivHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "anniv"))
{
result = new StringList("!anniv : afficher des anniversaires");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsAnyIgnoreCase(message, "!anniv"))
{
logger.info("!anniv caught.");
LocalDate now = LocalDate.now();
LocalDate revueBirthdate = LocalDate.of(2010, 04, 30);
String birthdate = revueBirthdate.format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
int years = Period.between(revueBirthdate, now).getYears();
bot.sendMessage(String.format("La revue hebdomadaire est née le %s et a %d ans", birthdate, years));
LocalDate hebdobotBirthdate = LocalDate.of(2011, 9, 9);
years = Period.between(hebdobotBirthdate, now).getYears();
birthdate = hebdobotBirthdate.format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
bot.sendMessage(String.format("Hebdobot a géré sa première revue le %s et a %d ans", birthdate, years));
LocalDate aprilBirthdate = LocalDate.of(1996, 11, 20);
birthdate = aprilBirthdate.format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
years = Period.between(aprilBirthdate, now).getYears();
bot.sendMessage(String.format("L'April a été déclarée en préférecture le %s et a %d ans", birthdate, years));
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,68 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
/**
* The Class DefaultHook.
*/
public class BadCommandHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(BadCommandHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(org.april.hebdobot.bot.Hebdobot, java.lang.String)
*/
@Override
public StringList attemptHelp(final String message) throws HebdobotException
{
return null;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (message.matches("^!.*$"))
{
logger.info("!??? caught.");
bot.sendMessage(sender + ", Yo !");
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,107 +0,0 @@
/**
* Copyright (C) 2019-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.april.hebdobot.bot.review.Topic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class CancelPreviousInputHook.
*/
public class CancelPreviousInputHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(CancelPreviousInputHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(org.april.hebdobot.bot.Hebdobot, java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "cancelprevious", "oops", "oups"))
{
result = new StringList("!oups, !oops, !cancelprevious : annuler la dernière entrée dans un point de revue");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringsUtils.equalsAnyIgnoreCase(message, "!cancelprevious", "!oops", "!oups"))
{
logger.info("!cancelprevious/!oops caught.");
// Missing.
if (bot.getReview() == null)
{
bot.sendMessage(sender + ", pas de revue en cours.");
}
else
{
Topic topic = bot.getReview().getCurrentTopic();
if (topic == null)
{
bot.sendMessage("Pas de sujet en cours.");
}
else
{
String previousMessage = topic.cancelPreviousMessage(sender);
if (previousMessage == null)
{
bot.sendMessage(sender + ", vous n'avez pas d'entrée en cours.");
}
else
{
bot.sendMessage(sender + ", suppression de votre précédente entrée : " + previousMessage);
}
}
}
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,83 +0,0 @@
/**
* Copyright (C) 2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class ChronoHook.
*/
public class ChronoHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(ChronoHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "chrono"))
{
result = new StringList("!chrono : afficher la durée du point de revue en cours");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsAnyIgnoreCase(message, "!chrono"))
{
logger.info("!chrono caught.");
// bot.sendChronoMessage();
bot.sendMessage(bot.getChrono().format());
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,108 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.april.hebdobot.bot.review.CollectiveTopic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class CollectiveSubjectHook.
*/
public class CollectiveSubjectHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(CollectiveSubjectHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "##"))
{
result = new StringList("## titre : démarrer un sujet collectif");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (message.matches("\\s*##.*"))
{
logger.info("\\s*##.* caught.");
// Collective topic, must be before individual topic.
if (bot.getReview() != null)
{
if (bot.getReview().isOwner(sender))
{
CollectiveTopic topic = new CollectiveTopic(message.replaceFirst("##", "").trim());
if (!bot.getReview().isEmpty())
{
bot.sendChronoMessage();
String participants = StringUtils.join(bot.getReview().getParticipants(), " ");
bot.sendMessage(String.format("%% %s, on va passer à la suite : %s", participants, topic.getTitle()));
}
bot.getReview().begin(topic);
bot.sendMessage("Sujet collectif : " + topic.getTitle());
bot.sendMessage("% 1 minute max");
bot.sendMessage("% si rien à signaler vous pouvez écrire % ras");
bot.sendMessage("% quand vous avez fini vous le dites par % fini");
bot.getChrono().start();
}
else
{
bot.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
}
}
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,82 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class CommentHook.
*/
public class CommentHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(CommentHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "%"))
{
result = new StringList("% message : traiter le message comme un commentaire (ignoré dans la synthèse de la revue)");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (message.startsWith("%"))
{
logger.info("% caught.");
// Ignore.
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,106 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.april.hebdobot.bot.review.CollectiveTopic;
import org.april.hebdobot.bot.review.IndividualTopic;
import org.april.hebdobot.bot.review.Topic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class CurrentHook.
*/
public class CurrentHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(CurrentHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "courant"))
{
result = new StringList("!courant : afficher le sujet en cours");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsIgnoreCase(message, "!courant"))
{
logger.info("!courant caught.");
// Current.
if (bot.getReview() == null)
{
bot.sendMessage(sender + ", pas de revue en cours.");
}
else
{
Topic current = bot.getReview().getCurrentTopic();
if (current == null)
{
bot.sendMessage("% Pas de sujet en cours.");
}
else if (current instanceof IndividualTopic)
{
bot.sendMessage("% Sujet individuel en cours : " + current.getTitle());
}
else if (current instanceof CollectiveTopic)
{
bot.sendMessage("% Sujet collectif en cours : " + current.getTitle());
}
}
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,87 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class DateHook.
*/
public class DateHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(DateHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "date", "time", "now"))
{
result = new StringList("!date, !time, !now : afficher la date et l'heure");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsAnyIgnoreCase(message, "!date", "!time", "!now"))
{
logger.info("!date caught.");
// Date command.
bot.sendMessage(LocalDateTime.now().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy HH'h'mm", Locale.FRENCH)));
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,65 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
/**
* The Class DefaultHook.
*/
public class DefaultHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(DefaultHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
result = null;
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
logger.info("All the other caught.");
result = true;
//
return result;
}
}

View File

@ -1,222 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.april.hebdobot.bot.review.ReviewReporter;
import org.april.hebdobot.bot.stats.ReviewData;
import org.april.hebdobot.bot.stats.ReviewDatas;
import org.april.hebdobot.bot.stats.ReviewDatasFile;
import org.april.hebdobot.bot.stats.ReviewStatsReporter;
import org.april.hebdobot.privatebin.PrivatebinClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class FinishReviewHook.
*/
public class FinishReviewHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(FinishReviewHook.class);
public static String DEFAULT_SUFFIX = "-log-irc-revue-hebdomadaire.txt";
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "fin"))
{
result = new StringList("!fin : terminer la revue en cours");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsAnyIgnoreCase(message, "!fin"))
{
logger.info("!fin caught.");
// End.
if (bot.getReview() == null)
{
bot.sendMessage(sender + ", pas de revue en cours.");
}
else if (!bot.getReview().isOwner(sender))
{
bot.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
}
else if (bot.getReview().isEnded())
{
bot.sendMessage("La revue est déjà finie.");
}
else if (bot.getReview().getParticipants().size() == 0)
{
bot.sendMessage("Participation nulle détectée. La revue est ignorée.");
bot.setReview(null);
}
else
{
// End the review.
bot.sendChronoMessage();
bot.endReview();
// Load and update review statistics.
ReviewDatas datas;
try
{
File reviewDataFile = new File(bot.getReviewDirectory(), "reviewstats.csv");
datas = ReviewDatasFile.load(reviewDataFile);
datas.clean();
ReviewData currentReviewData = new ReviewData(LocalDateTime.now(), bot.getReview().getParticipants().size(),
bot.getReview().getDurationInMinutes());
datas.add(currentReviewData);
if (bot.getReview().getParticipants().size() > 1)
{
ReviewDatasFile.append(reviewDataFile, currentReviewData);
}
}
catch (Exception exception)
{
logger.warn("Exception during statistics work.", exception);
datas = null;
}
// Generate the review text.
String date = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE);
String reviewText = ReviewReporter.report(datas, bot.getReview());
// Pastebin the review text.
String pastebinUrl;
if (bot.getPrivatebinSettings().isValid())
{
logger.info("Pastebin the review.");
try
{
PrivatebinClient pastebinClient = new PrivatebinClient(bot.getPrivatebinSettings());
pastebinUrl = pastebinClient.paste(reviewText);
}
catch (final Exception exception)
{
logger.error("Error during Pastebin submit.", exception);
pastebinUrl = "erreur";
}
}
else
{
pastebinUrl = "aucun";
}
// Save the review text.
logger.info("Write review file.");
File reviewFile = new File(bot.getReviewDirectory(), date + StringUtils.defaultString(bot.getReviewFileSuffix(), DEFAULT_SUFFIX));
if (reviewFile.exists())
{
LocalTime now = LocalTime.now();
String newSuffix = String.format("-%02dh%02d.txt", now.getHour(), now.getMinute());
reviewFile = new File(reviewFile.getAbsolutePath().replace(".txt", newSuffix));
}
try
{
if (!bot.getReviewDirectory().exists())
{
logger.info("Create review directory: " + bot.getReviewDirectory().getAbsolutePath());
bot.getReviewDirectory().mkdirs();
}
FileUtils.writeStringToFile(reviewFile, reviewText, StandardCharsets.UTF_8);
logger.info("File review saved in: [{}]", reviewFile.getAbsolutePath());
}
catch (final Exception exception)
{
logger.error("Error during file writing.", exception);
}
// Send conclusion message in channel.
bot.checkReviewAnniversary();
bot.sendMessage("% " + ReviewStatsReporter.reportCurrentReviewCount(datas));
bot.sendMessage("% Compte-rendu de la revue : " + pastebinUrl);
bot.sendMessage("% Durée de la revue : " + bot.getReview().getDurationInMinutes() + " minutes");
bot.sendMessage("% Nombre de personnes participantes : " + bot.getReview().getParticipants().size());
bot.sendMessage("% " + ReviewStatsReporter.reportCheckUserCountRecord(datas));
bot.sendMessage(bot.getReview().getOwner(), ReviewStatsReporter.reportUserCount(datas, bot.getReview().getParticipants().size()));
bot.sendMessage(bot.getReview().getOwner(), ReviewStatsReporter.reportDuration(datas, bot.getReview().getDurationInMinutes()));
String participants = StringUtils.join(bot.getReview().getParticipants(), " ");
bot.sendMessage("% " + participants + ", pensez à noter votre bénévalo : http://www.april.org/my?action=benevalo");
String reminderMessage = String.format(
"%% %s, ne pas oublier d'ajouter le compte-rendu de la revue sur https://agir.april.org/issues/135 en utilisant comme nom de fichier %s",
bot.getReview().getOwner(), reviewFile.getName());
logger.info("reminderMessage=[{}]", reminderMessage);
bot.sendMessage(reminderMessage);
// Finalize review.
bot.sendMessage("% Fin de la revue hebdomadaire");
bot.sendMessage(bot.getReview().getOwner(), "Revue finie.");
bot.setReview(null);
}
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,91 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class HelloHook.
*/
public class HelloHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(HelloHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "salut", "bonjour", "hello"))
{
result = new StringList("!salut, !bonjour, !hello : dire bonjour");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsAnyIgnoreCase(message, "!salut", "!bonjour", "!hello"))
{
logger.info("!salut caught.");
// Salutation command.
bot.sendMessage(sender + ", bonjour \\o/");
result = true;
}
else if ((StringsUtils.containsAnyIgnoreCase(message, "bonjour", "salut", "hello", "yo", "hey", "hi"))
&& (StringUtils.containsIgnoreCase(message, bot.getName())))
{
bot.sendMessage(sender + ", bonjour \\o/");
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,158 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class HelpHook.
*/
public class HelpHook extends Hook
{
private static final Pattern COMMAND_HELP_PATTERN = Pattern.compile("^!(aide|help)\\s+(?<token>\\S+)$");
private static final Logger logger = LoggerFactory.getLogger(HelpHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "aide", "help"))
{
result = new StringList();
result.append("!aide, !help, !aide hebdobot, !help hebdobot : afficher l'aide générale");
result.append("!aide commande, !help commande : afficher l'aide de la commande !commande");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message) throws HebdobotException
{
boolean result;
if (StringUtils.equalsAnyIgnoreCase(message, "!aide", "!help", "!aide hebdobot", "!help hebdobot"))
{
logger.info("!help caught.");
// Help.
bot.sendMessage(sender,
String.format("Bienvenue %s. Je suis %s, le robot de gestion des revues hebdomadaires de l'April.", sender, bot.getName()));
bot.sendMessage(sender, "Voici les commandes que je comprends :");
bot.sendMessage(sender, " ");
bot.sendMessage(sender, " !aide,!help : afficher cette aide");
bot.sendMessage(sender, " !aide commande : afficher l'aide de la commande !commande");
bot.sendMessage(sender, " !début : commencer une nouvelle revue");
bot.sendMessage(sender, " % message  : traiter comme un commentaire");
bot.sendMessage(sender, " # titre  : démarrer un sujet individuel");
bot.sendMessage(sender, " ## titre  : démarrer un sujet collectif");
bot.sendMessage(sender, " !oups   : annuler la dernière entrée dans un point de revue");
bot.sendMessage(sender, " !courant : afficher le sujet en cours");
bot.sendMessage(sender, " !fin : terminer la revue en cours");
bot.sendMessage(sender, " !stop  : abandonner la revue en cours");
bot.sendMessage(sender, " ");
bot.sendMessage(sender,
"Autres commandes : !anniv, !bonjour, !chrono, !date, !hello, !licence, !manquants, !merci, !record, !salut, !stats, !status, !version");
result = true;
}
else
{
String token = extractTargetHelp(message);
if (token == null)
{
result = false;
}
else
{
StringList help = bot.getHelp(token);
if (help == null)
{
bot.sendMessage("aide indisponible pour la commande " + token);
}
else
{
for (String line : help)
{
bot.sendMessage(line);
}
}
result = true;
}
}
//
return result;
}
/**
* Extract target help.
*
* @return the string
*/
private String extractTargetHelp(final String message)
{
String result;
Matcher matcher = COMMAND_HELP_PATTERN.matcher(message);
if (matcher.find())
{
result = matcher.group("token");
if (StringUtils.startsWith(result, "!"))
{
result = result.substring(1);
}
}
else
{
result = null;
}
//
return result;
}
}

View File

@ -1,78 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import fr.devinsy.strings.StringList;
/**
* The Class Hook.
*/
public abstract class Hook
{
/**
* Attempt help.
*
* @param string
* the string
* @return the string list
* @throws HebdobotException
* the hebdobot exception
*/
public abstract StringList attemptHelp(final String string) throws HebdobotException;
/**
* Attempt process.
*
* @param bot
* the bot
* @param channel
* the channel
* @param sender
* the sender
* @param login
* the login
* @param hostname
* the hostname
* @param message
* the message
* @return true, if successful
* @throws HebdobotException
* the hebdobot exception
*/
public abstract boolean attemptProcess(Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message) throws HebdobotException;
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
String result;
result = this.getClass().getName().replace("Hook", "");
//
return result;
}
}

View File

@ -1,190 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import java.util.ArrayList;
import java.util.Iterator;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
/**
* The class Hooker, a hook manager.
*/
public class Hooker
{
private static final Logger logger = LoggerFactory.getLogger(Hooker.class);
private ArrayList<Hook> hooks;
/**
* Instantiates a new hook manager.
*/
public Hooker()
{
this.hooks = new ArrayList<>(30);
}
/**
* Adds the.
*
* @param hook
* the hook
*/
public void add(final Hook hook)
{
if (hook != null)
{
this.hooks.add(hook);
}
}
/**
* Attempt help.
*
* @param message
* the message
* @return the string list
* @throws HebdobotException
* the hebdobot exception
*/
public StringList attemptHelp(final String message) throws HebdobotException
{
StringList result;
boolean ended = false;
Iterator<Hook> iterator = this.hooks.iterator();
result = null;
while (!ended)
{
if (iterator.hasNext())
{
Hook hook = iterator.next();
StringList help = hook.attemptHelp(message);
if (help != null)
{
ended = true;
result = help;
}
}
else
{
ended = true;
result = null;
}
}
//
return result;
}
/**
* Attempt process.
*
* @param bot
* the bot
* @param channel
* the channel
* @param sender
* the sender
* @param login
* the login
* @param hostname
* the hostname
* @param message
* the message
* @return true, if successful
* @throws HebdobotException
* the hebdobot exception
*/
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message) throws HebdobotException
{
boolean result;
boolean ended = false;
Iterator<Hook> iterator = this.hooks.iterator();
result = false;
while (!ended)
{
if (iterator.hasNext())
{
Hook hook = iterator.next();
boolean hookResult = hook.attemptProcess(bot, channel, sender, login, hostname, message);
if (hookResult)
{
ended = true;
result = true;
}
}
else
{
ended = true;
result = false;
}
}
//
return result;
}
/**
* Clear.
*/
public void clear()
{
this.hooks.clear();
}
public StringList getHookNames()
{
StringList result;
result = new StringList(this.hooks.size());
for (Hook hook : this.hooks)
{
result.add(hook.getName());
}
//
return result;
}
/**
* Size.
*
* @return the int
*/
public int size()
{
int result;
result = this.hooks.size();
//
return result;
}
}

View File

@ -1,107 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.april.hebdobot.bot.review.IndividualTopic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class IndividualSubjectHook.
*/
public class IndividualSubjectHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(IndividualSubjectHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "#"))
{
result = new StringList("# titre : démarrer un sujet individuel");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (message.matches("\\s*#[^#].*"))
{
logger.info("\\s*#[^#].* caught.");
// Individual topic.
if (bot.getReview() != null)
{
if (bot.getReview().isOwner(sender))
{
IndividualTopic topic = new IndividualTopic(message.replaceFirst("#", "").trim());
if (!bot.getReview().isEmpty())
{
bot.sendChronoMessage();
String participants = StringUtils.join(bot.getReview().getParticipants(), " ");
bot.sendMessage(String.format("%% %s, on va passer à la suite : %s", participants, topic.getTitle()));
}
bot.getReview().begin(topic);
bot.sendMessage("Sujet individuel : " + topic.getTitle());
bot.sendMessage("% si rien à signaler vous pouvez écrire % ras");
bot.sendMessage("% quand vous avez fini vous le dites par % fini");
bot.getChrono().start();
}
else
{
bot.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
}
}
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,75 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.april.hebdobot.bot.review.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
/**
* The Class DefaultHook.
*/
public class InputReviewHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(InputReviewHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
result = null;
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (bot.getReview() == null)
{
result = false;
}
else
{
bot.getReview().add(new Message(sender, message));
result = true;
}
result = true;
//
return result;
}
}

View File

@ -1,83 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class LicenseHook.
*/
public class LicenseHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(LicenseHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "licence", "license"))
{
result = new StringList("!licence, !license : afficher la licence du logiciel Hebdobot et le lien vers ses sources");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringsUtils.equalsAnyIgnoreCase(message, "!licence", "!license"))
{
logger.info("!licence caught.");
bot.sendMessage(
"Hebdobot est un logiciel libre de l'April sous licence GNU AGPLv3+, sources : https://forge.april.org/adminsys/hebdobot");
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,74 +0,0 @@
/**
* Copyright (C) 2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
/**
* The Class ListenAlexandrieHook.
*
* This hook is listening Alexandrie messages and do not answer.
*
*/
public class ListenAlexandrieHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(ListenAlexandrieHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
result = null;
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsIgnoreCase(sender, "alexandrie"))
{
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,116 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import java.util.Collection;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.april.hebdobot.bot.review.Topic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringSet;
import fr.devinsy.strings.StringsUtils;
/**
* The Class MissingHook.
*/
public class MissingHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(MissingHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "manquants"))
{
result = new StringList("!manquants : afficher les pseudos n'ayant pas participé au point en cours");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsIgnoreCase(message, "!manquants"))
{
logger.info("!manquants caught.");
// Missing.
if (bot.getReview() == null)
{
bot.sendMessage(sender + ", pas de revue en cours.");
}
else
{
Topic topic = bot.getReview().getCurrentTopic();
if (topic == null)
{
bot.sendMessage("Pas de sujet en cours.");
}
else
{
StringSet participants = bot.getReview().getParticipants();
participants.add(bot.getReview().getOwner());
StringSet currentParticipants = topic.getParticipants();
Collection<String> missing = CollectionUtils.subtract(participants, currentParticipants);
if (missing.isEmpty())
{
bot.sendMessage("Tout le monde s'est exprimé sur le sujet courant \\o/");
}
else
{
bot.sendMessage("Personnes participantes ne s'étant pas exprimées sur le sujet courant : " + StringUtils.join(missing, ", "));
}
}
}
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,109 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import java.io.File;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.april.hebdobot.bot.stats.ReviewDatas;
import org.april.hebdobot.bot.stats.ReviewDatasFile;
import org.april.hebdobot.bot.stats.ReviewStatsReporter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class RecordHook.
*/
public class RecordHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(RecordHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "record"))
{
result = new StringList("!record : afficher le record de participation à la revue");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsIgnoreCase(message, "!record"))
{
logger.info("!record caught.");
// This feature has to not break Hebdobot.
try
{
File reviewDataFile = new File(bot.getReviewDirectory(), "reviewstats.csv");
if (reviewDataFile.exists())
{
ReviewDatas datas = ReviewDatasFile.load(reviewDataFile);
datas.clean();
bot.sendMessage(ReviewStatsReporter.reportUserCountRecord(datas));
}
else
{
logger.warn("Statistic file not found [{}]", reviewDataFile.getAbsolutePath());
bot.sendMessage("% Fichier de statistiques absent.");
}
}
catch (Exception exception)
{
logger.warn("Exception during record work.", exception);
bot.sendMessage("% Impossible d'afficher le record.");
}
//
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,120 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import java.time.LocalTime;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.april.hebdobot.bot.review.Review;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class StartReviewHook.
*/
public class StartReviewHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(StartReviewHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "début", "debut", "start"))
{
result = new StringList("!début, !debut, !start : commencer une nouvelle revue");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsAnyIgnoreCase(message, "!début", "!debut", "!start"))
{
logger.info("!debut caught.");
if ((bot.getReviewWaitTime() != null) && (LocalTime.now().isBefore(bot.getReviewWaitTime())))
{
bot.sendMessage(sender + ", ce n'est pas encore l'heure.");
}
else
{
// Start.
if (bot.getReview() != null)
{
bot.sendMessage("% " + sender + ", une revue est déjà en cours.");
}
else
{
if (bot.getCronManager() != null)
{
try
{
bot.getCronManager().shutdown();
}
catch (SchedulerException exception)
{
logger.warn("Scheduler shutdown failed.", exception);
}
}
bot.setReview(new Review(sender, bot.getAliases()));
bot.sendMessage(sender, "Bonjour " + sender + ", vous êtes le conducteur de réunion.");
bot.sendMessage(sender, "Pour terminer la réunion, tapez \"!fin\"");
bot.checkReviewAnniversary();
bot.sendMessage("% Début de la réunion hebdomadaire");
bot.sendMessage(
"% rappel : toute ligne commençant par % sera considérée comme un commentaire et non prise en compte dans la synthèse");
bot.sendMessage("% pour connaître le point courant, taper !courant");
}
}
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,113 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import java.io.File;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.april.hebdobot.bot.stats.ReviewDatas;
import org.april.hebdobot.bot.stats.ReviewDatasFile;
import org.april.hebdobot.bot.stats.ReviewStatsReporter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class StatsHook.
*/
public class StatsHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(StatsHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "stats"))
{
result = new StringList("!stats : statistiques sur les précédentes revues");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsIgnoreCase(message, "!stats"))
{
logger.info("!stats caught.");
// Display statistics. This feature has to not break
// Hebdobot.
try
{
File reviewDataFile = new File(bot.getReviewDirectory(), "reviewstats.csv");
if (reviewDataFile.exists())
{
ReviewDatas datas = ReviewDatasFile.load(reviewDataFile);
datas.clean();
bot.sendMessage("% " + ReviewStatsReporter.reportReviewCount(datas));
bot.sendMessage("% " + ReviewStatsReporter.reportReviewUserCount(datas));
bot.sendMessage("% " + ReviewStatsReporter.reportReviewDuration(datas));
bot.sendMessage("% " + ReviewStatsReporter.reportUserCountBoard(datas));
bot.sendMessage("% " + ReviewStatsReporter.reportDurationBoard(datas));
}
else
{
logger.warn("Statistic file not found [{}]", reviewDataFile.getAbsolutePath());
bot.sendMessage("% Fichier de statistiques absent.");
}
}
catch (Exception exception)
{
logger.warn("Exception during statistics work.", exception);
bot.sendMessage("% Impossible d'afficher des statistiques.");
}
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,98 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class StatusHook.
*/
public class StatusHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(StatusHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "status", "statut"))
{
result = new StringList("!status, !statut : état et paramétrage d'Hebdobot");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsAnyIgnoreCase(message, "!status", "!statut"))
{
logger.info("!status caught.");
bot.sendMessage(sender, sender + ", voici l'état d'Hebdobot :");
bot.sendMessage(sender, " revue en cours : " + (bot.getReview() != null));
if (bot.getReview() == null)
{
bot.sendMessage(sender, " animateur revue : none");
}
else
{
bot.sendMessage(sender, " animateur revue : " + bot.getReview().getOwner());
}
bot.sendMessage(sender, " Alias settings : " + (bot.getAliases().size()));
bot.sendMessage(sender, " Identica settings : " + (bot.getIdenticaSettings().isValid()));
bot.sendMessage(sender, " Privatebin settings : " + bot.getPrivatebinSettings().toString());
bot.sendMessage(sender, " Twitter settings : " + (bot.getTwitterSettings().isValid()));
bot.sendMessage(sender, " Cron settings : " + (bot.getCronSettings().size()));
bot.sendMessage(sender, " Review Wait Time : " + (bot.getReviewWaitTime()));
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,96 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class StopReviewHook.
*/
public class StopReviewHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(StopReviewHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "stop"))
{
result = new StringList("!stop : abandonner la revue en cours");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsAnyIgnoreCase(message, "!stop"))
{
logger.info("!stop caught.");
// Stop.
if (bot.getReview() == null)
{
bot.sendMessage(sender + ", pas de revue en cours, abandon impossible.");
}
else if (!bot.getReview().isOwner(sender))
{
bot.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion.");
}
else
{
bot.sendMessage("Abandon de la revue en cours.");
bot.stopReview();
}
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,88 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class ThanksHook.
*/
public class ThanksHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(ThanksHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "merci"))
{
result = new StringList("!merci : dire que ça fait plaisir");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringsUtils.equalsAnyIgnoreCase(message, "!merci"))
{
logger.info("!merci caught.");
bot.sendMessage(sender + ", de rien \\o/");
result = true;
}
else if ((StringsUtils.containsAnyIgnoreCase(message, "merci")) && (StringUtils.containsIgnoreCase(message, bot.getName())))
{
bot.sendMessage(sender + ", de rien \\o/");
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,83 +0,0 @@
/**
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.hooks;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot;
import org.april.hebdobot.util.BuildInformation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/**
* The Class VersionHook.
*/
public class VersionHook extends Hook
{
private static final Logger logger = LoggerFactory.getLogger(VersionHook.class);
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
*/
@Override
public StringList attemptHelp(final String token) throws HebdobotException
{
StringList result;
if (StringsUtils.equalsAnyIgnoreCase(token, "version"))
{
result = new StringList("!version : afficher la version d'Hebdobot");
}
else
{
result = null;
}
//
return result;
}
/* (non-Javadoc)
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
final String message)
{
boolean result;
if (StringUtils.equalsIgnoreCase(message, "!version"))
{
logger.info("!version caught.");
bot.sendMessage(new BuildInformation().toString());
result = true;
}
else
{
result = false;
}
//
return result;
}
}

View File

@ -1,37 +0,0 @@
/**
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.review;
import java.util.LinkedList;
/**
* The Class CollectiveTopics.
*/
public class CollectiveTopics extends LinkedList<CollectiveTopic>
{
private static final long serialVersionUID = -2719546135520171963L;
/**
* Instantiates a new collective topics.
*/
public CollectiveTopics()
{
super();
}
}

View File

@ -1,64 +0,0 @@
/**
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.review;
import java.util.LinkedList;
import org.apache.commons.lang3.StringUtils;
/**
* The Class MessageLinkedList.
*/
public class Messages extends LinkedList<Message>
{
private static final long serialVersionUID = -4092193002518826252L;
/**
* Instantiates a new messages.
*/
public Messages()
{
super();
}
/**
* Gets the by author.
*
* @param author
* the author
* @return the by author
*/
public Messages getByAuthor(final String author)
{
Messages result;
result = new Messages();
for (Message message : this)
{
if (StringUtils.equals(message.getAuthor(), author))
{
result.add(message);
}
}
//
return result;
}
}

View File

@ -1,356 +0,0 @@
/**
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org>
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.review;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.april.hebdobot.bot.UserAliases;
import fr.devinsy.strings.StringSet;
/**
* The Class Review.
*/
public class Review
{
private static final int LENGTH = 80;
private final StringSet participants;
private final IndividualTopics individualTopics;
private final CollectiveTopics collectiveTopics;
private Topic currentTopic;
private final MessageList messages;
private final String owner;
private final UserAliases aliases;
private final LocalDateTime startTime;
private LocalDateTime endTime;
/**
* Instantiates a new review.
*
* @param owner
* the owner
* @param aliases
* the aliases
*/
public Review(final String owner, final UserAliases aliases)
{
this.participants = new StringSet();
this.individualTopics = new IndividualTopics();
this.collectiveTopics = new CollectiveTopics();
this.messages = new MessageList();
this.owner = owner;
this.aliases = aliases;
this.startTime = LocalDateTime.now();
this.endTime = null;
}
/**
* Adds the.
*
* @param message
* the message
*/
public void add(final Message message)
{
if (this.currentTopic != null)
{
this.participants.add(message.getAuthor());
this.currentTopic.add(message);
}
}
/**
* Adds the raw.
*
* @param message
* the message
*/
public void addRaw(final Message message)
{
this.messages.add(message);
}
/**
* Begin.
*
* @param topic
* the topic
*/
public void begin(final CollectiveTopic topic)
{
this.collectiveTopics.add(topic);
this.currentTopic = topic;
}
/**
* Begin.
*
* @param topic
* the topic
*/
public void begin(final IndividualTopic topic)
{
this.individualTopics.add(topic);
this.currentTopic = topic;
}
/**
* End review.
*/
public void endReview()
{
this.endTime = LocalDateTime.now();
}
public UserAliases getAliases()
{
return this.aliases;
}
/**
* Gets the collective topics.
*
* @return the collective topics
*/
public CollectiveTopics getCollectiveTopics()
{
return this.collectiveTopics;
}
/**
* Gets the current topic.
*
* @return the current topic
*/
public Topic getCurrentTopic()
{
return this.currentTopic;
}
/**
* Gets the duration.
*
* @return the duration
*/
public long getDuration()
{
long result;
if (this.endTime == null)
{
result = Duration.between(this.startTime, LocalDateTime.now()).getSeconds();
}
else
{
result = Duration.between(this.startTime, this.endTime).getSeconds();
}
//
return result;
}
/**
* Gets the duration.
*
* @return the duration
*/
public long getDurationInMinutes()
{
long result;
result = (long) Math.ceil(getDuration() / 60.0);
//
return result;
}
/**
* Gets the end time.
*
* @return the end time
*/
public LocalDateTime getEndTime()
{
return this.endTime;
}
/**
* Gets the formatted end time.
*
* @return the formatted end time
*/
public String getFormattedEndTime()
{
String result;
if (this.endTime == null)
{
result = "??h??";
}
else
{
result = this.endTime.format(DateTimeFormatter.ofPattern("kk'h'mm"));
}
//
return result;
}
/**
* Gets the formatted start time.
*
* @return the formatted start time
*/
public String getFormattedStartTime()
{
String result;
result = this.startTime.format(DateTimeFormatter.ofPattern("kk'h'mm"));
//
return result;
}
/**
* Gets the individual topics.
*
* @return the individual topics
*/
public IndividualTopics getIndividualTopics()
{
return this.individualTopics;
}
public MessageList getMessages()
{
return this.messages;
}
/**
* Gets the owner.
*
* @return the owner
*/
public String getOwner()
{
return this.owner;
}
/**
* Gets the participants.
*
* @return the participants
*/
public StringSet getParticipants()
{
StringSet result;
result = new StringSet();
for (final Topic topic : this.individualTopics)
{
result.addAll(topic.getParticipants());
}
for (final Topic topic : this.collectiveTopics)
{
result.addAll(topic.getParticipants());
}
//
return result;
}
/**
* Gets the start time.
*
* @return the start time
*/
public LocalDateTime getStartTime()
{
return this.startTime;
}
/**
* Checks if is empty.
*
* @return true, if is empty
*/
public boolean isEmpty()
{
boolean result;
if ((this.individualTopics.isEmpty()) && (this.collectiveTopics.isEmpty()))
{
result = true;
}
else
{
result = false;
}
//
return result;
}
/**
* Checks if is ended.
*
* @return true, if is ended
*/
public boolean isEnded()
{
boolean result;
if (this.endTime == null)
{
result = false;
}
else
{
result = true;
}
//
return result;
}
/**
* Checks if is owner.
*
* @param name
* the name
* @return true, if is owner
*/
public boolean isOwner(final String name)
{
boolean result;
result = this.owner.equalsIgnoreCase(name);
//
return result;
}
}

View File

@ -1,361 +0,0 @@
/**
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org>
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.review;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.bot.stats.ReviewDatas;
import org.april.hebdobot.bot.stats.ReviewStatsReporter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
/**
* The Class Review.
*/
public class ReviewReporter
{
private static final Logger logger = LoggerFactory.getLogger(ReviewReporter.class);
private static final int LENGTH_LINE = 80;
/**
* Adds the center.
*
* @param buffer
* the buffer
* @param content
* the content
*/
private static void addCenter(final StringList buffer, final String content)
{
addCenter(buffer, content, ' ');
}
/**
* Adds the center.
*
* @param buffer
* the buffer
* @param content
* the content
* @param letter
* the c
*/
private static void addCenter(final StringList buffer, final String content, final char letter)
{
buffer.appendln(getLine(content, letter));
}
/**
* Adds the chunk.
*
* @param buffer
* the buffer
* @param content
* the content
*/
private static void addChunk(final StringList buffer, final String content)
{
appendln(buffer, chunk(content));
}
/**
* Adds the empty.
*
* @param buffer
* the buffer
*/
private static void addEmpty(final StringList buffer)
{
buffer.appendln();
}
/**
* Adds the line.
*
* @param buffer
* the buffer
* @param c
* the c
*/
private static void addLine(final StringList buffer, final char c)
{
buffer.append(getLine(c)).appendln();
}
/**
* Adds the.
*
* @param buffer
* the buffer
* @param content
* the content
*/
private static void append(final StringList buffer, final String content)
{
buffer.append(content);
}
/**
* Appendln.
*
* @param buffer
* the buffer
* @param content
* the content
*/
private static void appendln(final StringList buffer, final String content)
{
buffer.appendln(content);
}
/**
* Chunk.
*
* @param content
* the content
* @return the string
*/
private static String chunk(final String content)
{
String result;
result = chunk(content, LENGTH_LINE);
//
return result;
}
/**
* Chunk.
*
* @param content
* the content
* @param maxLength
* the length
* @return the string
*/
private static String chunk(final String content, final int maxLength)
{
String result;
final String[] words = content.split(" ");
final StringBuffer buffer = new StringBuffer();
StringBuffer current = new StringBuffer();
for (final String word : words)
{
if (current.length() + word.length() > maxLength)
{
if (buffer.length() > 0)
{
buffer.append("\n");
}
buffer.append(current);
current = new StringBuffer(word);
}
else
{
if (current.length() > 0)
{
current.append(" ");
}
current.append(word);
}
}
if (current.length() > 0)
{
if (buffer.length() > 0)
{
buffer.append("\n");
}
buffer.append(current);
}
result = buffer.toString();
//
return result;
}
/**
* Gets the line.
*
* @param letter
* the letter
* @return the line
*/
private static String getLine(final Character letter)
{
String result;
result = StringUtils.repeat(letter.toString(), LENGTH_LINE);
//
return result;
}
/**
* Gets the line.
*
* @param content
* the content
* @param letter
* the c
* @return the line
*/
private static String getLine(final String content, final char letter)
{
String result;
result = StringUtils.center(" " + content + " ", LENGTH_LINE, letter);
//
return result;
}
/**
* Gets the topic.
*
* @param topic
* the topic
* @return the topic
*/
private static String getTopic(final Topic topic)
{
String result;
result = "=== " + topic.getTitle() + " ===";
//
return result;
}
/**
* Report.
*
* @param datas
* the datas
* @param review
* the review
* @return the string
*/
public static String report(final ReviewDatas datas, final Review review)
{
String result;
//
StringList buffer = new StringList();
//
addLine(buffer, '=');
addCenter(buffer, "Revue de la semaine en cours");
addEmpty(buffer);
addCenter(buffer, StringUtils.capitalize(LocalDateTime.now().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH))));
addLine(buffer, '=');
addEmpty(buffer);
addEmpty(buffer);
//
addLine(buffer, '=');
addEmpty(buffer);
addCenter(buffer, "Personnes participantes", '-');
for (final String participant : review.getParticipants())
{
addChunk(buffer, "* " + review.getAliases().getRealName(participant));
}
//
if (!review.getIndividualTopics().isEmpty())
{
for (final String participant : review.getParticipants())
{
addEmpty(buffer);
addLine(buffer, '=');
addEmpty(buffer);
addCenter(buffer, review.getAliases().getRealName(participant), '-');
for (final IndividualTopic topic : review.getIndividualTopics())
{
if (topic.hasParticipant(participant))
{
addEmpty(buffer);
appendln(buffer, getTopic(topic));
addEmpty(buffer);
for (final Message message : topic.getMessages(participant))
{
addChunk(buffer, "* " + message.getContent());
}
}
}
}
}
//
if (!review.getCollectiveTopics().isEmpty())
{
for (final CollectiveTopic topic : review.getCollectiveTopics())
{
addEmpty(buffer);
addLine(buffer, '=');
addCenter(buffer, topic.getTitle());
addLine(buffer, '=');
addEmpty(buffer);
for (final Message message : topic.getMessages())
{
addChunk(buffer, "* " + message.getAuthor() + " : " + message.getContent());
}
}
}
//
addEmpty(buffer);
addCenter(buffer, "Log IRC brut");
addEmpty(buffer);
for (Message message : review.getMessages())
{
addChunk(buffer, "* " + message.getAuthor() + " : " + message.getContent());
}
// Add statistics in text review.
addEmpty(buffer);
addCenter(buffer, "Statistiques");
addEmpty(buffer);
addChunk(buffer, ReviewStatsReporter.reportCurrentReviewCount(datas));
addChunk(buffer, "Horaire de début de la revue : " + review.getFormattedStartTime());
addChunk(buffer, "Horaire de fin de la revue : " + review.getFormattedEndTime());
addChunk(buffer, "Durée de la revue : " + review.getDurationInMinutes() + " minutes");
addChunk(buffer, "Nombre de personnes participantes : " + review.getParticipants().size());
addChunk(buffer, ReviewStatsReporter.reportCheckUserCountRecord(datas));
addChunk(buffer, ReviewStatsReporter.reportUserCount(datas, review.getParticipants().size()));
addChunk(buffer, ReviewStatsReporter.reportDuration(datas, review.getDurationInMinutes()));
//
result = buffer.toString();
//
return result;
}
}

View File

@ -1,300 +0,0 @@
/**
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.stats;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import fr.devinsy.strings.StringList;
/**
* The Class LongBoard.
*/
public class LongBoard implements Iterable<LongStat>
{
private Map<Long, LongStat> longs;
private boolean isUptodate;
private LongStats board;
/**
* Instantiates a new distribution.
*/
public LongBoard()
{
this.longs = new HashMap<>(30);
this.isUptodate = false;
this.board = new LongStats(this.longs.size());
}
/**
* Adds the.
*
* @param value
* the value
*/
public void add(final Long value)
{
if (value != null)
{
LongStat stat = this.longs.get(value);
if (stat == null)
{
stat = new LongStat(value);
this.longs.put(value, stat);
}
stat.inc();
}
}
/**
* Gets the.
*
* @param value
* the value
* @return the long stat
*/
public LongStat get(final long value)
{
LongStat result;
result = this.longs.get(value);
//
return result;
}
/**
* Gets the average.
*
* @return the average
*/
public double getAverage()
{
double result;
int numerator = 0;
int denumerator = 0;
for (LongStat stat : this.longs.values())
{
numerator += stat.getCount() * stat.getValue();
denumerator += stat.getCount();
}
result = (numerator * 1. / denumerator);
//
return result;
}
/**
* Gets the count sum.
*
* @return the count sum
*/
public int getCountSum()
{
int result;
result = 0;
for (LongStat stat : this.longs.values())
{
result += stat.getCount();
}
//
return result;
}
public long getMaxValue()
{
long result;
if (isEmpty())
{
result = 0;
}
else
{
result = Long.MIN_VALUE;
for (LongStat stat : this.longs.values())
{
if (stat.getValue() > result)
{
result = stat.getValue();
}
}
}
//
return result;
}
/**
* Gets the min.
*
* @return the min
*/
public long getMinValue()
{
long result;
if (isEmpty())
{
result = 0;
}
else
{
result = Long.MAX_VALUE;
for (LongStat stat : this.longs.values())
{
if (stat.getValue() < result)
{
result = stat.getValue();
}
}
}
//
return result;
}
/**
* Gets the position of board item.
*
* @param search
* the search
* @return the position of
*/
public Integer getPositionOf(final long search)
{
Integer result;
update();
int index = 0;
boolean ended = false;
result = null;
while (!ended)
{
if (index < this.board.size())
{
long value = this.board.get(index).getValue();
if (value == search)
{
result = index + 1;
ended = true;
}
else
{
index += 1;
}
}
else
{
ended = true;
result = null;
}
}
//
return result;
}
/**
* Checks if is empty.
*
* @return true, if is empty
*/
public boolean isEmpty()
{
boolean result;
if (this.longs.size() == 0)
{
result = true;
}
else
{
result = false;
}
//
return result;
}
/**
* Iterator.
*
* @return the iterator
*/
@Override
public Iterator<LongStat> iterator()
{
Iterator<LongStat> result;
update();
result = this.board.iterator();
//
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
String result;
update();
StringList buffer = new StringList();
for (LongStat stat : this.board)
{
buffer.append(String.format("%d (%d)", stat.getValue(), stat.getCount()));
}
result = buffer.toStringWithBracket();
//
return result;
}
/**
* Update.
*/
public void update()
{
if (!this.isUptodate)
{
this.board.clear();
for (LongStat stat : this.longs.values())
{
this.board.add(stat);
}
this.board.sortByValue();
Collections.reverse(this.board);
this.isUptodate = false;
}
}
}

View File

@ -1,99 +0,0 @@
/**
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.stats;
/**
* The Class Stat.
*/
public class LongStat
{
private long value;
private long count;
/**
* Instantiates a new distribution pair.
*
* @param value
* the value
*/
public LongStat(final long value)
{
this(value, 0);
}
/**
* Instantiates a new distribution pair.
*
* @param value
* the value
* @param count
* the count
*/
public LongStat(final long value, final long count)
{
this.value = value;
this.count = count;
}
/**
* Decrease count.
*/
public void dec()
{
this.count -= 1;
}
/**
* Gets the count.
*
* @return the count
*/
public long getCount()
{
long result;
result = this.count;
//
return result;
}
/**
* Gets the value.
*
* @return the value
*/
public long getValue()
{
long result;
result = this.value;
//
return result;
}
/**
* Increments count.
*/
public void inc()
{
this.count += 1;
}
}

View File

@ -1,217 +0,0 @@
/**
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.stats;
import java.util.Comparator;
/**
* The Class Stat.
*/
public class LongStatComparator implements Comparator<LongStat>
{
public enum Sorting
{
VALUE,
COUNT
}
private Sorting sorting;
/**
* Instantiates a new review data comparator.
*
* @param sorting
* the sorting
*/
public LongStatComparator(final Sorting sorting)
{
this.sorting = sorting;
}
/* (non-Javadoc)
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@Override
public int compare(final LongStat alpha, final LongStat bravo)
{
int result;
result = compare(alpha, bravo, this.sorting);
//
return result;
}
/**
* Compare.
*
* @param alpha
* the alpha
* @param bravo
* the bravo
* @return the int
*/
public static int compare(final Integer alpha, final Integer bravo)
{
int result;
//
if ((alpha == null) && (bravo == null))
{
result = 0;
}
else if (alpha == null)
{
result = -1;
}
else if (bravo == null)
{
result = +1;
}
else
{
result = alpha.compareTo(bravo);
}
//
return result;
}
/**
* Compare.
*
* @param alpha
* the alpha
* @param bravo
* the bravo
* @return the int
*/
public static int compare(final Long alpha, final Long bravo)
{
int result;
//
if ((alpha == null) && (bravo == null))
{
result = 0;
}
else if (alpha == null)
{
result = -1;
}
else if (bravo == null)
{
result = +1;
}
else
{
result = alpha.compareTo(bravo);
}
//
return result;
}
/**
* Compare.
*
* @param alpha
* the alpha
* @param bravo
* the bravo
* @param sorting
* the sorting
* @return the int
*/
public static int compare(final LongStat alpha, final LongStat bravo, final Sorting sorting)
{
int result;
if (sorting == null)
{
result = 0;
}
else
{
switch (sorting)
{
case VALUE:
result = compare(getValue(alpha), getValue(bravo));
break;
case COUNT:
result = compare(getCount(alpha), getCount(bravo));
break;
default:
result = 0;
}
}
//
return result;
}
/**
* Gets the user count.
*
* @param source
* the source
* @return the user count
*/
public static Long getCount(final LongStat source)
{
Long result;
if (source == null)
{
result = null;
}
else
{
result = source.getCount();
}
//
return result;
}
/**
* Gets the duration.
*
* @param source
* the source
* @return the duration
*/
public static Long getValue(final LongStat source)
{
Long result;
if (source == null)
{
result = null;
}
else
{
result = source.getValue();
}
//
return result;
}
}

View File

@ -1,75 +0,0 @@
/**
* Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.stats;
import java.util.ArrayList;
import java.util.Collections;
import org.april.hebdobot.bot.stats.LongStatComparator.Sorting;
/**
* The Class Stats.
*/
public class LongStats extends ArrayList<LongStat>
{
private static final long serialVersionUID = 5671191897589640804L;
/**
* Instantiates a new long stats.
*/
public LongStats()
{
super();
}
/**
* Instantiates a new long stats.
*
* @param initialCapacity
* the initial capacity
*/
public LongStats(final int initialCapacity)
{
super(initialCapacity);
}
/**
* Reverse.
*/
public void reverse()
{
Collections.reverse(this);
}
/**
* Sort by user count.
*/
public void sortByCount()
{
Collections.sort(this, new LongStatComparator(Sorting.COUNT));
}
/**
* Sort by duration.
*/
public void sortByValue()
{
Collections.sort(this, new LongStatComparator(Sorting.VALUE));
}
}

View File

@ -1,479 +0,0 @@
/**
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.stats;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import org.april.hebdobot.bot.stats.ReviewDataComparator.Sorting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class Stats.
*/
public class ReviewDatas extends ArrayList<ReviewData>
{
private static final long serialVersionUID = 326880908257489774L;
private static final Logger logger = LoggerFactory.getLogger(ReviewDatas.class);
/**
* Instantiates a new ReviewDatas.
*/
public ReviewDatas()
{
super();
}
/**
* Instantiates a new review datas.
*
* @param initialCapacity
* the initial capacity
*/
public ReviewDatas(final int initialCapacity)
{
super(initialCapacity);
}
/**
* Instantiates a new review datas.
*
* @param source
* the source
*/
public ReviewDatas(final ReviewDatas source)
{
super(source);
}
/**
* Clean.
*
* @return the int
*/
public int clean()
{
int result;
result = 0;
Iterator<ReviewData> iterator = iterator();
while (iterator.hasNext())
{
if (iterator.next().getUserCount() < 2)
{
iterator.remove();
result += 1;
}
}
logger.debug("Cleaned review data: {}", result);
//
return result;
}
/**
* Count by year.
*
* @param year
* the year
* @return the long
*/
public long countByYear(final long year)
{
long result;
result = getByYear(year).size();
//
return result;
}
/**
* Gets the averatge duration.
*
* @return the averatge duration
*/
public double getAveratgeDuration()
{
double result;
if (isEmpty())
{
result = 0;
}
else
{
result = 0;
int count = 0;
for (ReviewData data : this)
{
if (data.getDuration() != null)
{
count += 1;
result += data.getDuration();
}
}
if (count != 0)
{
result = result / count;
}
}
//
return result;
}
/**
* Gets the averatge user count.
*
* @return the averatge user count
*/
public double getAveratgeUserCount()
{
double result;
if (isEmpty())
{
result = 0;
}
else
{
result = 0;
for (ReviewData data : this)
{
result += data.getUserCount();
}
result = result / size();
}
//
return result;
}
/**
* Gets the by year.
*
* @param year
* the year
* @return the by year
*/
public ReviewDatas getByYear(final long year)
{
ReviewDatas result;
result = new ReviewDatas();
for (ReviewData data : this)
{
if (data.getDate().getYear() == year)
{
result.add(data);
}
}
//
return result;
}
/**
* Gets the last by index.
*
* @return the last by index
*/
public ReviewData getLastByIndex()
{
ReviewData result;
if (isEmpty())
{
result = null;
}
else
{
result = this.get(size() - 1);
}
//
return result;
}
/**
* Gets the last by max user count.
*
* @return the last by max user count
*/
public ReviewData getLastByMaxUserCount()
{
ReviewData result;
if (isEmpty())
{
result = null;
}
else
{
int max = Integer.MIN_VALUE;
result = null;
for (ReviewData data : this)
{
if (data.getUserCount() > max)
{
max = data.getUserCount();
result = data;
}
}
}
//
return result;
}
/**
* Gets the max duration.
*
* @return the max duration
*/
public long getMaxDuration()
{
long result;
if (isEmpty())
{
result = 0;
}
else
{
result = Long.MIN_VALUE;
for (ReviewData data : this)
{
if ((data.getDuration() != null) && (data.getUserCount() > result))
{
result = data.getDuration();
}
}
}
//
return result;
}
/**
* Gets the max user count.
*
* @return the max user count
*/
public int getMaxUserCount()
{
int result;
if (isEmpty())
{
result = 0;
}
else
{
result = Integer.MIN_VALUE;
for (ReviewData data : this)
{
if (data.getUserCount() > result)
{
result = data.getUserCount();
}
}
}
//
return result;
}
/**
* Gets the min duration.
*
* @return the min duration
*/
public long getMinDuration()
{
long result;
if (isEmpty())
{
result = 0;
}
else
{
result = Long.MAX_VALUE;
for (ReviewData data : this)
{
if ((data.getDuration() != null) && (data.getDuration() < result))
{
result = data.getDuration();
}
}
}
//
return result;
}
/**
* Gets the min user count.
*
* @return the min user count
*/
public int getMinUserCount()
{
int result;
if (isEmpty())
{
result = 0;
}
else
{
result = Integer.MAX_VALUE;
for (ReviewData data : this)
{
if (data.getUserCount() < result)
{
result = data.getUserCount();
}
}
}
//
return result;
}
/**
* Gets the previous last by index.
*
* @return the previous last by index
*/
public ReviewData getPreviousLastByIndex()
{
ReviewData result;
if ((isEmpty()) || (size() == 1))
{
result = null;
}
else
{
result = this.get(size() - 2);
}
//
return result;
}
/**
* Removes the first.
*
* @return the review datas
*/
public ReviewDatas removeFirst()
{
if (!isEmpty())
{
remove(0);
}
//
return this;
}
/**
* Removes the last.
*
* @return the review datas
*/
public ReviewDatas removeLast()
{
if (!isEmpty())
{
remove(size() - 1);
}
//
return this;
}
/**
* Reverse.
*/
public ReviewDatas reverse()
{
ReviewDatas result;
Collections.reverse(this);
result = this;
//
return result;
}
/**
* Sort by date.
*/
public ReviewDatas sortByDate()
{
ReviewDatas result;
Collections.sort(this, new ReviewDataComparator(Sorting.DATE));
result = this;
//
return result;
}
/**
* Sort by duration.
*/
public ReviewDatas sortByDuration()
{
ReviewDatas result;
Collections.sort(this, new ReviewDataComparator(Sorting.DURATION));
result = this;
//
return result;
}
/**
* Sort by user count.
*/
public ReviewDatas sortByUserCount()
{
ReviewDatas result;
Collections.sort(this, new ReviewDataComparator(Sorting.USERCOUNT));
result = this;
//
return result;
}
}

View File

@ -1,411 +0,0 @@
/**
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.bot.stats;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class ReviewStatReporter.
*/
public class ReviewStatsReporter
{
private static final Logger logger = LoggerFactory.getLogger(ReviewStatsReporter.class);
/**
* Instantiates a new review stat reporter.
*/
private ReviewStatsReporter()
{
}
/**
* Number suffix.
*
* @param number
* the number
* @return the string
*/
public static String numberSuffix(final long number)
{
String result;
if (number == 1)
{
result = "ère";
}
else
{
result = "e";
}
//
return result;
}
/**
* Percent.
*
* @param a
* the a
* @param b
* the b
* @return the double
*/
private static double percent(final double a, final double b)
{
double result;
if (b == 0.)
{
result = 0.;
}
else
{
result = Math.round(10000. * (a / b)) / 100.;
}
//
return result;
}
/**
* Percent.
*
* @param a
* the a
* @param b
* the b
* @return the double
*/
private static double percent(final int a, final int b)
{
double result;
result = percent(Double.valueOf(a).doubleValue(), Double.valueOf(b).doubleValue());
//
return result;
}
/**
* Report new max. The current user count is found in last review by date.
*
* @param datas
* the datas
* @return the string
*/
public static String reportCheckUserCountRecord(final ReviewDatas datas)
{
String result;
if ((datas == null) || (datas.isEmpty()) || (datas.size() == 1))
{
result = "Absence de statistique sur la participation.";
}
else
{
ReviewDatas reviews = new ReviewDatas(datas);
reviews.sortByDate();
ReviewData lastReview = datas.getLastByIndex();
reviews.removeLast();
reviews.sortByUserCount();
ReviewData recordReview = reviews.getLastByIndex();
if (lastReview.getUserCount() < recordReview.getUserCount())
{
double averageUserCount = reviews.getAveratgeUserCount();
result = String.format("La participation moyenne aux revues est de %02.1f personnes.", averageUserCount);
}
else if (lastReview.getUserCount() == recordReview.getUserCount())
{
String lastRecordDate = recordReview.getDate().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
result = String.format("\\o/ Record de participation égalé \\o/ Le précédent record de %d personnes était le %s.",
recordReview.getUserCount(), lastRecordDate);
}
else
{
String lastRecordDate = recordReview.getDate().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
result = String.format(
"*\\o/* Nouveau record de participation : %d personnes ! *\\o/* Le précédent record était de %d personnes le %s.",
lastReview.getUserCount(), recordReview.getUserCount(), lastRecordDate);
}
}
//
return result;
}
/**
* Report review count.
*
* @param datas
* the datas
* @return the string
*/
public static String reportCurrentReviewCount(final ReviewDatas datas)
{
String result;
if ((datas == null) || (datas.isEmpty()))
{
result = "Pas de statistique sur le nombre de revues.";
}
else
{
long currentYear = LocalDateTime.now().getYear();
long reviewYearCount = datas.countByYear(currentYear);
result = String.format("C'était la %d%s revue hebdomadaire de l'April, la %d%s de l'année %d.", datas.size(), numberSuffix(datas.size()),
reviewYearCount, numberSuffix(reviewYearCount), currentYear);
}
//
return result;
}
/**
* Report duration.
*
* @param datas
* the datas
* @param currentDuration
* the current duration
* @return the string
*/
public static String reportDuration(final ReviewDatas datas, final long currentDuration)
{
String result;
if ((datas == null) || (datas.isEmpty()))
{
result = "Pas de statistique sur la durée de la revue.";
}
else
{
LongBoard board = new LongBoard();
for (ReviewData data : datas)
{
board.add(data.getDuration());
}
logger.debug("Duration board: " + board.toString());
LongStat stat = board.get(currentDuration);
int total = board.getCountSum();
result = String.format(
"Statistiques sur la durée de la revue (%d min) : position %d (min.=%d min, moy.=%.1f min, max.=%d min), fréquence %d/%d (%.0f %%)",
stat.getValue(), board.getPositionOf(stat.getValue()), board.getMinValue(), board.getAverage(), board.getMaxValue(),
stat.getCount(), total, percent(stat.getCount(), total));
}
//
return result;
}
/**
* Report duration board.
*
* @param datas
* the datas
* @return the string
*/
public static String reportDurationBoard(final ReviewDatas datas)
{
String result;
LongBoard board = new LongBoard();
for (ReviewData data : datas)
{
board.add(data.getDuration());
}
result = "Tableau des durées (en minutes) : " + board.toString();
//
return result;
}
/**
* Report review count.
*
* @param datas
* the datas
* @return the string
*/
public static String reportReviewCount(final ReviewDatas datas)
{
String result;
if ((datas == null) || (datas.isEmpty()))
{
result = "Pas de statistique sur le nombre de revues.";
}
else
{
ReviewData firstReview = datas.sortByDate().get(0);
long reviewCount = datas.size();
String firstDate = firstReview.getDate().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
result = String.format("Il y a eu %d revues. La première date du %s.", reviewCount, firstDate);
}
//
return result;
}
/**
* Report review duration.
*
* @param datas
* the datas
* @return the string
*/
public static String reportReviewDuration(final ReviewDatas datas)
{
String result;
if ((datas == null) || (datas.isEmpty()))
{
result = "Pas de statistique sur la durée des revues.";
}
else
{
result = String.format("Durée des revues : min.=%d min, moy.=%.1f min, max=%d min", datas.getMinDuration(), datas.getAveratgeDuration(),
datas.getMaxDuration());
}
//
return result;
}
/**
* Report review user count.
*
* @param datas
* the datas
* @return the string
*/
public static String reportReviewUserCount(final ReviewDatas datas)
{
String result;
if ((datas == null) || (datas.isEmpty()))
{
result = "Absence de statistique sur les participations.";
}
else
{
result = String.format("Participation aux revues : min.=%d, moy.=%.1f, max=%d", datas.getMinUserCount(), datas.getAveratgeUserCount(),
datas.getMaxUserCount());
}
//
return result;
}
/**
* Report user count.
*
* @param datas
* the datas
* @param currentUserCount
* the current user count
* @return the string
*/
public static String reportUserCount(final ReviewDatas datas, final int currentUserCount)
{
String result;
if ((datas == null) || (datas.isEmpty()))
{
result = "Absence de statistique sur la participation.";
}
else
{
IntegerBoard board = new IntegerBoard();
for (ReviewData data : datas)
{
board.add(data.getUserCount());
}
logger.debug("User count board: " + board.toString());
IntegerStat stat = board.get(currentUserCount);
int total = board.getCountSum();
result = String.format(
"Statistiques sur la participation à la revue (%d personnes) : position %d (min.=%d, moy.=%.1f, max.=%d), fréquence %d/%d (%.0f %%)",
stat.getValue(), board.getPositionOf(stat.getValue()), board.getMinValue(), board.getAverage(), board.getMaxValue(),
stat.getCount(), total, percent(stat.getCount(), total));
}
//
return result;
}
/**
* Report user count board.
*
* @param datas
* the datas
* @return the string
*/
public static String reportUserCountBoard(final ReviewDatas datas)
{
String result;
IntegerBoard board = new IntegerBoard();
for (ReviewData data : datas)
{
board.add(data.getUserCount());
}
result = "Tableau du nombre de personnes participantes : " + board.toString();
//
return result;
}
/**
* Report max user count.
*
* @param datas
* the datas
* @return the string
*/
public static String reportUserCountRecord(final ReviewDatas datas)
{
String result;
if ((datas == null) || (datas.isEmpty()))
{
result = "Absence de statistique sur la participation à la revue.";
}
else
{
ReviewData recordReview = datas.getLastByMaxUserCount();
String recordDate = recordReview.getDate().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
result = String.format("Le record de participation est de %d personnes le %s.", recordReview.getUserCount(), recordDate);
}
//
return result;
}
}

View File

@ -1,6 +1,6 @@
/** /**
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr> * Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
* Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
* *
* This file is part of (April) Hebdobot. * This file is part of (April) Hebdobot.
* *
@ -31,13 +31,13 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.BasicConfigurator; import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.PropertyConfigurator;
import org.april.hebdobot.HebdobotException; import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.bot.Hebdobot; import org.april.hebdobot.model.Hebdobot;
import org.april.hebdobot.bot.UserAliases; import org.april.hebdobot.model.UserAliases;
import org.april.hebdobot.util.BuildInformation; import org.april.hebdobot.util.BuildInformation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList; import fr.devinsy.util.strings.StringList;
/** /**
* The Class Launcher. * The Class Launcher.
@ -50,7 +50,7 @@ public class HebdobotCLI
private static final String DEFAULT_ALIAS_FILE = "users.conf"; private static final String DEFAULT_ALIAS_FILE = "users.conf";
/** /**
* Instantiates a new hebdobot CLI. * Instantiates a new hebdobot launcher.
*/ */
private HebdobotCLI() private HebdobotCLI()
{ {
@ -201,7 +201,7 @@ public class HebdobotCLI
logger.info("Alias list: " + aliases.toLineString()); logger.info("Alias list: " + aliases.toLineString());
Hebdobot bot = new Hebdobot(config.getIrcHost(), config.getIrcPort(), config.getIrcName(), config.getIrcChannel(), Hebdobot bot = new Hebdobot(config.getIrcHost(), config.getIrcPort(), config.getIrcName(), config.getIrcChannel(),
configFile.getParentFile(), reviewDirectory, config.getIrcIdentifyNick(), config.getIrcIdentifyPassword()); configFile.getParentFile(), reviewDirectory);
// //
bot.setReviewWaitTime(config.getReviewWaitTime()); bot.setReviewWaitTime(config.getReviewWaitTime());
@ -209,7 +209,7 @@ public class HebdobotCLI
// //
logger.info("Bot configuring…"); logger.info("Bot configuring…");
bot.getPrivatebinSettings().setServerUrl(config.getPrivatebinUrl()); bot.getPastebinSettings().setApiKey(config.getPastebinApiKey());
bot.getIdenticaSettings().setApiKey(config.getIdenticaApiKey()); bot.getIdenticaSettings().setApiKey(config.getIdenticaApiKey());
bot.getIdenticaSettings().setApiSecret(config.getIdenticaApiSecret()); bot.getIdenticaSettings().setApiSecret(config.getIdenticaApiSecret());
bot.getTwitterSettings().setConsumerKey(config.getTwitterConsumerKey()); bot.getTwitterSettings().setConsumerKey(config.getTwitterConsumerKey());

View File

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org> * Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
* *
* This file is part of (April) Hebdobot. * This file is part of (April) Hebdobot.
* *
@ -21,8 +21,6 @@ package org.april.hebdobot.cli;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Properties; import java.util.Properties;
@ -35,7 +33,7 @@ import org.april.hebdobot.util.HebdobotUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringSet; import fr.devinsy.util.strings.StringSet;
/** /**
* The Class Launcher. * The Class Launcher.
@ -92,7 +90,6 @@ public class HebdobotConfigFile extends Properties
for (String notifyName : getNotifyNames()) for (String notifyName : getNotifyNames())
{ {
String notifyDescription = getNotifyCron(notifyName);
String notifyCron = getNotifyCron(notifyName); String notifyCron = getNotifyCron(notifyName);
String notifyIrcMessage = getNotifyIrcMessage(notifyName); String notifyIrcMessage = getNotifyIrcMessage(notifyName);
String notifyTwitterMessage = getNotifyTwitterMessage(notifyName); String notifyTwitterMessage = getNotifyTwitterMessage(notifyName);
@ -108,7 +105,7 @@ public class HebdobotConfigFile extends Properties
notifyImageFile = new File(notifyImageFileName); notifyImageFile = new File(notifyImageFileName);
} }
CronValue cronValue = new CronValue(notifyName, notifyDescription, notifyCron, notifyIrcMessage, notifyTwitterMessage, notifyImageFile); CronValue cronValue = new CronValue(notifyName, notifyCron, notifyIrcMessage, notifyTwitterMessage, notifyImageFile);
result.add(cronValue); result.add(cronValue);
} }
@ -179,36 +176,6 @@ public class HebdobotConfigFile extends Properties
return result; return result;
} }
/**
* Gets the irc identify login.
*
* @return the irc identify login
*/
public String getIrcIdentifyNick()
{
String result;
result = getProperty("irc.identify.nick");
//
return result;
}
/**
* Gets the identify password.
*
* @return the identify password
*/
public String getIrcIdentifyPassword()
{
String result;
result = getProperty("irc.identify.password");
//
return result;
}
/** /**
* Gets the name. * Gets the name.
* *
@ -334,23 +301,15 @@ public class HebdobotConfigFile extends Properties
} }
/** /**
* Gets the private bin url. * Gets the pastebin api key.
* *
* @return the private bin url * @return the pastebin api key
*/ */
public URL getPrivatebinUrl() public String getPastebinApiKey()
{ {
URL result; String result;
try result = getProperty("pastebin.apiKey");
{
String value = getProperty("privatebin.url");
result = new URL(value);
}
catch (MalformedURLException exception)
{
result = null;
}
// //
return result; return result;
@ -485,14 +444,6 @@ public class HebdobotConfigFile extends Properties
{ {
result = false; result = false;
} }
else if ((getProperty("irc.identify.nick") != null) && (getProperty("irc.identify.password") == null))
{
result = false;
}
else if ((getProperty("irc.identify.nick") == null) && (getProperty("irc.identify.password") != null))
{
result = false;
}
else else
{ {
result = true; result = true;

View File

@ -1,6 +1,6 @@
/** /**
* Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr> * Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
* Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
* *
* This file is part of (April) Hebdobot. * This file is part of (April) Hebdobot.
* *
@ -19,21 +19,18 @@
*/ */
package org.april.hebdobot.cron; package org.april.hebdobot.cron;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.bot.Hebdobot;
import org.quartz.Job; import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException; import org.quartz.JobExecutionException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* The Class NotifyCronJob. * The Class Job.
*/ */
public class NotifyJob implements Job public class CronFooJob implements Job
{ {
private static final Logger logger = LoggerFactory.getLogger(NotifyJob.class); private static final Logger logger = LoggerFactory.getLogger(CronFooJob.class);
/* (non-Javadoc) /* (non-Javadoc)
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext) * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
@ -41,28 +38,6 @@ public class NotifyJob implements Job
@Override @Override
public void execute(final JobExecutionContext context) throws JobExecutionException public void execute(final JobExecutionContext context) throws JobExecutionException
{ {
logger.info("CRON FIRE " + context.getTrigger().getDescription()); logger.debug("CRON JOB");
JobDataMap map = context.getJobDetail().getJobDataMap();
Hebdobot bot = (Hebdobot) map.get("bot");
CronValue cron = (CronValue) map.get("cron");
if (StringUtils.isBlank(cron.getIrcMessage()))
{
logger.info("No IRC message so no notify.");
}
else
{
bot.notifyIrc(cron.getIrcMessage());
}
if (StringUtils.isBlank(cron.getTwitterMessage()))
{
logger.info("No Twitter message so no notify.");
}
else
{
bot.notifyTwitter(cron.getTwitterMessage(), cron.getImageFile());
}
} }
} }

View File

@ -0,0 +1,126 @@
/**
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
* Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hebdobot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.cron;
import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.model.Hebdobot;
import org.quartz.JobExecutionContext;
import org.quartz.Trigger;
import org.quartz.Trigger.CompletedExecutionInstruction;
import org.quartz.TriggerListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class Job.
*/
public class CronListener implements TriggerListener
{
private static final Logger logger = LoggerFactory.getLogger(CronListener.class);
private CronValue cron;
private Hebdobot bot;
/**
* Instantiates a new cron listener.
*
* @param bot
* the bot
* @param cron
* the cron
*/
public CronListener(final Hebdobot bot, final CronValue cron)
{
if (cron == null)
{
throw new IllegalArgumentException("Null parameter cron.");
}
else if (bot == null)
{
throw new IllegalArgumentException("Null parameter bot.");
}
else
{
this.bot = bot;
this.cron = cron;
}
}
/* (non-Javadoc)
* @see org.quartz.TriggerListener#getName()
*/
@Override
public String getName()
{
return this.cron.getName();
}
/* (non-Javadoc)
* @see org.quartz.TriggerListener#triggerComplete(org.quartz.Trigger, org.quartz.JobExecutionContext, org.quartz.Trigger.CompletedExecutionInstruction)
*/
@Override
public void triggerComplete(final Trigger trigger, final JobExecutionContext context, final CompletedExecutionInstruction triggerInstructionCode)
{
}
/* (non-Javadoc)
* @see org.quartz.TriggerListener#triggerFired(org.quartz.Trigger, org.quartz.JobExecutionContext)
*/
@Override
public void triggerFired(final Trigger trigger, final JobExecutionContext context)
{
logger.info("CRON FIRE " + context.getTrigger().getDescription());
if (StringUtils.isBlank(this.cron.getIrcMessage()))
{
logger.info("No IRC message so no notify.");
}
else
{
this.bot.notifyIrc(this.cron.getIrcMessage());
}
if (StringUtils.isBlank(this.cron.getTwitterMessage()))
{
logger.info("No Twitter message so no notify.");
}
else
{
this.bot.notifyTwitter(this.cron.getTwitterMessage(), this.cron.getImageFile());
}
}
/* (non-Javadoc)
* @see org.quartz.TriggerListener#triggerMisfired(org.quartz.Trigger)
*/
@Override
public void triggerMisfired(final Trigger trigger)
{
}
/* (non-Javadoc)
* @see org.quartz.TriggerListener#vetoJobExecution(org.quartz.Trigger, org.quartz.JobExecutionContext)
*/
@Override
public boolean vetoJobExecution(final Trigger trigger, final JobExecutionContext context)
{
return false;
}
}

View File

@ -1,6 +1,6 @@
/** /**
* Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr> * Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
* Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
* *
* This file is part of (April) Hebdobot. * This file is part of (April) Hebdobot.
* *
@ -19,15 +19,18 @@
*/ */
package org.april.hebdobot.cron; package org.april.hebdobot.cron;
import java.text.ParseException; import org.april.hebdobot.model.Hebdobot;
import org.quartz.CronScheduleBuilder;
import org.april.hebdobot.bot.Hebdobot; import org.quartz.JobBuilder;
import org.quartz.JobDataMap; import org.quartz.JobDetail;
import org.quartz.Scheduler; import org.quartz.Scheduler;
import org.quartz.SchedulerException; import org.quartz.SchedulerException;
import org.quartz.impl.JobDetailImpl; import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.TriggerKey;
import org.quartz.TriggerListener;
import org.quartz.impl.StdSchedulerFactory; import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.triggers.CronTriggerImpl; import org.quartz.impl.matchers.KeyMatcher;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -51,10 +54,8 @@ public class CronManager
* the crons * the crons
* @throws SchedulerException * @throws SchedulerException
* the scheduler exception * the scheduler exception
* @throws ParseException
* the parse exception
*/ */
public CronManager(final Hebdobot bot, final CronSettings crons) throws SchedulerException, ParseException public CronManager(final Hebdobot bot, final CronSettings crons) throws SchedulerException
{ {
this.bot = bot; this.bot = bot;
this.crons = crons; this.crons = crons;
@ -64,7 +65,6 @@ public class CronManager
{ {
addCron(cron); addCron(cron);
} }
this.scheduler.start();
} }
/** /**
@ -74,29 +74,16 @@ public class CronManager
* the cron * the cron
* @throws SchedulerException * @throws SchedulerException
* the scheduler exception * the scheduler exception
* @throws ParseException
* the parse exception
*/ */
public void addCron(final CronValue cron) throws SchedulerException, ParseException public void addCron(final CronValue cron) throws SchedulerException
{ {
{ Trigger trigger = TriggerBuilder.newTrigger().withDescription(cron.getName()).withIdentity(cron.getName())
final JobDetailImpl job = new JobDetailImpl(); .withSchedule(CronScheduleBuilder.cronSchedule(cron.getCron())).build();
job.setName(cron.getName()); JobDetail job = JobBuilder.newJob(CronFooJob.class).withIdentity(cron.getName()).build();
job.setDescription(cron.getDescription()); this.scheduler.scheduleJob(job, trigger);
job.setJobClass(NotifyJob.class);
JobDataMap data = new JobDataMap(); TriggerListener listener = new CronListener(this.bot, cron);
data.put("bot", this.bot); this.scheduler.getListenerManager().addTriggerListener(listener, KeyMatcher.keyEquals(new TriggerKey(cron.getName())));
data.put("cron", cron);
job.setJobDataMap(data);
CronTriggerImpl trigger = new CronTriggerImpl();
trigger.setName(cron.getName());
trigger.setDescription(cron.getDescription());
trigger.setCronExpression(cron.getCron());
this.scheduler.scheduleJob(job, trigger);
}
logger.info("Added cron value: " + cron.getName()); logger.info("Added cron value: " + cron.getName());
} }

View File

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2017,2019 Christian Pierre MOMON <cmomon@april.org> * Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
* *
* This file is part of (April) Hebdobot. * This file is part of (April) Hebdobot.
* *
@ -26,7 +26,6 @@ import java.io.File;
public class CronValue public class CronValue
{ {
private String name; private String name;
private String description;
private String cron; private String cron;
private String ircMessage; private String ircMessage;
private String twitterMessage; private String twitterMessage;
@ -37,8 +36,6 @@ public class CronValue
* *
* @param name * @param name
* the name * the name
* @param description
* the description
* @param cron * @param cron
* the cron * the cron
* @param ircMessage * @param ircMessage
@ -48,11 +45,9 @@ public class CronValue
* @param imageFile * @param imageFile
* the image file * the image file
*/ */
public CronValue(final String name, final String description, final String cron, final String ircMessage, final String twitterMessage, public CronValue(final String name, final String cron, final String ircMessage, final String twitterMessage, final File imageFile)
final File imageFile)
{ {
this.name = name; this.name = name;
this.description = description;
this.cron = cron; this.cron = cron;
this.ircMessage = ircMessage; this.ircMessage = ircMessage;
this.twitterMessage = twitterMessage; this.twitterMessage = twitterMessage;
@ -64,11 +59,6 @@ public class CronValue
return this.cron; return this.cron;
} }
public String getDescription()
{
return this.description;
}
public File getImageFile() public File getImageFile()
{ {
return this.imageFile; return this.imageFile;
@ -94,11 +84,6 @@ public class CronValue
this.cron = value; this.cron = value;
} }
public void setDescription(final String description)
{
this.description = description;
}
public void setImageFile(final File imageFile) public void setImageFile(final File imageFile)
{ {
this.imageFile = imageFile; this.imageFile = imageFile;

Some files were not shown because too many files have changed in this diff Show More