Compare commits
107 Commits
mastodon
...
Hebdobot-v
Author | SHA1 | Date | |
---|---|---|---|
89321c9203 | |||
4f7f9902e8 | |||
13abc16e41 | |||
fbd6543aa2 | |||
959d947563 | |||
d0bedf3d31 | |||
ba417d60d8 | |||
e04bfdcf84 | |||
8b3784e7d5 | |||
5f449b66e5 | |||
03103efa35 | |||
ef22bbc593 | |||
d00ba4c40a | |||
9f0e09b8e6 | |||
31bca36d49 | |||
cbdef8e674 | |||
483732382b | |||
925bc0a805 | |||
d709328666 | |||
54669590ab | |||
66bb09ef87 | |||
f5da3a6ae4 | |||
534d335df1 | |||
216db84883 | |||
47fd4b58e8 | |||
c469fd5c7b | |||
4382db9e8b | |||
de0d8a4d5e | |||
58d8bcc3a8 | |||
caba69fc75 | |||
cd319dbacc | |||
b5fd23533f | |||
03e346554f | |||
9a3bf64417 | |||
8e51e5c25b | |||
6fb712ed18 | |||
c2aeedced2 | |||
44b1865a9b | |||
853852751f | |||
d110c2168e | |||
f3a9bfc465 | |||
4d9a09b0e1 | |||
b5cfa87aa9 | |||
9e2743368b | |||
c4e904a7a9 | |||
9526609196 | |||
7cc73c9a4e | |||
dfaac4e407 | |||
8696ed665c | |||
c731c9413c | |||
12fe4ede50 | |||
77d501937a | |||
f97607b91e | |||
94b2b35870 | |||
33c8617fcf | |||
f645c86fe4 | |||
3a4980d3e2 | |||
2c42afdcc3 | |||
06516acdaa | |||
81eaaaee76 | |||
fb2eb0772d | |||
1799500b0f | |||
a9057039c4 | |||
29e878a02a | |||
b7be0fae07 | |||
8c5b3486ab | |||
ddddfd55bc | |||
cf090c021e | |||
8346f211f9 | |||
90c739ed07 | |||
d02e12e1da | |||
18bd91eec2 | |||
680b2b56d8 | |||
2c37b9ab0a | |||
96a37bf770 | |||
a1dfbcc896 | |||
dbbb9da4d6 | |||
935bdeed07 | |||
7bc6a415f6 | |||
3058ffe587 | |||
1f3b2accbd | |||
8660574211 | |||
880e1d44b6 | |||
42b6faaa5c | |||
95c12449d1 | |||
1e8f06f373 | |||
f11dd169d7 | |||
d52d358984 | |||
1cd73061e7 | |||
d2a1f6b340 | |||
f2f9bceae5 | |||
6640dc9853 | |||
1524774eb7 | |||
bca2565ea9 | |||
bfc81614a9 | |||
59fb949d02 | |||
561fb4ce02 | |||
0467fdb1dd | |||
a72713d36c | |||
599f04e7dd | |||
7651c66c54 | |||
9a18bea228 | |||
c87cbe2059 | |||
fb2dd10a46 | |||
1eab79954c | |||
2d5c6d025c | |||
ed13715e60 |
23
.classpath
@ -12,16 +12,18 @@
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</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/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/junit-4.11.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-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-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/httpclient-4.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/httpcore-4.4.1.jar"/>
|
||||
@ -29,16 +31,15 @@
|
||||
<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/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-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-stream-4.0.4.jar" sourcepath="lib/twitter4j-stream-4.0.4-src.zip"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/mastodon4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.25.jar" sourcepath="lib/Logs/slf4j-api-1.7.25-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/Logs/slf4j-log4j12-1.7.25.jar" sourcepath="lib/Logs/slf4j-log4j12-1.7.25-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/UnitTesting/junit-4.12.jar" sourcepath="lib/UnitTesting/junit-4.12-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/devinsy-strings-0.8.2.jar" sourcepath="lib/devinsy-strings-0.8.2-sources.zip"/>
|
||||
<classpathentry kind="lib" path="lib/commons-lang3-3.8.jar" sourcepath="lib/commons-lang3-3.8-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/json-simple-1.1.1.jar" sourcepath="lib/json-simple-1.1.1-source.zip"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
||||
/bin/
|
||||
/dist/
|
||||
/build/
|
||||
*~
|
@ -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.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=11
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
@ -33,6 +33,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
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.explicitlyClosedAutoCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
@ -76,6 +77,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=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.staticAccessReceiver=warning
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
@ -108,8 +110,10 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=11
|
||||
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_annotation=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
@ -117,17 +121,20 @@ 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_qualified_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=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_enum_constants=49
|
||||
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_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_method_declaration=16
|
||||
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_string_concatenation=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_type_declaration=16
|
||||
@ -213,11 +220,12 @@ 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_method_body=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_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_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_bitwise_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_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
@ -248,6 +256,8 @@ 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_ellipsis=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_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
@ -272,13 +282,17 @@ 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_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_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_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_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_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_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_bitwise_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_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
@ -326,6 +340,8 @@ 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_ellipsis=do not 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_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
@ -362,9 +378,12 @@ 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_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_relational_operator=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_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_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
|
||||
@ -390,7 +409,11 @@ org.eclipse.jdt.core.formatter.tabulation.char=space
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=4
|
||||
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.wrap_before_binary_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_additive_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_string_concatenation=true
|
||||
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
|
||||
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
|
||||
|
@ -13,28 +13,38 @@ cleanup.always_use_this_for_non_static_field_access=true
|
||||
cleanup.always_use_this_for_non_static_method_access=false
|
||||
cleanup.convert_functional_interfaces=false
|
||||
cleanup.convert_to_enhanced_for_loop=false
|
||||
cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
|
||||
cleanup.correct_indentation=false
|
||||
cleanup.format_source_code=true
|
||||
cleanup.format_source_code_changes_only=false
|
||||
cleanup.insert_inferred_type_arguments=false
|
||||
cleanup.lazy_logical_operator=false
|
||||
cleanup.make_local_variable_final=false
|
||||
cleanup.make_parameters_final=true
|
||||
cleanup.make_private_fields_final=false
|
||||
cleanup.make_type_abstract_if_missing_method=false
|
||||
cleanup.make_variable_declarations_final=true
|
||||
cleanup.merge_conditional_blocks=false
|
||||
cleanup.never_use_blocks=false
|
||||
cleanup.never_use_parentheses_in_expressions=true
|
||||
cleanup.number_suffix=false
|
||||
cleanup.objects_equals=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_member_accesses_through_instances_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_method_accesses_with_declaring_class=false
|
||||
cleanup.remove_private_constructors=true
|
||||
cleanup.remove_redundant_type_arguments=true
|
||||
cleanup.remove_redundant_modifiers=false
|
||||
cleanup.remove_redundant_semicolons=false
|
||||
cleanup.remove_redundant_type_arguments=false
|
||||
cleanup.remove_trailing_whitespaces=true
|
||||
cleanup.remove_trailing_whitespaces_all=true
|
||||
cleanup.remove_trailing_whitespaces_ignore_empty=false
|
||||
cleanup.remove_unnecessary_array_creation=false
|
||||
cleanup.remove_unnecessary_casts=true
|
||||
cleanup.remove_unnecessary_nls_tags=true
|
||||
cleanup.remove_unused_imports=true
|
||||
@ -43,11 +53,14 @@ cleanup.remove_unused_private_fields=true
|
||||
cleanup.remove_unused_private_members=false
|
||||
cleanup.remove_unused_private_methods=true
|
||||
cleanup.remove_unused_private_types=true
|
||||
cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
cleanup.sort_members=true
|
||||
cleanup.sort_members_all=false
|
||||
cleanup.use_anonymous_class_creation=false
|
||||
cleanup.use_autoboxing=false
|
||||
cleanup.use_blocks=true
|
||||
cleanup.use_blocks_only_for_return_and_throw=false
|
||||
cleanup.use_directly_map_method=false
|
||||
cleanup.use_lambda=true
|
||||
cleanup.use_parentheses_in_expressions=false
|
||||
cleanup.use_this_for_non_static_field_access=true
|
||||
@ -55,6 +68,8 @@ 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_only_if_necessary=true
|
||||
cleanup.use_type_arguments=false
|
||||
cleanup.use_unboxing=false
|
||||
cleanup.use_var=false
|
||||
cleanup_profile=_Hebdobot
|
||||
cleanup_settings_version=2
|
||||
eclipse.preferences.version=1
|
||||
@ -62,6 +77,7 @@ editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
|
||||
formatter_profile=_Hebdobot
|
||||
formatter_settings_version=12
|
||||
jautodoc.cleanup.add_header=false
|
||||
jautodoc.cleanup.javadoc=false
|
||||
jautodoc.cleanup.replace_header=false
|
||||
org.eclipse.jdt.ui.exception.name=exception
|
||||
org.eclipse.jdt.ui.gettersetter.use.is=true
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<runtime name="jdk1.8.0_92"/>
|
||||
<installed facet="java" version="1.8"/>
|
||||
<installed facet="java" version="11"/>
|
||||
</faceted-project>
|
||||
|
4
CHANGES
@ -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 :
|
||||
> From: aeris <aeris@imirhil.fr>
|
||||
@ -32,5 +32,5 @@ Le 08/01/2018 à 01:07, aeris a écrit :
|
||||
* change Java version to 1.8
|
||||
|
||||
* anonymized Twitter API key
|
||||
* eplaced Maven with Ant
|
||||
* replaced Maven with Ant
|
||||
* no more code injection
|
62
README.md
Normal file
@ -0,0 +1,62 @@
|
||||
# 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
|
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Sat May 19 15:38:35 CEST 2018
|
||||
build.number=11
|
||||
#Fri Dec 31 11:53:11 CET 2021
|
||||
build.number=8
|
||||
|
@ -1,3 +1,3 @@
|
||||
product.name=hebdobot
|
||||
product.revision.major=2
|
||||
product.revision.minor=0
|
||||
product.revision.minor=11
|
||||
|
18
build.sh
@ -41,11 +41,11 @@ function build_snapshot
|
||||
|
||||
# Java version check.
|
||||
javaVersionCheck=`javac -version 2>&1`
|
||||
if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
|
||||
echo "Java 8 version requirement..... OK"
|
||||
if [[ "$javaVersionCheck" =~ ^.*\ 11. ]]; then
|
||||
echo "Java 11 version requirement..... OK"
|
||||
let "okCount+=1"
|
||||
else
|
||||
echo "Java 8 version requirement..... MISSING"
|
||||
echo "Java 11 version requirement..... MISSING"
|
||||
fi
|
||||
|
||||
if [ "$okCount" == 3 ]; then
|
||||
@ -83,11 +83,11 @@ function build_local
|
||||
|
||||
# Java version check.
|
||||
javaVersionCheck=`javac -version 2>&1`
|
||||
if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
|
||||
echo "Java 8 version requirement..... OK"
|
||||
if [[ "$javaVersionCheck" =~ ^.*\ 11. ]]; then
|
||||
echo "Java 11 version requirement..... OK"
|
||||
let "okCount+=1"
|
||||
else
|
||||
echo "Java 8 version requirement..... MISSING"
|
||||
echo "Java 11 version requirement..... MISSING"
|
||||
fi
|
||||
|
||||
if [ "$okCount" == 3 ]; then
|
||||
@ -125,11 +125,11 @@ function build_tagandpush
|
||||
|
||||
# Java version check.
|
||||
javaVersionCheck=`javac -version 2>&1`
|
||||
if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
|
||||
echo "Java 8 version requirement..... OK"
|
||||
if [[ "$javaVersionCheck" =~ ^.*\ 11. ]]; then
|
||||
echo "Java 11 version requirement..... OK"
|
||||
let "okCount+=1"
|
||||
else
|
||||
echo "Java 8 version requirement..... MISSING"
|
||||
echo "Java 11 version requirement..... MISSING"
|
||||
fi
|
||||
|
||||
# Git check.
|
||||
|
BIN
lib/Logs/slf4j-api-1.7.25-sources.jar
Normal file
BIN
lib/Logs/slf4j-api-1.7.25.jar
Normal file
BIN
lib/Logs/slf4j-log4j12-1.7.25-sources.jar
Normal file
BIN
lib/Logs/slf4j-log4j12-1.7.25.jar
Normal file
BIN
lib/UnitTesting/junit-4.12-sources.jar
Normal file
BIN
lib/UnitTesting/junit-4.12.jar
Normal file
BIN
lib/commons-lang3-3.8-sources.jar
Normal file
BIN
lib/commons-lang3-3.8.jar
Normal file
BIN
lib/devinsy-strings-0.8.2-sources.zip
Normal file
BIN
lib/devinsy-strings-0.8.2.jar
Normal file
BIN
lib/json-simple-1.1.1-source.zip
Normal file
BIN
lib/json-simple-1.1.1.jar
Normal file
@ -12,9 +12,11 @@ irc.host=irc.freenode.org
|
||||
irc.port=6667
|
||||
irc.name=Hebdobot
|
||||
irc.channel=#april-test
|
||||
irc.identify.nick=
|
||||
irc.identify.password=
|
||||
|
||||
# Pastebin settings.
|
||||
#pastebin.apiKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
# Privatebin settings.
|
||||
#privatebin.url=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
# Twitter settings.
|
||||
#twitter.consumerKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
@ -37,7 +39,7 @@ irc.channel=#april-test
|
||||
notify.at15.cron=0 45 11 ? * *
|
||||
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.at5.image=/srv/foo/photo-pizza.jpg
|
||||
notify.at15.image=/srv/foo/photo-pizza.jpg
|
||||
|
||||
#notify.at30.cron=0 30 11 ? * *
|
||||
#notify.at30.irc=Revue hebdomadaire dans 30 minutes
|
||||
|
After Width: | Height: | Size: 359 KiB |
1
resources/images/Pizza-chacun-chez-soi/notes
Normal file
@ -0,0 +1 @@
|
||||
Travaux réalisés par Antoine Bardelli en avril 2020.
|
After Width: | Height: | Size: 2.7 MiB |
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 2.2 MiB |
After Width: | Height: | Size: 3.7 MiB |
After Width: | Height: | Size: 490 KiB |
BIN
resources/images/isorepublic-pizza-green-1-AlinePonce-1024x.jpg
Normal file
After Width: | Height: | Size: 342 KiB |
After Width: | Height: | Size: 299 KiB |
After Width: | Height: | Size: 497 KiB |
6
resources/images/notes
Normal file
@ -0,0 +1,6 @@
|
||||
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
|
BIN
resources/images/photo-pizza-ElfQrinValerioCapello.jpg
Normal file
After Width: | Height: | Size: 641 KiB |
BIN
resources/images/pizza-julien-tromeur-1024x.jpg
Normal file
After Width: | Height: | Size: 318 KiB |
BIN
resources/images/pizza-sanok-szwejk-2012-Silar-1024x.jpg
Normal file
After Width: | Height: | Size: 380 KiB |
BIN
resources/logo/kinder-abc-letter-h.jpg
Normal file
After Width: | Height: | Size: 666 KiB |
7
resources/logo/notes
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
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.
|
@ -14,11 +14,11 @@ fi
|
||||
|
||||
# Java version check.
|
||||
javaVersionCheck=`java -version 2>&1`
|
||||
if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
|
||||
echo "Java 8 version requirement..... OK"
|
||||
if [[ "$javaVersionCheck" =~ ^.*\ 11. ]]; then
|
||||
echo "Java 11 version requirement..... OK"
|
||||
let "okCount+=1"
|
||||
else
|
||||
echo "Java 8 version requirement..... MISSING"
|
||||
echo "Java 11 version requirement..... MISSING"
|
||||
fi
|
||||
|
||||
if [ "$okCount" == 2 ]; then
|
||||
|
@ -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) 2017 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
583
src/org/april/hebdobot/bot/Hebdobot.java
Normal file
@ -0,0 +1,583 @@
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
@ -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) 2017 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -17,7 +17,7 @@
|
||||
* 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.model;
|
||||
package org.april.hebdobot.bot;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -32,7 +32,7 @@ import org.april.hebdobot.HebdobotException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.util.strings.StringList;
|
||||
import fr.devinsy.strings.StringList;
|
||||
|
||||
/**
|
||||
* The Class UserAliases.
|
103
src/org/april/hebdobot/bot/hooks/AnnivHook.java
Normal file
@ -0,0 +1,103 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
68
src/org/april/hebdobot/bot/hooks/BadCommandHook.java
Normal file
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
107
src/org/april/hebdobot/bot/hooks/CancelPreviousInputHook.java
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
83
src/org/april/hebdobot/bot/hooks/ChronoHook.java
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
108
src/org/april/hebdobot/bot/hooks/CollectiveSubjectHook.java
Normal file
@ -0,0 +1,108 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
82
src/org/april/hebdobot/bot/hooks/CommentHook.java
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
106
src/org/april/hebdobot/bot/hooks/CurrentHook.java
Normal file
@ -0,0 +1,106 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
87
src/org/april/hebdobot/bot/hooks/DateHook.java
Normal file
@ -0,0 +1,87 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
65
src/org/april/hebdobot/bot/hooks/DefaultHook.java
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
222
src/org/april/hebdobot/bot/hooks/FinishReviewHook.java
Normal file
@ -0,0 +1,222 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
91
src/org/april/hebdobot/bot/hooks/HelloHook.java
Normal file
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
158
src/org/april/hebdobot/bot/hooks/HelpHook.java
Normal file
@ -0,0 +1,158 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
78
src/org/april/hebdobot/bot/hooks/Hook.java
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
190
src/org/april/hebdobot/bot/hooks/Hooker.java
Normal file
@ -0,0 +1,190 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
107
src/org/april/hebdobot/bot/hooks/IndividualSubjectHook.java
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
75
src/org/april/hebdobot/bot/hooks/InputReviewHook.java
Normal file
@ -0,0 +1,75 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
83
src/org/april/hebdobot/bot/hooks/LicenseHook.java
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
74
src/org/april/hebdobot/bot/hooks/ListenAlexandrieHook.java
Normal file
@ -0,0 +1,74 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
116
src/org/april/hebdobot/bot/hooks/MissingHook.java
Normal file
@ -0,0 +1,116 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
109
src/org/april/hebdobot/bot/hooks/RecordHook.java
Normal file
@ -0,0 +1,109 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
120
src/org/april/hebdobot/bot/hooks/StartReviewHook.java
Normal file
@ -0,0 +1,120 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
113
src/org/april/hebdobot/bot/hooks/StatsHook.java
Normal file
@ -0,0 +1,113 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
98
src/org/april/hebdobot/bot/hooks/StatusHook.java
Normal file
@ -0,0 +1,98 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
96
src/org/april/hebdobot/bot/hooks/StopReviewHook.java
Normal file
@ -0,0 +1,96 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
88
src/org/april/hebdobot/bot/hooks/ThanksHook.java
Normal file
@ -0,0 +1,88 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
83
src/org/april/hebdobot/bot/hooks/VersionHook.java
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
@ -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) 2017 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -17,11 +17,11 @@
|
||||
* 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.model.review;
|
||||
package org.april.hebdobot.bot.review;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import fr.devinsy.strings.StringSet;
|
||||
|
||||
/**
|
||||
* The Class CollectiveTopic.
|
||||
@ -52,6 +52,31 @@ public class CollectiveTopic extends Topic
|
||||
this.messages.add(message);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.review.Topic#cancelPrevious(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String cancelPreviousMessage(final String author)
|
||||
{
|
||||
String result;
|
||||
|
||||
Messages authorMessages = this.messages.getByAuthor(author);
|
||||
|
||||
if (authorMessages.isEmpty())
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Message previousMessage = authorMessages.getLast();
|
||||
this.messages.remove(previousMessage);
|
||||
result = previousMessage.getContent();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the messages.
|
||||
*
|
||||
@ -66,13 +91,34 @@ public class CollectiveTopic extends Topic
|
||||
* @see org.april.hebdobot.review.Topic#getParticipants()
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getParticipants()
|
||||
public StringSet getParticipants()
|
||||
{
|
||||
final Set<String> participants = new HashSet<String>();
|
||||
StringSet result = new StringSet();
|
||||
for (final Message message : this.messages)
|
||||
{
|
||||
participants.add(message.getAuthor());
|
||||
result.add(message.getAuthor());
|
||||
}
|
||||
return participants;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for message.
|
||||
*
|
||||
* @param author
|
||||
* the author
|
||||
* @return true, if successful
|
||||
*/
|
||||
@Override
|
||||
public boolean hasMessage(final String author)
|
||||
{
|
||||
boolean result;
|
||||
|
||||
Messages authorMessage = this.messages.getByAuthor(author);
|
||||
result = authorMessage.isEmpty();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -16,21 +16,21 @@
|
||||
* 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.model.review;
|
||||
package org.april.hebdobot.bot.review;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* The Class MessageLinkedList.
|
||||
* The Class CollectiveTopics.
|
||||
*/
|
||||
public class Messages extends LinkedList<Message>
|
||||
public class CollectiveTopics extends LinkedList<CollectiveTopic>
|
||||
{
|
||||
private static final long serialVersionUID = -4092193002518826252L;
|
||||
private static final long serialVersionUID = -2719546135520171963L;
|
||||
|
||||
/**
|
||||
* Instantiates a new messages.
|
||||
* Instantiates a new collective topics.
|
||||
*/
|
||||
public Messages()
|
||||
public CollectiveTopics()
|
||||
{
|
||||
super();
|
||||
}
|
@ -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) 2017 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -17,18 +17,16 @@
|
||||
* 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.model.review;
|
||||
package org.april.hebdobot.bot.review;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import fr.devinsy.strings.StringSet;
|
||||
|
||||
/**
|
||||
* The Class IndividualTopic.
|
||||
*/
|
||||
public class IndividualTopic extends Topic
|
||||
{
|
||||
private final Map<String, Messages> messages;
|
||||
private final MessageMap messages;
|
||||
|
||||
/**
|
||||
* Instantiates a new individual topic.
|
||||
@ -40,7 +38,7 @@ public class IndividualTopic extends Topic
|
||||
{
|
||||
super(title);
|
||||
|
||||
this.messages = new HashMap<String, Messages>();
|
||||
this.messages = new MessageMap();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -57,6 +55,29 @@ public class IndividualTopic extends Topic
|
||||
this.messages.get(author).add(message);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.review.Topic#cancelPrevious(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String cancelPreviousMessage(final String participant)
|
||||
{
|
||||
String result;
|
||||
|
||||
Messages authorMessages = this.messages.get(participant);
|
||||
if ((authorMessages == null) || (authorMessages.isEmpty()))
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Message removed = authorMessages.removeLast();
|
||||
result = removed.getContent();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the messages.
|
||||
*
|
||||
@ -78,11 +99,38 @@ public class IndividualTopic extends Topic
|
||||
* @see org.april.hebdobot.review.Topic#getParticipants()
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getParticipants()
|
||||
public StringSet getParticipants()
|
||||
{
|
||||
Set<String> result;
|
||||
StringSet result;
|
||||
|
||||
result = this.messages.keySet();
|
||||
result = new StringSet(this.messages.keySet());
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for message.
|
||||
*
|
||||
* @param participant
|
||||
* the participant
|
||||
* @return true, if successful
|
||||
*/
|
||||
@Override
|
||||
public boolean hasMessage(final String participant)
|
||||
{
|
||||
boolean result;
|
||||
|
||||
Messages messages = this.messages.get(participant);
|
||||
|
||||
if ((messages == null) || (messages.isEmpty()))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
@ -1,6 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
|
||||
* Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -17,25 +16,22 @@
|
||||
* 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;
|
||||
package org.april.hebdobot.bot.review;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* The Class BotMock.
|
||||
* The Class IndividualTopics.
|
||||
*/
|
||||
public class Foo
|
||||
public class IndividualTopics extends LinkedList<IndividualTopic>
|
||||
{
|
||||
private static final long serialVersionUID = -5285310840777688742L;
|
||||
|
||||
/**
|
||||
* Instantiates a new bot mock.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
* Instantiates a new individual topics.
|
||||
*/
|
||||
@Test
|
||||
public static void Foo() throws Exception
|
||||
public IndividualTopics()
|
||||
{
|
||||
StringUtils.isBlank("");
|
||||
super();
|
||||
}
|
||||
}
|
@ -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) 2017 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -17,7 +17,7 @@
|
||||
* 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.model.review;
|
||||
package org.april.hebdobot.bot.review;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -16,7 +16,7 @@
|
||||
* 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.model.review;
|
||||
package org.april.hebdobot.bot.review;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
37
src/org/april/hebdobot/bot/review/MessageMap.java
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 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.review;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* The Class MessageMap.
|
||||
*/
|
||||
public class MessageMap extends HashMap<String, Messages>
|
||||
{
|
||||
private static final long serialVersionUID = 2324236890989710448L;
|
||||
|
||||
/**
|
||||
* Instantiates a new message map.
|
||||
*/
|
||||
public MessageMap()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
64
src/org/april/hebdobot/bot/review/Messages.java
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
356
src/org/april/hebdobot/bot/review/Review.java
Normal file
@ -0,0 +1,356 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
361
src/org/april/hebdobot/bot/review/ReviewReporter.java
Normal file
@ -0,0 +1,361 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
@ -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) 2017 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -17,9 +17,9 @@
|
||||
* 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.model.review;
|
||||
package org.april.hebdobot.bot.review;
|
||||
|
||||
import java.util.Set;
|
||||
import fr.devinsy.strings.StringSet;
|
||||
|
||||
/**
|
||||
* The Class Topic.
|
||||
@ -47,12 +47,20 @@ public abstract class Topic
|
||||
*/
|
||||
public abstract void add(Message message);
|
||||
|
||||
/**
|
||||
* Cancel previous.
|
||||
*
|
||||
* @param participant
|
||||
* the participant
|
||||
*/
|
||||
public abstract String cancelPreviousMessage(final String participant);
|
||||
|
||||
/**
|
||||
* Gets the participants.
|
||||
*
|
||||
* @return the participants
|
||||
*/
|
||||
public abstract Set<String> getParticipants();
|
||||
public abstract StringSet getParticipants();
|
||||
|
||||
/**
|
||||
* Gets the title.
|
||||
@ -63,4 +71,13 @@ public abstract class Topic
|
||||
{
|
||||
return this.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for message from.
|
||||
*
|
||||
* @param author
|
||||
* the author
|
||||
* @return true, if successful
|
||||
*/
|
||||
public abstract boolean hasMessage(String author);
|
||||
}
|
@ -16,14 +16,14 @@
|
||||
* 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.model.stats;
|
||||
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.util.strings.StringList;
|
||||
import fr.devinsy.strings.StringList;
|
||||
|
||||
/**
|
||||
* The Class Integers.
|
||||
@ -39,7 +39,7 @@ public class IntegerBoard implements Iterable<IntegerStat>
|
||||
*/
|
||||
public IntegerBoard()
|
||||
{
|
||||
this.integers = new HashMap<Integer, IntegerStat>(30);
|
||||
this.integers = new HashMap<>(30);
|
||||
this.isUptodate = false;
|
||||
this.board = new IntegerStats(this.integers.size());
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
* 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.model.stats;
|
||||
package org.april.hebdobot.bot.stats;
|
||||
|
||||
/**
|
||||
* The Class Stat.
|
@ -16,7 +16,7 @@
|
||||
* 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.model.stats;
|
||||
package org.april.hebdobot.bot.stats;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
@ -16,12 +16,12 @@
|
||||
* 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.model.stats;
|
||||
package org.april.hebdobot.bot.stats;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.april.hebdobot.model.stats.IntegerStatComparator.Sorting;
|
||||
import org.april.hebdobot.bot.stats.IntegerStatComparator.Sorting;
|
||||
|
||||
/**
|
||||
* The Class Stats.
|