From 2465b8ced2303c6a5c7695bc96dca306ed82516e Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 14 Dec 2017 15:37:29 +0100 Subject: [PATCH] Set formatter and save actions settings and applied it. --- .settings/org.eclipse.jdt.core.prefs | 285 +++++++++ .settings/org.eclipse.jdt.ui.prefs | 125 ++++ .../imirhil/april/hebdobot/Application.java | 83 +-- .../fr/imirhil/april/hebdobot/Context.java | 43 +- .../java/fr/imirhil/april/hebdobot/Job.java | 61 +- .../april/hebdobot/OAuthRegistration.java | 31 +- .../fr/imirhil/april/hebdobot/irc/Bot.java | 547 +++++++++--------- .../april/hebdobot/irc/ReviewListener.java | 5 +- .../april/hebdobot/pastebin/Expiration.java | 25 +- .../april/hebdobot/pastebin/Format.java | 25 +- .../april/hebdobot/pastebin/Option.java | 21 +- .../hebdobot/pastebin/PastebinClient.java | 252 ++++---- .../april/hebdobot/pastebin/Private.java | 23 +- .../hebdobot/review/CollectiveTopic.java | 46 +- .../hebdobot/review/IndividualTopic.java | 54 +- .../april/hebdobot/review/Message.java | 39 +- .../imirhil/april/hebdobot/review/Review.java | 371 ++++++------ .../imirhil/april/hebdobot/review/Topic.java | 23 +- .../imirhil/april/hebdobot/xml/UserAlias.java | 77 +-- .../imirhil/april/hebdobot/irc/BotTest.java | 130 +++-- .../hebdobot/pastebin/PastebinClientTest.java | 15 +- 21 files changed, 1413 insertions(+), 868 deletions(-) create mode 100644 .settings/org.eclipse.jdt.ui.prefs diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 60105c1..a41f3ba 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -3,3 +3,288 @@ org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +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 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_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_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=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_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 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=false +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=false +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +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_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_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 +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +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_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 +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +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_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_unary_operator=do not 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_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 +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=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 +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=150 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +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_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..9335075 --- /dev/null +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,125 @@ +cleanup.add_default_serial_version_id=false +cleanup.add_generated_serial_version_id=true +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +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.correct_indentation=false +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.insert_inferred_type_arguments=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.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=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_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +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.sort_members=true +cleanup.sort_members_all=false +cleanup.use_anonymous_class_creation=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_lambda=true +cleanup.use_parentheses_in_expressions=false +cleanup.use_this_for_non_static_field_access=true +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_profile=_Hebdobot +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_Hebdobot +formatter_settings_version=12 +jautodoc.cleanup.add_header=false +jautodoc.cleanup.replace_header=false +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=true +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_type_arguments=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=true +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=true +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=true +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_type_arguments=false +sp_jautodoc.cleanup.add_header=false +sp_jautodoc.cleanup.replace_header=false diff --git a/src/main/java/fr/imirhil/april/hebdobot/Application.java b/src/main/java/fr/imirhil/april/hebdobot/Application.java index bec2c2a..5dfec1b 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/Application.java +++ b/src/main/java/fr/imirhil/april/hebdobot/Application.java @@ -35,50 +35,53 @@ import fr.imirhil.april.hebdobot.pastebin.PastebinClient; import fr.imirhil.april.hebdobot.pastebin.Private; import fr.imirhil.april.hebdobot.review.Review; -public class Application implements ReviewListener { - private static final Logger LOGGER = LoggerFactory - .getLogger(Application.class); +public class Application implements ReviewListener +{ + private static final Logger LOGGER = LoggerFactory.getLogger(Application.class); - private static final String FILE_SUFFIX = "file.suffix"; + private static final String FILE_SUFFIX = "file.suffix"; - private final Properties properties = Context.getBean("properties"); - private final Bot bot = Context.getBean(Bot.class); - private final PastebinClient pastebinClient = Context - .getBean(PastebinClient.class); + private final Properties properties = Context.getBean("properties"); + private final Bot bot = Context.getBean(Bot.class); + private final PastebinClient pastebinClient = Context.getBean(PastebinClient.class); - private Application() throws Exception { - this.bot.add(this); - } + private Application() throws Exception + { + this.bot.add(this); + } - @Override - public void onEnd(final Review review) { - final String date = ISODateTimeFormat.basicDate().print(new DateTime()); - final String text = review.toString(); - try { - this.bot.sendMessage("% Compte-rendu de la revue : " - + this.pastebinClient.paste(text, "Revue APRIL " + date, - Private.UNLISTED)); - } catch (final Exception e) { - LOGGER.error("Error during Pastebin submit", e); - } + @Override + public void onEnd(final Review review) + { + final String date = ISODateTimeFormat.basicDate().print(new DateTime()); + final String text = review.toString(); + try + { + this.bot.sendMessage("% Compte-rendu de la revue : " + this.pastebinClient.paste(text, "Revue APRIL " + date, Private.UNLISTED)); + } + catch (final Exception e) + { + LOGGER.error("Error during Pastebin submit", e); + } - if (this.properties.containsKey(FILE_SUFFIX)) { - try { - final File file = - new File(date + "_" - + this.properties.getProperty(FILE_SUFFIX)); - FileUtils.writeStringToFile(file, text); - this.bot.sendMessage("% Compte-rendu de la revue : " - + file.getName()); - } catch (final Exception e) { - LOGGER.error("Error during file generation", e); - } - } - } + if (this.properties.containsKey(FILE_SUFFIX)) + { + try + { + final File file = new File(date + "_" + this.properties.getProperty(FILE_SUFFIX)); + FileUtils.writeStringToFile(file, text); + this.bot.sendMessage("% Compte-rendu de la revue : " + file.getName()); + } + catch (final Exception e) + { + LOGGER.error("Error during file generation", e); + } + } + } - public static void main(final String[] args) throws Exception { - new FileSystemXmlApplicationContext(System.getProperty("spring.conf", - "conf.xml")).registerShutdownHook(); - new Application(); - } + public static void main(final String[] args) throws Exception + { + new FileSystemXmlApplicationContext(System.getProperty("spring.conf", "conf.xml")).registerShutdownHook(); + new Application(); + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/Context.java b/src/main/java/fr/imirhil/april/hebdobot/Context.java index 1c944bf..af81a04 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/Context.java +++ b/src/main/java/fr/imirhil/april/hebdobot/Context.java @@ -26,28 +26,33 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.stereotype.Component; @Component -public final class Context implements ApplicationContextAware { - private static ApplicationContext CONTEXT; +public final class Context implements ApplicationContextAware +{ + private static ApplicationContext CONTEXT; - @Override - public void setApplicationContext( - final ApplicationContext applicationContext) throws BeansException { - CONTEXT = applicationContext; - } + @Override + public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException + { + CONTEXT = applicationContext; + } - public static T getBean(final Class clazz) { - return CONTEXT.getBean(clazz); - } + public static void close() + { + if (CONTEXT instanceof ConfigurableApplicationContext) + { + ((ConfigurableApplicationContext) CONTEXT).close(); + } + } - public static void close() { - if (CONTEXT instanceof ConfigurableApplicationContext) { - ((ConfigurableApplicationContext)CONTEXT).close(); - } - } + public static T getBean(final Class clazz) + { + return CONTEXT.getBean(clazz); + } - @SuppressWarnings("unchecked") - public static T getBean(final String name) { - return (T) CONTEXT.getBean(name); - } + @SuppressWarnings("unchecked") + public static T getBean(final String name) + { + return (T) CONTEXT.getBean(name); + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/Job.java b/src/main/java/fr/imirhil/april/hebdobot/Job.java index 6444136..9deb75f 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/Job.java +++ b/src/main/java/fr/imirhil/april/hebdobot/Job.java @@ -25,37 +25,44 @@ import org.springframework.social.twitter.api.impl.TwitterTemplate; import fr.imirhil.april.hebdobot.irc.Bot; -public class Job { - @Resource - private Bot bot; - @Resource - private TwitterTemplate twitterClient; - private String tweet; - private String irc; +public class Job +{ + @Resource + private Bot bot; + @Resource + private TwitterTemplate twitterClient; + private String tweet; + private String irc; - public void setTweet(final String message) { - this.tweet = message; - } + public void at30() + { + this.notify(30); + } - public void setIrc(final String message) { - this.irc = message; - } + public void at45() + { + this.notify(15); + } - private void notify(final int min) { - this.bot.sendMessage(String.format(this.irc, min)); - final String tweet = String.format(this.tweet, min); - this.twitterClient.timelineOperations().updateStatus(tweet); - } + public void at55() + { + this.notify(5); + } - public void at30() { - this.notify(30); - } + private void notify(final int min) + { + this.bot.sendMessage(String.format(this.irc, min)); + final String tweet = String.format(this.tweet, min); + this.twitterClient.timelineOperations().updateStatus(tweet); + } - public void at45() { - this.notify(15); - } + public void setIrc(final String message) + { + this.irc = message; + } - public void at55() { - this.notify(5); - } + public void setTweet(final String message) + { + this.tweet = message; + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/OAuthRegistration.java b/src/main/java/fr/imirhil/april/hebdobot/OAuthRegistration.java index e3067af..6e0c117 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/OAuthRegistration.java +++ b/src/main/java/fr/imirhil/april/hebdobot/OAuthRegistration.java @@ -27,22 +27,19 @@ import org.scribe.model.Token; import org.scribe.model.Verifier; import org.scribe.oauth.OAuthService; -public class OAuthRegistration { - public static void main(final String args[]) throws Exception { - final OAuthService service = - new ServiceBuilder() - .provider(TwitterApi.class) - .apiKey("uCZMXbUWuda7a2RqqKd2yg") - .apiSecret( - "KUH2O77u5RJfqZ2rE8qV6Ak1HBKQRg70DUIVAXDr6oo") - .build(); - final Token requestToken = service.getRequestToken(); - final String authUrl = service.getAuthorizationUrl(requestToken); - System.out.println(authUrl); +public class OAuthRegistration +{ + public static void main(final String args[]) throws Exception + { + final OAuthService service = new ServiceBuilder().provider(TwitterApi.class).apiKey("uCZMXbUWuda7a2RqqKd2yg") + .apiSecret("KUH2O77u5RJfqZ2rE8qV6Ak1HBKQRg70DUIVAXDr6oo").build(); + final Token requestToken = service.getRequestToken(); + final String authUrl = service.getAuthorizationUrl(requestToken); + System.out.println(authUrl); - final String value = new Scanner(System.in).nextLine(); - final Verifier v = new Verifier(value); - final Token accessToken = service.getAccessToken(requestToken, v); - System.out.println(accessToken); - } + final String value = new Scanner(System.in).nextLine(); + final Verifier v = new Verifier(value); + final Token accessToken = service.getAccessToken(requestToken, v); + System.out.println(accessToken); + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/irc/Bot.java b/src/main/java/fr/imirhil/april/hebdobot/irc/Bot.java index 1d0760a..0759eff 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/irc/Bot.java +++ b/src/main/java/fr/imirhil/april/hebdobot/irc/Bot.java @@ -36,304 +36,325 @@ import fr.imirhil.april.hebdobot.review.Message; import fr.imirhil.april.hebdobot.review.Review; import fr.imirhil.april.hebdobot.review.Topic; -public class Bot extends PircBot { - private abstract class Handler { - public abstract boolean handle(String sender, String message); - } +public class Bot extends PircBot +{ + private abstract class Handler + { + public abstract boolean handle(String sender, String message); + } - private static final Logger LOGGER = LoggerFactory.getLogger(Bot.class); + private static final Logger LOGGER = LoggerFactory.getLogger(Bot.class); - private final String host; - private final int port; - private final String channel; - private Review review = null; - private final Collection listeners = new LinkedList(); - private final List handlers = new LinkedList(); + private final String host; + private final int port; + private final String channel; + private Review review = null; + private final Collection listeners = new LinkedList(); + private final List handlers = new LinkedList(); - public Bot(final String host, final int port, final String name, - final String channel) { - this.host = host; - this.port = port; - this.channel = channel; - this.setName(name); - } + public Bot(final String host, final int port, final String name, final String channel) + { + this.host = host; + this.port = port; + this.channel = channel; + this.setName(name); + } - public void init() throws Exception { - this.connect(this.host, this.port); - this.joinChannel(this.channel); + public void add(final ReviewListener listener) + { + this.listeners.add(listener); + } - this.registerHandlers(); - } + public void close() + { + this.disconnect(); + this.dispose(); + } - private void registerHandlers() { - // Help - this.handlers.add(new Handler() { - @Override - public boolean handle(final String sender, final String message) { - if (!"!help".equalsIgnoreCase(message)) { - return false; - } + public void init() throws Exception + { + this.connect(this.host, this.port); + this.joinChannel(this.channel); - Bot.this.sendMessage(sender, "Bienvenue " + sender); - Bot.this.sendMessage( - sender, - "Je suis " - + Bot.this.getName() - + ", le robot de gestion des revues hebdomadaires de l'APRIL"); - Bot.this.sendMessage(sender, - "Voici les commandes que je comprend :"); - Bot.this.sendMessage(sender, " "); - Bot.this.sendMessage(sender, - "— !debut : commencer une nouvelle revue"); - Bot.this.sendMessage(sender, - "— !fin : terminer la revue en cours"); - Bot.this.sendMessage(sender, - "— # titre : démarrer un sujet individuel"); - Bot.this.sendMessage(sender, - "— ## titre : démarrer un sujet collectif"); - Bot.this.sendMessage(sender, - "— !courant : affiche le sujet en cours"); - Bot.this.sendMessage( - sender, - "— !manquants : affiche les participants qui n'ont pas répondu sur le dernier sujet"); - Bot.this.sendMessage(sender, "— % message : un commentaire"); - return true; - } - }); + this.registerHandlers(); + } - // Die - this.handlers.add(new Handler() { - @Override - public boolean handle(final String sender, final String message) { - if (!"!stop".equalsIgnoreCase(message)) { - return false; - } + @Override + protected void onMessage(final String channel, final String sender, final String login, final String hostname, String message) + { + LOGGER.debug("Message received - channel : {}, sender : {}, message : {}", new Object[] { channel, sender, message }); + if (!channel.equalsIgnoreCase(this.channel)) + { + return; + } - if (Bot.this.review != null) { - Bot.this.sendMessage("% Une revue est en cours, arrêt impossible"); - return false; - } + message = message.trim(); - Context.close(); - return true; - } - }); + for (final Handler handler : this.handlers) + { + if (handler.handle(sender, message)) + { + break; + } + } + } - // Start - this.handlers.add(new Handler() { - @Override - public boolean handle(final String sender, final String message) { - if (!"!debut".equalsIgnoreCase(message)) { - return false; - } + private void registerHandlers() + { + // Help + this.handlers.add(new Handler() + { + @Override + public boolean handle(final String sender, final String message) + { + if (!"!help".equalsIgnoreCase(message)) + { + return false; + } - Bot.this.review = new Review(sender); - Bot.this.sendMessage(sender, - "Vous êtes le conducteur de réunion"); - Bot.this.sendMessage(sender, - "Pour terminer la réunion, tapez \"!fin\""); - Bot.this.sendMessage("% Début de la réunion hebdomadaire"); - Bot.this.sendMessage("% rappel : toute ligne commençant par % sera considérée comme un commentaire et non prise en compte dans la synthèse"); - return true; - } - }); + Bot.this.sendMessage(sender, "Bienvenue " + sender); + Bot.this.sendMessage(sender, "Je suis " + Bot.this.getName() + ", le robot de gestion des revues hebdomadaires de l'APRIL"); + Bot.this.sendMessage(sender, "Voici les commandes que je comprend :"); + Bot.this.sendMessage(sender, " "); + Bot.this.sendMessage(sender, "— !debut : commencer une nouvelle revue"); + Bot.this.sendMessage(sender, "— !fin : terminer la revue en cours"); + Bot.this.sendMessage(sender, "— # titre : démarrer un sujet individuel"); + Bot.this.sendMessage(sender, "— ## titre : démarrer un sujet collectif"); + Bot.this.sendMessage(sender, "— !courant : affiche le sujet en cours"); + Bot.this.sendMessage(sender, "— !manquants : affiche les participants qui n'ont pas répondu sur le dernier sujet"); + Bot.this.sendMessage(sender, "— % message : un commentaire"); + return true; + } + }); - // Stop - this.handlers.add(new Handler() { - @Override - public boolean handle(final String sender, final String message) { - if (Bot.this.review == null - || !"!fin".equalsIgnoreCase(message)) { - return false; - } + // Die + this.handlers.add(new Handler() + { + @Override + public boolean handle(final String sender, final String message) + { + if (!"!stop".equalsIgnoreCase(message)) + { + return false; + } - if (!Bot.this.review.isOwner(sender)) { - Bot.this.sendMessage(sender - + ", vous n'êtes pas le conducteur de la réunion"); - return false; - } + if (Bot.this.review != null) + { + Bot.this.sendMessage("% Une revue est en cours, arrêt impossible"); + return false; + } - for (final ReviewListener listener : Bot.this.listeners) { - listener.onEnd(Bot.this.review); - } + Context.close(); + return true; + } + }); - Bot.this.sendMessage("% " - + Bot.this.review.getOwner() - + ", ne pas oublier d'ajouter le compte-rendu de la revue sur https://agir.april.org/issues/135"); - final String participants = StringUtils.join( - Bot.this.review.getParticipants(), " "); - Bot.this.sendMessage("% " - + participants - + ", pensez à noter votre bénévalo : http://www.april.org/my?action=benevalo"); - Bot.this.sendMessage("% Fin de la revue hebdomadaire"); - Bot.this.review = null; - return true; - } - }); + // Start + this.handlers.add(new Handler() + { + @Override + public boolean handle(final String sender, final String message) + { + if (!"!debut".equalsIgnoreCase(message)) + { + return false; + } - // Collective topic, must be before individual topic - this.handlers.add(new Handler() { - @Override - public boolean handle(final String sender, final String message) { - if (Bot.this.review == null || !message.matches("\\s*##.*")) { - return false; - } + Bot.this.review = new Review(sender); + Bot.this.sendMessage(sender, "Vous êtes le conducteur de réunion"); + Bot.this.sendMessage(sender, "Pour terminer la réunion, tapez \"!fin\""); + Bot.this.sendMessage("% Début de la réunion hebdomadaire"); + Bot.this.sendMessage( + "% rappel : toute ligne commençant par % sera considérée comme un commentaire et non prise en compte dans la synthèse"); + return true; + } + }); - if (!Bot.this.review.isOwner(sender)) { - Bot.this.sendMessage(sender - + ", vous n'êtes pas le conducteur de la réunion"); - return false; - } + // Stop + this.handlers.add(new Handler() + { + @Override + public boolean handle(final String sender, final String message) + { + if (Bot.this.review == null || !"!fin".equalsIgnoreCase(message)) + { + return false; + } - final CollectiveTopic topic = new CollectiveTopic(message - .replaceFirst("##", "").trim()); - Bot.this.review.begin(topic); - Bot.this.sendMessage("Sujet collectif : " + topic.getTitle()); - if (topic.getTitle().toLowerCase().contains("bloquage")) { - Bot.this.sendMessage("% si rien à dire vous pouvez dire %ras"); - } else { - Bot.this.sendMessage("% 1 minute max"); - } - return true; - } - }); + if (!Bot.this.review.isOwner(sender)) + { + Bot.this.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion"); + return false; + } - // Individual topic - this.handlers.add(new Handler() { - @Override - public boolean handle(final String sender, final String message) { - if (Bot.this.review == null || !message.matches("\\s*#[^#].*")) { - return false; - } + for (final ReviewListener listener : Bot.this.listeners) + { + listener.onEnd(Bot.this.review); + } - if (!Bot.this.review.isOwner(sender)) { - Bot.this.sendMessage(sender - + ", vous n'êtes pas le conducteur de la réunion"); - return false; - } + Bot.this.sendMessage("% " + Bot.this.review.getOwner() + + ", ne pas oublier d'ajouter le compte-rendu de la revue sur https://agir.april.org/issues/135"); + final String participants = StringUtils.join(Bot.this.review.getParticipants(), " "); + Bot.this.sendMessage("% " + participants + ", pensez à noter votre bénévalo : http://www.april.org/my?action=benevalo"); + Bot.this.sendMessage("% Fin de la revue hebdomadaire"); + Bot.this.review = null; + return true; + } + }); - final IndividualTopic topic = new IndividualTopic(message - .replaceFirst("#", "").trim()); - Bot.this.review.begin(topic); - Bot.this.sendMessage("Sujet individuel : " + topic.getTitle()); - Bot.this.sendMessage("% quand vous avez fini vous le dites par % fini"); - return true; - } - }); + // Collective topic, must be before individual topic + this.handlers.add(new Handler() + { + @Override + public boolean handle(final String sender, final String message) + { + if (Bot.this.review == null || !message.matches("\\s*##.*")) + { + return false; + } - // Missing - this.handlers.add(new Handler() { - @Override - public boolean handle(final String sender, final String message) { - if (Bot.this.review == null - || !"!manquants".equalsIgnoreCase(message)) { - return false; - } + if (!Bot.this.review.isOwner(sender)) + { + Bot.this.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion"); + return false; + } - final Topic topic = Bot.this.review.getCurrentTopic(); - if (topic == null) { - Bot.this.sendMessage("Aucun sujet traité"); - return true; - } + final CollectiveTopic topic = new CollectiveTopic(message.replaceFirst("##", "").trim()); + Bot.this.review.begin(topic); + Bot.this.sendMessage("Sujet collectif : " + topic.getTitle()); + if (topic.getTitle().toLowerCase().contains("bloquage")) + { + Bot.this.sendMessage("% si rien à dire vous pouvez dire %ras"); + } + else + { + Bot.this.sendMessage("% 1 minute max"); + } + return true; + } + }); - final Collection participants = Bot.this.review - .getParticipants(); - final Collection currentParticipants = topic - .getParticipants(); + // Individual topic + this.handlers.add(new Handler() + { + @Override + public boolean handle(final String sender, final String message) + { + if (Bot.this.review == null || !message.matches("\\s*#[^#].*")) + { + return false; + } - @SuppressWarnings("unchecked") - final Collection missing = CollectionUtils.subtract( - participants, currentParticipants); - if (missing.isEmpty()) { - Bot.this.sendMessage("Aucun participant manquant \\o/"); - return true; - } + if (!Bot.this.review.isOwner(sender)) + { + Bot.this.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion"); + return false; + } - Bot.this.sendMessage(String.format( - "Les participants suivants sont manquants : %1s", - StringUtils.join(missing, ", "))); - return true; - } - }); + final IndividualTopic topic = new IndividualTopic(message.replaceFirst("#", "").trim()); + Bot.this.review.begin(topic); + Bot.this.sendMessage("Sujet individuel : " + topic.getTitle()); + Bot.this.sendMessage("% quand vous avez fini vous le dites par % fini"); + return true; + } + }); - // Current - this.handlers.add(new Handler() { - @Override - public boolean handle(final String sender, final String message) { - if (Bot.this.review == null - || !"!courant".equalsIgnoreCase(message)) { - return false; - } + // Missing + this.handlers.add(new Handler() + { + @Override + public boolean handle(final String sender, final String message) + { + if (Bot.this.review == null || !"!manquants".equalsIgnoreCase(message)) + { + return false; + } - final Topic current = Bot.this.review.getCurrentTopic(); - if (current == null) { - Bot.this.sendMessage("% Pas de sujet en cours"); - } else if (current instanceof IndividualTopic) { - Bot.this.sendMessage("% Sujet individuel en cours : " - + current.getTitle()); - } else if (current instanceof CollectiveTopic) { - Bot.this.sendMessage("% Sujet collectif en cours : " - + current.getTitle()); - } - return true; - } - }); + final Topic topic = Bot.this.review.getCurrentTopic(); + if (topic == null) + { + Bot.this.sendMessage("Aucun sujet traité"); + return true; + } - // Topic message - this.handlers.add(new Handler() { - @Override - public boolean handle(final String sender, final String message) { - if (Bot.this.review == null || message.startsWith("%")) { - return false; - } - Bot.this.review.add(new Message(sender, message)); - return true; - } - }); + final Collection participants = Bot.this.review.getParticipants(); + final Collection currentParticipants = topic.getParticipants(); - // All the other - this.handlers.add(new Handler() { - @Override - public boolean handle(final String sender, final String message) { - if (Bot.this.review == null) { - return false; - } - Bot.this.review.addRaw(new Message(sender, message)); - return true; - } - }); - } + @SuppressWarnings("unchecked") + final Collection missing = CollectionUtils.subtract(participants, currentParticipants); + if (missing.isEmpty()) + { + Bot.this.sendMessage("Aucun participant manquant \\o/"); + return true; + } - public void close() { - this.disconnect(); - this.dispose(); - } + Bot.this.sendMessage(String.format("Les participants suivants sont manquants : %1s", StringUtils.join(missing, ", "))); + return true; + } + }); - public void add(final ReviewListener listener) { - this.listeners.add(listener); - } + // Current + this.handlers.add(new Handler() + { + @Override + public boolean handle(final String sender, final String message) + { + if (Bot.this.review == null || !"!courant".equalsIgnoreCase(message)) + { + return false; + } - @Override - protected void onMessage(final String channel, final String sender, - final String login, final String hostname, String message) { - LOGGER.debug( - "Message received - channel : {}, sender : {}, message : {}", - new Object[] { channel, sender, message }); - if (!channel.equalsIgnoreCase(this.channel)) { - return; - } + final Topic current = Bot.this.review.getCurrentTopic(); + if (current == null) + { + Bot.this.sendMessage("% Pas de sujet en cours"); + } + else if (current instanceof IndividualTopic) + { + Bot.this.sendMessage("% Sujet individuel en cours : " + current.getTitle()); + } + else if (current instanceof CollectiveTopic) + { + Bot.this.sendMessage("% Sujet collectif en cours : " + current.getTitle()); + } + return true; + } + }); - message = message.trim(); + // Topic message + this.handlers.add(new Handler() + { + @Override + public boolean handle(final String sender, final String message) + { + if (Bot.this.review == null || message.startsWith("%")) + { + return false; + } + Bot.this.review.add(new Message(sender, message)); + return true; + } + }); - for (final Handler handler : this.handlers) { - if (handler.handle(sender, message)) { - break; - } - } - } + // All the other + this.handlers.add(new Handler() + { + @Override + public boolean handle(final String sender, final String message) + { + if (Bot.this.review == null) + { + return false; + } + Bot.this.review.addRaw(new Message(sender, message)); + return true; + } + }); + } - public void sendMessage(final String message) { - LOGGER.debug("Send message : {}", message); - this.sendMessage(this.channel, message); - } + public void sendMessage(final String message) + { + LOGGER.debug("Send message : {}", message); + this.sendMessage(this.channel, message); + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/irc/ReviewListener.java b/src/main/java/fr/imirhil/april/hebdobot/irc/ReviewListener.java index 013504d..1041389 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/irc/ReviewListener.java +++ b/src/main/java/fr/imirhil/april/hebdobot/irc/ReviewListener.java @@ -21,6 +21,7 @@ package fr.imirhil.april.hebdobot.irc; import fr.imirhil.april.hebdobot.review.Review; -public interface ReviewListener { - void onEnd(Review review); +public interface ReviewListener +{ + void onEnd(Review review); } diff --git a/src/main/java/fr/imirhil/april/hebdobot/pastebin/Expiration.java b/src/main/java/fr/imirhil/april/hebdobot/pastebin/Expiration.java index 157ad6d..06e4878 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/pastebin/Expiration.java +++ b/src/main/java/fr/imirhil/april/hebdobot/pastebin/Expiration.java @@ -19,16 +19,23 @@ */ package fr.imirhil.april.hebdobot.pastebin; -public enum Expiration { - NEVER(null), MINUTE_10("10M"), HOUR_1("1H"), DAY_1("1D"), MONTH_1("1M"); +public enum Expiration +{ + NEVER(null), + MINUTE_10("10M"), + HOUR_1("1H"), + DAY_1("1D"), + MONTH_1("1M"); - private final String value; + private final String value; - private Expiration(final String value) { - this.value = value; - } + private Expiration(final String value) + { + this.value = value; + } - public String getValue() { - return this.value; - } + public String getValue() + { + return this.value; + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/pastebin/Format.java b/src/main/java/fr/imirhil/april/hebdobot/pastebin/Format.java index 0d1bd69..8e2aa7b 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/pastebin/Format.java +++ b/src/main/java/fr/imirhil/april/hebdobot/pastebin/Format.java @@ -19,16 +19,23 @@ */ package fr.imirhil.april.hebdobot.pastebin; -public enum Format { - NONE(null), C("c"), CPP("cpp"), JAVA("java"), JAVA_5("java5"); +public enum Format +{ + NONE(null), + C("c"), + CPP("cpp"), + JAVA("java"), + JAVA_5("java5"); - private final String value; + private final String value; - private Format(final String value) { - this.value = value; - } + private Format(final String value) + { + this.value = value; + } - public String getValue() { - return this.value; - } + public String getValue() + { + return this.value; + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/pastebin/Option.java b/src/main/java/fr/imirhil/april/hebdobot/pastebin/Option.java index 9bf5fb4..bda96ab 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/pastebin/Option.java +++ b/src/main/java/fr/imirhil/april/hebdobot/pastebin/Option.java @@ -19,16 +19,19 @@ */ package fr.imirhil.april.hebdobot.pastebin; -public enum Option { - PASTE("paste"); +public enum Option +{ + PASTE("paste"); - private final String value; + private final String value; - private Option(final String value) { - this.value = value; - } + private Option(final String value) + { + this.value = value; + } - public String getValue() { - return this.value; - } + public String getValue() + { + return this.value; + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/pastebin/PastebinClient.java b/src/main/java/fr/imirhil/april/hebdobot/pastebin/PastebinClient.java index fe02798..3ac169c 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/pastebin/PastebinClient.java +++ b/src/main/java/fr/imirhil/april/hebdobot/pastebin/PastebinClient.java @@ -32,155 +32,157 @@ import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import org.apache.http.protocol.HTTP; -public class PastebinClient { - private static final String API_DEV_KEY = "api_dev_key"; - private static final String API_USER_KEY = "api_user_key"; - private static final String API_USER_NAME = "api_user_name"; - private static final String API_USER_PASSWORD = "api_user_password"; - private static final String API_OPTION = "api_option"; - private static final String API_PASTE_PRIVATE = "api_paste_private"; - private static final String API_PASTE_NAME = "api_paste_name"; - private static final String API_PASTE_EXPIRATION = "api_paste_expire_date"; - private static final String API_PASTE_FORMAT = "api_paste_format"; - private static final String API_PASTE_CODE = "api_paste_code"; +public class PastebinClient +{ + public static class APIException extends Exception + { + private static final long serialVersionUID = 1L; - private static final String API_ERROR = "Bad API request,"; + private APIException(final String message) + { + super(message); + } - public static class APIException extends Exception { - private static final long serialVersionUID = 1L; + private static void throwIfError(final String content) throws APIException + { + if (content.contains(API_ERROR)) + { + throw new APIException(content.replaceFirst(API_ERROR, "")); + } + } + } - private APIException(final String message) { - super(message); - } + private static final String API_DEV_KEY = "api_dev_key"; + private static final String API_USER_KEY = "api_user_key"; + private static final String API_USER_NAME = "api_user_name"; + private static final String API_USER_PASSWORD = "api_user_password"; + private static final String API_OPTION = "api_option"; + private static final String API_PASTE_PRIVATE = "api_paste_private"; + private static final String API_PASTE_NAME = "api_paste_name"; + private static final String API_PASTE_EXPIRATION = "api_paste_expire_date"; + private static final String API_PASTE_FORMAT = "api_paste_format"; - private static void throwIfError(final String content) - throws APIException { - if (content.contains(API_ERROR)) { - throw new APIException(content.replaceFirst(API_ERROR, "")); - } - } - } + private static final String API_PASTE_CODE = "api_paste_code"; - private final String apiKey; - private String apiUserKey = null; - HttpClient httpClient = new DefaultHttpClient(); + private static final String API_ERROR = "Bad API request,"; - public PastebinClient(final String apiKey) { - this.apiKey = apiKey; - } + private final String apiKey; + private String apiUserKey = null; + HttpClient httpClient = new DefaultHttpClient(); - public void login(final String name, final String password) - throws Exception { - final List params = new LinkedList(); - setParameter(params, API_DEV_KEY, this.apiKey); - setParameter(params, API_USER_NAME, name); - setParameter(params, API_USER_PASSWORD, password); + public PastebinClient(final String apiKey) + { + this.apiKey = apiKey; + } - final HttpPost request = - new HttpPost("http://pastebin.com/api/api_login.php"); - request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); + public void login(final String name, final String password) throws Exception + { + final List params = new LinkedList(); + setParameter(params, API_DEV_KEY, this.apiKey); + setParameter(params, API_USER_NAME, name); + setParameter(params, API_USER_PASSWORD, password); - final HttpResponse response = this.httpClient.execute(request); - final String content = - IOUtils.toString(response.getEntity().getContent()); - APIException.throwIfError(content); - this.apiUserKey = content; - } + final HttpPost request = new HttpPost("http://pastebin.com/api/api_login.php"); + request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); - public String paste(final String code) throws Exception { - return this.paste(code, null, Format.NONE, Private.PUBLIC, - Expiration.DAY_1); - } + final HttpResponse response = this.httpClient.execute(request); + final String content = IOUtils.toString(response.getEntity().getContent()); + APIException.throwIfError(content); + this.apiUserKey = content; + } - public String paste(final String code, final Private privat) - throws Exception { - return this.paste(code, null, Format.NONE, privat, Expiration.DAY_1); - } + public String paste(final String code) throws Exception + { + return this.paste(code, null, Format.NONE, Private.PUBLIC, Expiration.DAY_1); + } - public String paste(final String code, final String name) throws Exception { - return this.paste(code, name, Format.NONE, Private.PUBLIC, - Expiration.DAY_1); - } + public String paste(final String code, final Expiration expiration) throws Exception + { + return this.paste(code, null, Format.NONE, Private.PUBLIC, expiration); + } - public String paste(final String code, final String name, - final Private privat) throws Exception { - return this.paste(code, name, Format.NONE, privat, Expiration.DAY_1); - } + public String paste(final String code, final Format format) throws Exception + { + return this.paste(code, null, format, Private.PUBLIC, Expiration.DAY_1); + } - public String paste(final String code, final String name, - final Format format) throws Exception { - return this.paste(code, name, format, Private.PUBLIC, Expiration.DAY_1); - } + public String paste(final String code, final Format format, final Expiration expiration) throws Exception + { + return this.paste(code, null, format, Private.PUBLIC, expiration); + } - public String paste(final String code, final String name, - final Format format, final Private privat) throws Exception { - return this.paste(code, name, format, privat, Expiration.DAY_1); - } + public String paste(final String code, final Format format, final Private privat) throws Exception + { + return this.paste(code, null, format, privat, Expiration.DAY_1); + } - public String paste(final String code, final Format format) - throws Exception { - return this.paste(code, null, format, Private.PUBLIC, Expiration.DAY_1); - } + public String paste(final String code, final Format format, final Private privat, final Expiration expiration) throws Exception + { + return this.paste(code, null, format, privat, expiration); + } - public String paste(final String code, final Format format, - final Private privat) throws Exception { - return this.paste(code, null, format, privat, Expiration.DAY_1); - } + public String paste(final String code, final Private privat) throws Exception + { + return this.paste(code, null, Format.NONE, privat, Expiration.DAY_1); + } - public String paste(final String code, final Expiration expiration) - throws Exception { - return this.paste(code, null, Format.NONE, Private.PUBLIC, expiration); - } + public String paste(final String code, final Private privat, final Expiration expiration) throws Exception + { + return this.paste(code, null, Format.NONE, privat, expiration); + } - public String paste(final String code, final Private privat, - final Expiration expiration) throws Exception { - return this.paste(code, null, Format.NONE, privat, expiration); - } + public String paste(final String code, final String name) throws Exception + { + return this.paste(code, name, Format.NONE, Private.PUBLIC, Expiration.DAY_1); + } - public String paste(final String code, final Format format, - final Expiration expiration) throws Exception { - return this.paste(code, null, format, Private.PUBLIC, expiration); - } + public String paste(final String code, final String name, final Format format) throws Exception + { + return this.paste(code, name, format, Private.PUBLIC, Expiration.DAY_1); + } - public String paste(final String code, final Format format, - final Private privat, final Expiration expiration) throws Exception { - return this.paste(code, null, format, privat, expiration); - } + public String paste(final String code, final String name, final Format format, final Expiration expiration) throws Exception + { + return this.paste(code, name, format, Private.PUBLIC, expiration); + } - public String paste(final String code, final String name, - final Format format, final Expiration expiration) throws Exception { - return this.paste(code, name, format, Private.PUBLIC, expiration); - } + public String paste(final String code, final String name, final Format format, final Private privat) throws Exception + { + return this.paste(code, name, format, privat, Expiration.DAY_1); + } - public String paste(final String code, final String name, - final Format format, final Private privat, - final Expiration expiration) throws Exception { - final List params = new LinkedList(); - setParameter(params, API_DEV_KEY, this.apiKey); - setParameter(params, API_USER_KEY, this.apiUserKey); - setParameter(params, API_OPTION, Option.PASTE.getValue()); - setParameter(params, API_PASTE_PRIVATE, privat.getValue()); - setParameter(params, API_PASTE_NAME, name); - setParameter(params, API_PASTE_EXPIRATION, expiration.getValue()); - setParameter(params, API_PASTE_FORMAT, format.getValue()); - setParameter(params, API_PASTE_CODE, code); + public String paste(final String code, final String name, final Format format, final Private privat, final Expiration expiration) throws Exception + { + final List params = new LinkedList(); + setParameter(params, API_DEV_KEY, this.apiKey); + setParameter(params, API_USER_KEY, this.apiUserKey); + setParameter(params, API_OPTION, Option.PASTE.getValue()); + setParameter(params, API_PASTE_PRIVATE, privat.getValue()); + setParameter(params, API_PASTE_NAME, name); + setParameter(params, API_PASTE_EXPIRATION, expiration.getValue()); + setParameter(params, API_PASTE_FORMAT, format.getValue()); + setParameter(params, API_PASTE_CODE, code); - final HttpPost request = - new HttpPost("http://pastebin.com/api/api_post.php"); - request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); + final HttpPost request = new HttpPost("http://pastebin.com/api/api_post.php"); + request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); - final HttpResponse response = this.httpClient.execute(request); - final String content = - IOUtils.toString(response.getEntity().getContent()); - APIException.throwIfError(content); - return content; - } + final HttpResponse response = this.httpClient.execute(request); + final String content = IOUtils.toString(response.getEntity().getContent()); + APIException.throwIfError(content); + return content; + } - private static void setParameter(final List params, - final String name, final String value) { - if (value == null) { - return; - } - params.add(new BasicNameValuePair(name, value)); - } + public String paste(final String code, final String name, final Private privat) throws Exception + { + return this.paste(code, name, Format.NONE, privat, Expiration.DAY_1); + } + + private static void setParameter(final List params, final String name, final String value) + { + if (value == null) + { + return; + } + params.add(new BasicNameValuePair(name, value)); + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/pastebin/Private.java b/src/main/java/fr/imirhil/april/hebdobot/pastebin/Private.java index 919ada3..dd8a1f8 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/pastebin/Private.java +++ b/src/main/java/fr/imirhil/april/hebdobot/pastebin/Private.java @@ -19,16 +19,21 @@ */ package fr.imirhil.april.hebdobot.pastebin; -public enum Private { - PUBLIC("0"), UNLISTED("1"), PRIVATE("2"); +public enum Private +{ + PUBLIC("0"), + UNLISTED("1"), + PRIVATE("2"); - private String value; + private String value; - private Private(final String value) { - this.value = value; - } + private Private(final String value) + { + this.value = value; + } - String getValue() { - return this.value; - } + String getValue() + { + return this.value; + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/review/CollectiveTopic.java b/src/main/java/fr/imirhil/april/hebdobot/review/CollectiveTopic.java index c7d9b4e..4f4c36c 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/review/CollectiveTopic.java +++ b/src/main/java/fr/imirhil/april/hebdobot/review/CollectiveTopic.java @@ -24,28 +24,34 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; -public class CollectiveTopic extends Topic { - private final List messages = new LinkedList(); +public class CollectiveTopic extends Topic +{ + private final List messages = new LinkedList(); - public CollectiveTopic(final String title) { - super(title); - } + public CollectiveTopic(final String title) + { + super(title); + } - @Override - public void add(final Message message) { - this.messages.add(message); - } + @Override + public void add(final Message message) + { + this.messages.add(message); + } - @Override - public Set getParticipants() { - final Set participants = new HashSet(); - for (final Message message : this.messages) { - participants.add(message.getAuthor()); - } - return participants; - } + public List getMessages() + { + return this.messages; + } - public List getMessages() { - return this.messages; - } + @Override + public Set getParticipants() + { + final Set participants = new HashSet(); + for (final Message message : this.messages) + { + participants.add(message.getAuthor()); + } + return participants; + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/review/IndividualTopic.java b/src/main/java/fr/imirhil/april/hebdobot/review/IndividualTopic.java index 76e9c5a..c77ad63 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/review/IndividualTopic.java +++ b/src/main/java/fr/imirhil/april/hebdobot/review/IndividualTopic.java @@ -25,33 +25,39 @@ import java.util.List; import java.util.Map; import java.util.Set; -public class IndividualTopic extends Topic { - private final Map> messages = - new HashMap>(); +public class IndividualTopic extends Topic +{ + private final Map> messages = new HashMap>(); - public IndividualTopic(final String title) { - super(title); - } + public IndividualTopic(final String title) + { + super(title); + } - @Override - public void add(final Message message) { - final String author = message.getAuthor(); - if (!this.messages.containsKey(author)) { - this.messages.put(author, new LinkedList()); - } - this.messages.get(author).add(message); - } + @Override + public void add(final Message message) + { + final String author = message.getAuthor(); + if (!this.messages.containsKey(author)) + { + this.messages.put(author, new LinkedList()); + } + this.messages.get(author).add(message); + } - @Override - public Set getParticipants() { - return this.messages.keySet(); - } + public List getMessages(final String author) + { + return this.messages.get(author); + } - public List getMessages(final String author) { - return this.messages.get(author); - } + @Override + public Set getParticipants() + { + return this.messages.keySet(); + } - public boolean hasParticipant(final String participant) { - return this.messages.containsKey(participant); - } + public boolean hasParticipant(final String participant) + { + return this.messages.containsKey(participant); + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/review/Message.java b/src/main/java/fr/imirhil/april/hebdobot/review/Message.java index 09ea9ee..c6db78d 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/review/Message.java +++ b/src/main/java/fr/imirhil/april/hebdobot/review/Message.java @@ -21,25 +21,30 @@ package fr.imirhil.april.hebdobot.review; import org.joda.time.DateTime; -public class Message { - private final DateTime date = new DateTime(); - private final String author; - private final String content; +public class Message +{ + private final DateTime date = new DateTime(); + private final String author; + private final String content; - public Message(final String author, final String content) { - this.author = author; - this.content = content; - } + public Message(final String author, final String content) + { + this.author = author; + this.content = content; + } - public DateTime getDate() { - return this.date; - } + public String getAuthor() + { + return this.author; + } - public String getAuthor() { - return this.author; - } + public String getContent() + { + return this.content; + } - public String getContent() { - return this.content; - } + public DateTime getDate() + { + return this.date; + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/review/Review.java b/src/main/java/fr/imirhil/april/hebdobot/review/Review.java index 381055e..05d8c43 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/review/Review.java +++ b/src/main/java/fr/imirhil/april/hebdobot/review/Review.java @@ -32,204 +32,237 @@ import org.joda.time.format.DateTimeFormat; import fr.imirhil.april.hebdobot.Context; import fr.imirhil.april.hebdobot.xml.UserAlias; -public class Review { - private static final int LENGTH = 80; +public class Review +{ + private static final int LENGTH = 80; - private static final UserAlias USER_ALIAS = Context - .getBean(UserAlias.class); - private final Set participants = new HashSet(); - private final List individualTopics = - new LinkedList(); - private final List collectiveTopics = - new LinkedList(); - private Topic currentTopic; - private final List messages = new LinkedList(); - private final String owner; + private static final UserAlias USER_ALIAS = Context.getBean(UserAlias.class); + private final Set participants = new HashSet(); + private final List individualTopics = new LinkedList(); + private final List collectiveTopics = new LinkedList(); + private Topic currentTopic; + private final List messages = new LinkedList(); + private final String owner; - public String getOwner() { - return this.owner; - } + public Review(final String owner) + { + this.owner = owner; + } - public boolean isOwner(final String name) { - return this.owner.equalsIgnoreCase(name); - } + public void add(final Message message) + { + if (this.currentTopic != null) + { + this.participants.add(message.getAuthor()); + this.currentTopic.add(message); + } + this.addRaw(message); + } - public Review(final String owner) { - this.owner = owner; - } + public void addRaw(final Message message) + { + this.messages.add(message); + } - public Topic getCurrentTopic() { - return this.currentTopic; - } + public void begin(final CollectiveTopic topic) + { + this.collectiveTopics.add(topic); + this.currentTopic = topic; + } - public void begin(final IndividualTopic topic) { - this.individualTopics.add(topic); - this.currentTopic = topic; - } + public void begin(final IndividualTopic topic) + { + this.individualTopics.add(topic); + this.currentTopic = topic; + } - public void begin(final CollectiveTopic topic) { - this.collectiveTopics.add(topic); - this.currentTopic = topic; - } + public Topic getCurrentTopic() + { + return this.currentTopic; + } - public void add(final Message message) { - if (this.currentTopic != null) { - this.participants.add(message.getAuthor()); - this.currentTopic.add(message); - } - this.addRaw(message); - } + public String getOwner() + { + return this.owner; + } - public void addRaw(final Message message) { - this.messages.add(message); - } + public Collection getParticipants() + { + final Collection reviewers = new HashSet(); + for (final Topic topic : this.individualTopics) + { + reviewers.addAll(topic.getParticipants()); + } + for (final Topic topic : this.collectiveTopics) + { + reviewers.addAll(topic.getParticipants()); + } + return reviewers; + } - @Override - public String toString() { - final StringBuffer buffer = new StringBuffer(); - addLine(buffer, '='); - addCenter(buffer, "Revue de la semaine en cours"); - addEmpty(buffer); - addCenter(buffer, DateTimeFormat.fullDate().print(new DateTime())); - addLine(buffer, '='); - addEmpty(buffer); - addEmpty(buffer); + public boolean isOwner(final String name) + { + return this.owner.equalsIgnoreCase(name); + } - addLine(buffer, '='); - addEmpty(buffer); - addCenter(buffer, "Participants", '-'); - for (final String participant : this.participants) { - addChunk(buffer, "* " + USER_ALIAS.getRealName(participant) + "\n"); - } + @Override + public String toString() + { + final StringBuffer buffer = new StringBuffer(); + addLine(buffer, '='); + addCenter(buffer, "Revue de la semaine en cours"); + addEmpty(buffer); + addCenter(buffer, DateTimeFormat.fullDate().print(new DateTime())); + addLine(buffer, '='); + addEmpty(buffer); + addEmpty(buffer); - if (!this.individualTopics.isEmpty()) { - for (final String participant : this.participants) { - addEmpty(buffer); - addLine(buffer, '='); - addEmpty(buffer); - addCenter(buffer, USER_ALIAS.getRealName(participant), '-'); - for (final IndividualTopic topic : this.individualTopics) { - if (topic.hasParticipant(participant)) { - addEmpty(buffer); - add(buffer, getTopic(topic)); - addEmpty(buffer); - for (final Message message : topic - .getMessages(participant)) { - addChunk(buffer, "* " + message.getContent() + "\n"); - } - } - } - } - } + addLine(buffer, '='); + addEmpty(buffer); + addCenter(buffer, "Participants", '-'); + for (final String participant : this.participants) + { + addChunk(buffer, "* " + USER_ALIAS.getRealName(participant) + "\n"); + } - if (!this.collectiveTopics.isEmpty()) { - for (final CollectiveTopic topic : this.collectiveTopics) { - addEmpty(buffer); - addLine(buffer, '='); - addCenter(buffer, topic.getTitle()); - addLine(buffer, '='); - addEmpty(buffer); - for (final Message message : topic.getMessages()) { - addChunk(buffer, "* " + message.getAuthor() + " : " - + message.getContent() + "\n"); - } - } - } + if (!this.individualTopics.isEmpty()) + { + for (final String participant : this.participants) + { + addEmpty(buffer); + addLine(buffer, '='); + addEmpty(buffer); + addCenter(buffer, USER_ALIAS.getRealName(participant), '-'); + for (final IndividualTopic topic : this.individualTopics) + { + if (topic.hasParticipant(participant)) + { + addEmpty(buffer); + add(buffer, getTopic(topic)); + addEmpty(buffer); + for (final Message message : topic.getMessages(participant)) + { + addChunk(buffer, "* " + message.getContent() + "\n"); + } + } + } + } + } - addEmpty(buffer); - addCenter(buffer, "Log IRC brut"); - addEmpty(buffer); - for (final Message message : this.messages) { - addChunk(buffer, - "* " + message.getAuthor() + " : " + message.getContent() - + "\n"); - } + if (!this.collectiveTopics.isEmpty()) + { + for (final CollectiveTopic topic : this.collectiveTopics) + { + addEmpty(buffer); + addLine(buffer, '='); + addCenter(buffer, topic.getTitle()); + addLine(buffer, '='); + addEmpty(buffer); + for (final Message message : topic.getMessages()) + { + addChunk(buffer, "* " + message.getAuthor() + " : " + message.getContent() + "\n"); + } + } + } - return buffer.toString(); - } + addEmpty(buffer); + addCenter(buffer, "Log IRC brut"); + addEmpty(buffer); + for (final Message message : this.messages) + { + addChunk(buffer, "* " + message.getAuthor() + " : " + message.getContent() + "\n"); + } - private static String getLine(final Character c) { - return StringUtils.repeat(c.toString(), LENGTH) + "\n"; - } + return buffer.toString(); + } - private static String getLine(final String content, final char c) { - return StringUtils.center(" " + content + " ", LENGTH, c) + "\n"; - } + private static void add(final StringBuffer buffer, final String content) + { + buffer.append(content); + } - private static String getTopic(final Topic topic) { - return "=== " + topic.getTitle() + " ===\n"; - } + private static void addCenter(final StringBuffer buffer, final String content) + { + addCenter(buffer, content, ' '); + } - private static void addCenter(final StringBuffer buffer, - final String content, final char c) { - buffer.append(getLine(content, c)); - } + private static void addCenter(final StringBuffer buffer, final String content, final char c) + { + buffer.append(getLine(content, c)); + } - private static void addCenter(final StringBuffer buffer, - final String content) { - addCenter(buffer, content, ' '); - } + private static void addChunk(final StringBuffer buffer, final String content) + { + add(buffer, chunk(content)); + } - private static void addLine(final StringBuffer buffer, final char c) { - buffer.append(getLine(c)); - } + private static void addEmpty(final StringBuffer buffer) + { + buffer.append("\n"); + } - private static void addEmpty(final StringBuffer buffer) { - buffer.append("\n"); - } + private static void addLine(final StringBuffer buffer, final char c) + { + buffer.append(getLine(c)); + } - private static String chunk(final String content, final int length) { - final String[] words = content.split(" "); - final StringBuffer result = new StringBuffer(); - StringBuffer current = new StringBuffer(); + private static String chunk(final String content) + { + return chunk(content, LENGTH); + } - for (final String word : words) { - if (current.length() + word.length() > length) { - if (result.length() > 0) { - result.append("\n"); - } - result.append(current); - current = new StringBuffer(word); - } else { - if (current.length() > 0) { - current.append(" "); - } - current.append(word); - } - } + private static String chunk(final String content, final int length) + { + final String[] words = content.split(" "); + final StringBuffer result = new StringBuffer(); + StringBuffer current = new StringBuffer(); - if (current.length() > 0) { - if (result.length() > 0) { - result.append("\n"); - } - result.append(current); - } + for (final String word : words) + { + if (current.length() + word.length() > length) + { + if (result.length() > 0) + { + result.append("\n"); + } + result.append(current); + current = new StringBuffer(word); + } + else + { + if (current.length() > 0) + { + current.append(" "); + } + current.append(word); + } + } - return result.toString(); - } + if (current.length() > 0) + { + if (result.length() > 0) + { + result.append("\n"); + } + result.append(current); + } - private static void add(final StringBuffer buffer, final String content) { - buffer.append(content); - } + return result.toString(); + } - private static String chunk(final String content) { - return chunk(content, LENGTH); - } + private static String getLine(final Character c) + { + return StringUtils.repeat(c.toString(), LENGTH) + "\n"; + } - private static void - addChunk(final StringBuffer buffer, final String content) { - add(buffer, chunk(content)); - } + private static String getLine(final String content, final char c) + { + return StringUtils.center(" " + content + " ", LENGTH, c) + "\n"; + } - public Collection getParticipants() { - final Collection reviewers = new HashSet(); - for (final Topic topic : this.individualTopics) { - reviewers.addAll(topic.getParticipants()); - } - for (final Topic topic : this.collectiveTopics) { - reviewers.addAll(topic.getParticipants()); - } - return reviewers; - } + private static String getTopic(final Topic topic) + { + return "=== " + topic.getTitle() + " ===\n"; + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/review/Topic.java b/src/main/java/fr/imirhil/april/hebdobot/review/Topic.java index 030dfe4..33f7b37 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/review/Topic.java +++ b/src/main/java/fr/imirhil/april/hebdobot/review/Topic.java @@ -21,18 +21,21 @@ package fr.imirhil.april.hebdobot.review; import java.util.Set; -public abstract class Topic { - private final String title; +public abstract class Topic +{ + private final String title; - protected Topic(final String title) { - this.title = title; - } + protected Topic(final String title) + { + this.title = title; + } - public String getTitle() { - return this.title; - } + public abstract void add(Message message); - public abstract void add(Message message); + public abstract Set getParticipants(); - public abstract Set getParticipants(); + public String getTitle() + { + return this.title; + } } diff --git a/src/main/java/fr/imirhil/april/hebdobot/xml/UserAlias.java b/src/main/java/fr/imirhil/april/hebdobot/xml/UserAlias.java index efdb369..4a044f1 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/xml/UserAlias.java +++ b/src/main/java/fr/imirhil/april/hebdobot/xml/UserAlias.java @@ -31,44 +31,51 @@ import javax.xml.bind.Unmarshaller; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.SchemaFactory; +import org.jibble.pircbot.User; import org.xml.sax.SAXException; -public class UserAlias { - private final Map aliases = new HashMap(); +public class UserAlias +{ + private final Map aliases = new HashMap(); - public UserAlias(final InputStream source) { - try { - final Unmarshaller u = - JAXBContext.newInstance(Users.class).createUnmarshaller(); - u.setSchema(SchemaFactory - .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) - .newSchema( - UserAlias.class - .getResource("/fr/imirhil/april/hebdobot/users.xsd"))); + public UserAlias(final InputStream source) + { + try + { + final Unmarshaller u = JAXBContext.newInstance(Users.class).createUnmarshaller(); + u.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) + .newSchema(UserAlias.class.getResource("/fr/imirhil/april/hebdobot/users.xsd"))); - for (final User user : u - .unmarshal(new StreamSource(source), Users.class) - .getValue().getUser()) { - final String realName = user.getRealName(); - for (final String nick : user.getNick()) { - this.aliases.put(nick, realName); - } - } - } catch (final SAXException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } catch (final JAXBException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } + for (final User user : u.unmarshal(new StreamSource(source), Users.class).getValue().getUser()) + { + final String realName = user.getRealName(); + for (final String nick : user.getNick()) + { + this.aliases.put(nick, realName); + } + } + } + catch (final SAXException e) + { + e.printStackTrace(); + throw new RuntimeException(e); + } + catch (final JAXBException e) + { + e.printStackTrace(); + throw new RuntimeException(e); + } + } - public String getRealName(final String nick) { - for (final Entry entry : this.aliases.entrySet()) { - if (nick.toLowerCase().contains(entry.getKey().toLowerCase())) { - return entry.getValue() + " ( " + nick + " )"; - } - } - return nick; - } + public String getRealName(final String nick) + { + for (final Entry entry : this.aliases.entrySet()) + { + if (nick.toLowerCase().contains(entry.getKey().toLowerCase())) + { + return entry.getValue() + " ( " + nick + " )"; + } + } + return nick; + } } diff --git a/src/test/java/fr/imirhil/april/hebdobot/irc/BotTest.java b/src/test/java/fr/imirhil/april/hebdobot/irc/BotTest.java index 83dcd77..c77fdd4 100644 --- a/src/test/java/fr/imirhil/april/hebdobot/irc/BotTest.java +++ b/src/test/java/fr/imirhil/april/hebdobot/irc/BotTest.java @@ -40,66 +40,82 @@ import fr.imirhil.april.hebdobot.review.Review; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/fr/imirhil/april/hebdobot/conf.xml") -public class BotTest implements ReviewListener { - private static class BotMock extends Bot { - public BotMock() throws Exception { - super("", 0, "bot", "channel"); - } +public class BotTest implements ReviewListener +{ + private static class BotMock extends Bot + { + public BotMock() throws Exception + { + super("", 0, "bot", "channel"); + } - @Override - public void onMessage(final String channel, final String sender, - final String login, final String hostname, final String message) { - super.onMessage(channel, sender, login, hostname, message); - } - } + @Override + public void onMessage(final String channel, final String sender, final String login, final String hostname, final String message) + { + super.onMessage(channel, sender, login, hostname, message); + } + } - @Test - public void redo() throws Exception { - final Bot bot = new BotMock(); - bot.add(this); + @Override + public void onEnd(final Review review) + { + try + { + final String date = ISODateTimeFormat.basicDate().print(new DateTime()); + final String text = review.toString(); + final File file = new File("target/" + date + "_revue.txt"); + FileUtils.writeStringToFile(file, text); + } + catch (final IOException e) + { + throw new RuntimeException(e); + } + } - final InputStream is = BotTest.class - .getResourceAsStream("/fr/imirhil/april/hebdobot/review.log"); - if (is == null) { - return; - } - try { - final Reader isr = new InputStreamReader(is); - try { - final BufferedReader isbr = new BufferedReader(isr); - try { - String line; - final Pattern pattern = Pattern - .compile(".*\\s+<([^>]+)>\\s+(.*)"); - while ((line = isbr.readLine()) != null) { - final Matcher matcher = pattern.matcher(line); - if (matcher.matches()) { - bot.onMessage("channel", matcher.group(1), "", "", - matcher.group(2)); - } - } - } finally { - isbr.close(); - } + @Test + public void redo() throws Exception + { + final Bot bot = new BotMock(); + bot.add(this); - } finally { - isr.close(); - } - } finally { - is.close(); - } - } + final InputStream is = BotTest.class.getResourceAsStream("/fr/imirhil/april/hebdobot/review.log"); + if (is == null) + { + return; + } + try + { + final Reader isr = new InputStreamReader(is); + try + { + final BufferedReader isbr = new BufferedReader(isr); + try + { + String line; + final Pattern pattern = Pattern.compile(".*\\s+<([^>]+)>\\s+(.*)"); + while ((line = isbr.readLine()) != null) + { + final Matcher matcher = pattern.matcher(line); + if (matcher.matches()) + { + bot.onMessage("channel", matcher.group(1), "", "", matcher.group(2)); + } + } + } + finally + { + isbr.close(); + } - @Override - public void onEnd(final Review review) { - try { - final String date = ISODateTimeFormat.basicDate().print( - new DateTime()); - final String text = review.toString(); - final File file = new File("target/" + date + "_revue.txt"); - FileUtils.writeStringToFile(file, text); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } + } + finally + { + isr.close(); + } + } + finally + { + is.close(); + } + } } diff --git a/src/test/java/fr/imirhil/april/hebdobot/pastebin/PastebinClientTest.java b/src/test/java/fr/imirhil/april/hebdobot/pastebin/PastebinClientTest.java index f6c5b22..7dcd750 100644 --- a/src/test/java/fr/imirhil/april/hebdobot/pastebin/PastebinClientTest.java +++ b/src/test/java/fr/imirhil/april/hebdobot/pastebin/PastebinClientTest.java @@ -21,12 +21,13 @@ package fr.imirhil.april.hebdobot.pastebin; import org.junit.Test; -public class PastebinClientTest { - private final PastebinClient client = new PastebinClient( - "b95ea42d539ec9dca02a7da1f5b229c7"); +public class PastebinClientTest +{ + private final PastebinClient client = new PastebinClient("b95ea42d539ec9dca02a7da1f5b229c7"); - @Test - public void testPaste() throws Exception { - System.out.println(this.client.paste("ééé", Expiration.MINUTE_10)); - } + @Test + public void testPaste() throws Exception + { + System.out.println(this.client.paste("ééé", Expiration.MINUTE_10)); + } }