Set formatter and save actions settings and applied it.

This commit is contained in:
Christian P. MOMON 2017-12-14 15:37:29 +01:00
parent 66ca08fbf9
commit 2465b8ced2
21 changed files with 1413 additions and 868 deletions

View File

@ -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.compliance=1.6
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6 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

View File

@ -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

View File

@ -35,50 +35,53 @@ import fr.imirhil.april.hebdobot.pastebin.PastebinClient;
import fr.imirhil.april.hebdobot.pastebin.Private; import fr.imirhil.april.hebdobot.pastebin.Private;
import fr.imirhil.april.hebdobot.review.Review; import fr.imirhil.april.hebdobot.review.Review;
public class Application implements ReviewListener { public class Application implements ReviewListener
private static final Logger LOGGER = LoggerFactory {
.getLogger(Application.class); 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 Properties properties = Context.getBean("properties");
private final Bot bot = Context.getBean(Bot.class); private final Bot bot = Context.getBean(Bot.class);
private final PastebinClient pastebinClient = Context private final PastebinClient pastebinClient = Context.getBean(PastebinClient.class);
.getBean(PastebinClient.class);
private Application() throws Exception { private Application() throws Exception
{
this.bot.add(this); this.bot.add(this);
} }
@Override @Override
public void onEnd(final Review review) { public void onEnd(final Review review)
{
final String date = ISODateTimeFormat.basicDate().print(new DateTime()); final String date = ISODateTimeFormat.basicDate().print(new DateTime());
final String text = review.toString(); final String text = review.toString();
try { try
this.bot.sendMessage("% Compte-rendu de la revue : " {
+ this.pastebinClient.paste(text, "Revue APRIL " + date, this.bot.sendMessage("% Compte-rendu de la revue : " + this.pastebinClient.paste(text, "Revue APRIL " + date, Private.UNLISTED));
Private.UNLISTED)); }
} catch (final Exception e) { catch (final Exception e)
{
LOGGER.error("Error during Pastebin submit", e); LOGGER.error("Error during Pastebin submit", e);
} }
if (this.properties.containsKey(FILE_SUFFIX)) { if (this.properties.containsKey(FILE_SUFFIX))
try { {
final File file = try
new File(date + "_" {
+ this.properties.getProperty(FILE_SUFFIX)); final File file = new File(date + "_" + this.properties.getProperty(FILE_SUFFIX));
FileUtils.writeStringToFile(file, text); FileUtils.writeStringToFile(file, text);
this.bot.sendMessage("% Compte-rendu de la revue : " this.bot.sendMessage("% Compte-rendu de la revue : " + file.getName());
+ file.getName()); }
} catch (final Exception e) { catch (final Exception e)
{
LOGGER.error("Error during file generation", e); LOGGER.error("Error during file generation", e);
} }
} }
} }
public static void main(final String[] args) throws Exception { public static void main(final String[] args) throws Exception
new FileSystemXmlApplicationContext(System.getProperty("spring.conf", {
"conf.xml")).registerShutdownHook(); new FileSystemXmlApplicationContext(System.getProperty("spring.conf", "conf.xml")).registerShutdownHook();
new Application(); new Application();
} }
} }

View File

@ -26,27 +26,32 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public final class Context implements ApplicationContextAware { public final class Context implements ApplicationContextAware
{
private static ApplicationContext CONTEXT; private static ApplicationContext CONTEXT;
@Override @Override
public void setApplicationContext( public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException
final ApplicationContext applicationContext) throws BeansException { {
CONTEXT = applicationContext; CONTEXT = applicationContext;
} }
public static <T> T getBean(final Class<T> clazz) { public static void close()
{
if (CONTEXT instanceof ConfigurableApplicationContext)
{
((ConfigurableApplicationContext) CONTEXT).close();
}
}
public static <T> T getBean(final Class<T> clazz)
{
return CONTEXT.getBean(clazz); return CONTEXT.getBean(clazz);
} }
public static void close() {
if (CONTEXT instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext)CONTEXT).close();
}
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> T getBean(final String name) { public static <T> T getBean(final String name)
{
return (T) CONTEXT.getBean(name); return (T) CONTEXT.getBean(name);
} }

View File

@ -25,7 +25,8 @@ import org.springframework.social.twitter.api.impl.TwitterTemplate;
import fr.imirhil.april.hebdobot.irc.Bot; import fr.imirhil.april.hebdobot.irc.Bot;
public class Job { public class Job
{
@Resource @Resource
private Bot bot; private Bot bot;
@Resource @Resource
@ -33,29 +34,35 @@ public class Job {
private String tweet; private String tweet;
private String irc; private String irc;
public void setTweet(final String message) { public void at30()
this.tweet = message; {
this.notify(30);
} }
public void setIrc(final String message) { public void at45()
this.irc = message; {
this.notify(15);
} }
private void notify(final int min) { public void at55()
{
this.notify(5);
}
private void notify(final int min)
{
this.bot.sendMessage(String.format(this.irc, min)); this.bot.sendMessage(String.format(this.irc, min));
final String tweet = String.format(this.tweet, min); final String tweet = String.format(this.tweet, min);
this.twitterClient.timelineOperations().updateStatus(tweet); this.twitterClient.timelineOperations().updateStatus(tweet);
} }
public void at30() { public void setIrc(final String message)
this.notify(30); {
this.irc = message;
} }
public void at45() { public void setTweet(final String message)
this.notify(15); {
} this.tweet = message;
public void at55() {
this.notify(5);
} }
} }

View File

@ -27,15 +27,12 @@ import org.scribe.model.Token;
import org.scribe.model.Verifier; import org.scribe.model.Verifier;
import org.scribe.oauth.OAuthService; import org.scribe.oauth.OAuthService;
public class OAuthRegistration { public class OAuthRegistration
public static void main(final String args[]) throws Exception { {
final OAuthService service = public static void main(final String args[]) throws Exception
new ServiceBuilder() {
.provider(TwitterApi.class) final OAuthService service = new ServiceBuilder().provider(TwitterApi.class).apiKey("uCZMXbUWuda7a2RqqKd2yg")
.apiKey("uCZMXbUWuda7a2RqqKd2yg") .apiSecret("KUH2O77u5RJfqZ2rE8qV6Ak1HBKQRg70DUIVAXDr6oo").build();
.apiSecret(
"KUH2O77u5RJfqZ2rE8qV6Ak1HBKQRg70DUIVAXDr6oo")
.build();
final Token requestToken = service.getRequestToken(); final Token requestToken = service.getRequestToken();
final String authUrl = service.getAuthorizationUrl(requestToken); final String authUrl = service.getAuthorizationUrl(requestToken);
System.out.println(authUrl); System.out.println(authUrl);

View File

@ -36,8 +36,10 @@ import fr.imirhil.april.hebdobot.review.Message;
import fr.imirhil.april.hebdobot.review.Review; import fr.imirhil.april.hebdobot.review.Review;
import fr.imirhil.april.hebdobot.review.Topic; import fr.imirhil.april.hebdobot.review.Topic;
public class Bot extends PircBot { public class Bot extends PircBot
private abstract class Handler { {
private abstract class Handler
{
public abstract boolean handle(String sender, String message); public abstract boolean handle(String sender, String message);
} }
@ -50,66 +52,94 @@ public class Bot extends PircBot {
private final Collection<ReviewListener> listeners = new LinkedList<ReviewListener>(); private final Collection<ReviewListener> listeners = new LinkedList<ReviewListener>();
private final List<Handler> handlers = new LinkedList<Handler>(); private final List<Handler> handlers = new LinkedList<Handler>();
public Bot(final String host, final int port, final String name, public Bot(final String host, final int port, final String name, final String channel)
final String channel) { {
this.host = host; this.host = host;
this.port = port; this.port = port;
this.channel = channel; this.channel = channel;
this.setName(name); this.setName(name);
} }
public void init() throws Exception { public void add(final ReviewListener listener)
{
this.listeners.add(listener);
}
public void close()
{
this.disconnect();
this.dispose();
}
public void init() throws Exception
{
this.connect(this.host, this.port); this.connect(this.host, this.port);
this.joinChannel(this.channel); this.joinChannel(this.channel);
this.registerHandlers(); this.registerHandlers();
} }
private void registerHandlers() {
// Help
this.handlers.add(new Handler() {
@Override @Override
public boolean handle(final String sender, final String message) { protected void onMessage(final String channel, final String sender, final String login, final String hostname, String message)
if (!"!help".equalsIgnoreCase(message)) { {
LOGGER.debug("Message received - channel : {}, sender : {}, message : {}", new Object[] { channel, sender, message });
if (!channel.equalsIgnoreCase(this.channel))
{
return;
}
message = message.trim();
for (final Handler handler : this.handlers)
{
if (handler.handle(sender, message))
{
break;
}
}
}
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; return false;
} }
Bot.this.sendMessage(sender, "Bienvenue " + sender); Bot.this.sendMessage(sender, "Bienvenue " + sender);
Bot.this.sendMessage( Bot.this.sendMessage(sender, "Je suis " + Bot.this.getName() + ", le robot de gestion des revues hebdomadaires de l'APRIL");
sender, Bot.this.sendMessage(sender, "Voici les commandes que je comprend :");
"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, " ");
Bot.this.sendMessage(sender, Bot.this.sendMessage(sender, "— !debut : commencer une nouvelle revue");
"— !debut : commencer une nouvelle revue"); Bot.this.sendMessage(sender, "— !fin : terminer la revue en cours");
Bot.this.sendMessage(sender, Bot.this.sendMessage(sender, "— # titre : démarrer un sujet individuel");
"— !fin : terminer la revue en cours"); Bot.this.sendMessage(sender, "— ## titre : démarrer un sujet collectif");
Bot.this.sendMessage(sender, Bot.this.sendMessage(sender, "— !courant : affiche le sujet en cours");
"— # titre : démarrer un sujet individuel"); Bot.this.sendMessage(sender, "— !manquants : affiche les participants qui n'ont pas répondu sur le dernier sujet");
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"); Bot.this.sendMessage(sender, "— % message : un commentaire");
return true; return true;
} }
}); });
// Die // Die
this.handlers.add(new Handler() { this.handlers.add(new Handler()
{
@Override @Override
public boolean handle(final String sender, final String message) { public boolean handle(final String sender, final String message)
if (!"!stop".equalsIgnoreCase(message)) { {
if (!"!stop".equalsIgnoreCase(message))
{
return false; return false;
} }
if (Bot.this.review != null) { if (Bot.this.review != null)
{
Bot.this.sendMessage("% Une revue est en cours, arrêt impossible"); Bot.this.sendMessage("% Une revue est en cours, arrêt impossible");
return false; return false;
} }
@ -120,51 +150,52 @@ public class Bot extends PircBot {
}); });
// Start // Start
this.handlers.add(new Handler() { this.handlers.add(new Handler()
{
@Override @Override
public boolean handle(final String sender, final String message) { public boolean handle(final String sender, final String message)
if (!"!debut".equalsIgnoreCase(message)) { {
if (!"!debut".equalsIgnoreCase(message))
{
return false; return false;
} }
Bot.this.review = new Review(sender); Bot.this.review = new Review(sender);
Bot.this.sendMessage(sender, Bot.this.sendMessage(sender, "Vous êtes le conducteur de réunion");
"Vous êtes le conducteur de réunion"); Bot.this.sendMessage(sender, "Pour terminer la réunion, tapez \"!fin\"");
Bot.this.sendMessage(sender,
"Pour terminer la réunion, tapez \"!fin\"");
Bot.this.sendMessage("% Début de la réunion hebdomadaire"); 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"); 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; return true;
} }
}); });
// Stop // Stop
this.handlers.add(new Handler() { this.handlers.add(new Handler()
{
@Override @Override
public boolean handle(final String sender, final String message) { public boolean handle(final String sender, final String message)
if (Bot.this.review == null {
|| !"!fin".equalsIgnoreCase(message)) { if (Bot.this.review == null || !"!fin".equalsIgnoreCase(message))
{
return false; return false;
} }
if (!Bot.this.review.isOwner(sender)) { if (!Bot.this.review.isOwner(sender))
Bot.this.sendMessage(sender {
+ ", vous n'êtes pas le conducteur de la réunion"); Bot.this.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
return false; return false;
} }
for (final ReviewListener listener : Bot.this.listeners) { for (final ReviewListener listener : Bot.this.listeners)
{
listener.onEnd(Bot.this.review); listener.onEnd(Bot.this.review);
} }
Bot.this.sendMessage("% " Bot.this.sendMessage("% " + Bot.this.review.getOwner()
+ Bot.this.review.getOwner()
+ ", ne pas oublier d'ajouter le compte-rendu de la revue sur https://agir.april.org/issues/135"); + ", ne pas oublier d'ajouter le compte-rendu de la revue sur https://agir.april.org/issues/135");
final String participants = StringUtils.join( final String participants = StringUtils.join(Bot.this.review.getParticipants(), " ");
Bot.this.review.getParticipants(), " "); Bot.this.sendMessage("% " + participants + ", pensez à noter votre bénévalo : http://www.april.org/my?action=benevalo");
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.sendMessage("% Fin de la revue hebdomadaire");
Bot.this.review = null; Bot.this.review = null;
return true; return true;
@ -172,26 +203,31 @@ public class Bot extends PircBot {
}); });
// Collective topic, must be before individual topic // Collective topic, must be before individual topic
this.handlers.add(new Handler() { this.handlers.add(new Handler()
{
@Override @Override
public boolean handle(final String sender, final String message) { public boolean handle(final String sender, final String message)
if (Bot.this.review == null || !message.matches("\\s*##.*")) { {
if (Bot.this.review == null || !message.matches("\\s*##.*"))
{
return false; return false;
} }
if (!Bot.this.review.isOwner(sender)) { if (!Bot.this.review.isOwner(sender))
Bot.this.sendMessage(sender {
+ ", vous n'êtes pas le conducteur de la réunion"); Bot.this.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
return false; return false;
} }
final CollectiveTopic topic = new CollectiveTopic(message final CollectiveTopic topic = new CollectiveTopic(message.replaceFirst("##", "").trim());
.replaceFirst("##", "").trim());
Bot.this.review.begin(topic); Bot.this.review.begin(topic);
Bot.this.sendMessage("Sujet collectif : " + topic.getTitle()); Bot.this.sendMessage("Sujet collectif : " + topic.getTitle());
if (topic.getTitle().toLowerCase().contains("bloquage")) { if (topic.getTitle().toLowerCase().contains("bloquage"))
{
Bot.this.sendMessage("% si rien à dire vous pouvez dire %ras"); Bot.this.sendMessage("% si rien à dire vous pouvez dire %ras");
} else { }
else
{
Bot.this.sendMessage("% 1 minute max"); Bot.this.sendMessage("% 1 minute max");
} }
return true; return true;
@ -199,21 +235,23 @@ public class Bot extends PircBot {
}); });
// Individual topic // Individual topic
this.handlers.add(new Handler() { this.handlers.add(new Handler()
{
@Override @Override
public boolean handle(final String sender, final String message) { public boolean handle(final String sender, final String message)
if (Bot.this.review == null || !message.matches("\\s*#[^#].*")) { {
if (Bot.this.review == null || !message.matches("\\s*#[^#].*"))
{
return false; return false;
} }
if (!Bot.this.review.isOwner(sender)) { if (!Bot.this.review.isOwner(sender))
Bot.this.sendMessage(sender {
+ ", vous n'êtes pas le conducteur de la réunion"); Bot.this.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
return false; return false;
} }
final IndividualTopic topic = new IndividualTopic(message final IndividualTopic topic = new IndividualTopic(message.replaceFirst("#", "").trim());
.replaceFirst("#", "").trim());
Bot.this.review.begin(topic); Bot.this.review.begin(topic);
Bot.this.sendMessage("Sujet individuel : " + topic.getTitle()); Bot.this.sendMessage("Sujet individuel : " + topic.getTitle());
Bot.this.sendMessage("% quand vous avez fini vous le dites par % fini"); Bot.this.sendMessage("% quand vous avez fini vous le dites par % fini");
@ -222,68 +260,75 @@ public class Bot extends PircBot {
}); });
// Missing // Missing
this.handlers.add(new Handler() { this.handlers.add(new Handler()
{
@Override @Override
public boolean handle(final String sender, final String message) { public boolean handle(final String sender, final String message)
if (Bot.this.review == null {
|| !"!manquants".equalsIgnoreCase(message)) { if (Bot.this.review == null || !"!manquants".equalsIgnoreCase(message))
{
return false; return false;
} }
final Topic topic = Bot.this.review.getCurrentTopic(); final Topic topic = Bot.this.review.getCurrentTopic();
if (topic == null) { if (topic == null)
{
Bot.this.sendMessage("Aucun sujet traité"); Bot.this.sendMessage("Aucun sujet traité");
return true; return true;
} }
final Collection<String> participants = Bot.this.review final Collection<String> participants = Bot.this.review.getParticipants();
.getParticipants(); final Collection<String> currentParticipants = topic.getParticipants();
final Collection<String> currentParticipants = topic
.getParticipants();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final Collection<String> missing = CollectionUtils.subtract( final Collection<String> missing = CollectionUtils.subtract(participants, currentParticipants);
participants, currentParticipants); if (missing.isEmpty())
if (missing.isEmpty()) { {
Bot.this.sendMessage("Aucun participant manquant \\o/"); Bot.this.sendMessage("Aucun participant manquant \\o/");
return true; return true;
} }
Bot.this.sendMessage(String.format( Bot.this.sendMessage(String.format("Les participants suivants sont manquants : %1s", StringUtils.join(missing, ", ")));
"Les participants suivants sont manquants : %1s",
StringUtils.join(missing, ", ")));
return true; return true;
} }
}); });
// Current // Current
this.handlers.add(new Handler() { this.handlers.add(new Handler()
{
@Override @Override
public boolean handle(final String sender, final String message) { public boolean handle(final String sender, final String message)
if (Bot.this.review == null {
|| !"!courant".equalsIgnoreCase(message)) { if (Bot.this.review == null || !"!courant".equalsIgnoreCase(message))
{
return false; return false;
} }
final Topic current = Bot.this.review.getCurrentTopic(); final Topic current = Bot.this.review.getCurrentTopic();
if (current == null) { if (current == null)
{
Bot.this.sendMessage("% Pas de sujet en cours"); Bot.this.sendMessage("% Pas de sujet en cours");
} else if (current instanceof IndividualTopic) { }
Bot.this.sendMessage("% Sujet individuel en cours : " else if (current instanceof IndividualTopic)
+ current.getTitle()); {
} else if (current instanceof CollectiveTopic) { Bot.this.sendMessage("% Sujet individuel en cours : " + current.getTitle());
Bot.this.sendMessage("% Sujet collectif en cours : " }
+ current.getTitle()); else if (current instanceof CollectiveTopic)
{
Bot.this.sendMessage("% Sujet collectif en cours : " + current.getTitle());
} }
return true; return true;
} }
}); });
// Topic message // Topic message
this.handlers.add(new Handler() { this.handlers.add(new Handler()
{
@Override @Override
public boolean handle(final String sender, final String message) { public boolean handle(final String sender, final String message)
if (Bot.this.review == null || message.startsWith("%")) { {
if (Bot.this.review == null || message.startsWith("%"))
{
return false; return false;
} }
Bot.this.review.add(new Message(sender, message)); Bot.this.review.add(new Message(sender, message));
@ -292,10 +337,13 @@ public class Bot extends PircBot {
}); });
// All the other // All the other
this.handlers.add(new Handler() { this.handlers.add(new Handler()
{
@Override @Override
public boolean handle(final String sender, final String message) { public boolean handle(final String sender, final String message)
if (Bot.this.review == null) { {
if (Bot.this.review == null)
{
return false; return false;
} }
Bot.this.review.addRaw(new Message(sender, message)); Bot.this.review.addRaw(new Message(sender, message));
@ -304,35 +352,8 @@ public class Bot extends PircBot {
}); });
} }
public void close() { public void sendMessage(final String message)
this.disconnect(); {
this.dispose();
}
public void add(final ReviewListener listener) {
this.listeners.add(listener);
}
@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;
}
message = message.trim();
for (final Handler handler : this.handlers) {
if (handler.handle(sender, message)) {
break;
}
}
}
public void sendMessage(final String message) {
LOGGER.debug("Send message : {}", message); LOGGER.debug("Send message : {}", message);
this.sendMessage(this.channel, message); this.sendMessage(this.channel, message);
} }

View File

@ -21,6 +21,7 @@ package fr.imirhil.april.hebdobot.irc;
import fr.imirhil.april.hebdobot.review.Review; import fr.imirhil.april.hebdobot.review.Review;
public interface ReviewListener { public interface ReviewListener
{
void onEnd(Review review); void onEnd(Review review);
} }

View File

@ -19,16 +19,23 @@
*/ */
package fr.imirhil.april.hebdobot.pastebin; package fr.imirhil.april.hebdobot.pastebin;
public enum Expiration { public enum Expiration
NEVER(null), MINUTE_10("10M"), HOUR_1("1H"), DAY_1("1D"), MONTH_1("1M"); {
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) { private Expiration(final String value)
{
this.value = value; this.value = value;
} }
public String getValue() { public String getValue()
{
return this.value; return this.value;
} }
} }

View File

@ -19,16 +19,23 @@
*/ */
package fr.imirhil.april.hebdobot.pastebin; package fr.imirhil.april.hebdobot.pastebin;
public enum Format { public enum Format
NONE(null), C("c"), CPP("cpp"), JAVA("java"), JAVA_5("java5"); {
NONE(null),
C("c"),
CPP("cpp"),
JAVA("java"),
JAVA_5("java5");
private final String value; private final String value;
private Format(final String value) { private Format(final String value)
{
this.value = value; this.value = value;
} }
public String getValue() { public String getValue()
{
return this.value; return this.value;
} }
} }

View File

@ -19,16 +19,19 @@
*/ */
package fr.imirhil.april.hebdobot.pastebin; package fr.imirhil.april.hebdobot.pastebin;
public enum Option { public enum Option
{
PASTE("paste"); PASTE("paste");
private final String value; private final String value;
private Option(final String value) { private Option(final String value)
{
this.value = value; this.value = value;
} }
public String getValue() { public String getValue()
{
return this.value; return this.value;
} }
} }

View File

@ -32,7 +32,26 @@ import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair; import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HTTP;
public class PastebinClient { public class PastebinClient
{
public static class APIException extends Exception
{
private static final long serialVersionUID = 1L;
private APIException(final String message)
{
super(message);
}
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_DEV_KEY = "api_dev_key"; 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_KEY = "api_user_key";
private static final String API_USER_NAME = "api_user_name"; private static final String API_USER_NAME = "api_user_name";
@ -42,119 +61,98 @@ public class PastebinClient {
private static final String API_PASTE_NAME = "api_paste_name"; 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_EXPIRATION = "api_paste_expire_date";
private static final String API_PASTE_FORMAT = "api_paste_format"; private static final String API_PASTE_FORMAT = "api_paste_format";
private static final String API_PASTE_CODE = "api_paste_code"; private static final String API_PASTE_CODE = "api_paste_code";
private static final String API_ERROR = "Bad API request,"; private static final String API_ERROR = "Bad API request,";
public static class APIException extends Exception {
private static final long serialVersionUID = 1L;
private APIException(final String message) {
super(message);
}
private static void throwIfError(final String content)
throws APIException {
if (content.contains(API_ERROR)) {
throw new APIException(content.replaceFirst(API_ERROR, ""));
}
}
}
private final String apiKey; private final String apiKey;
private String apiUserKey = null; private String apiUserKey = null;
HttpClient httpClient = new DefaultHttpClient(); HttpClient httpClient = new DefaultHttpClient();
public PastebinClient(final String apiKey) { public PastebinClient(final String apiKey)
{
this.apiKey = apiKey; this.apiKey = apiKey;
} }
public void login(final String name, final String password) public void login(final String name, final String password) throws Exception
throws Exception { {
final List<NameValuePair> params = new LinkedList<NameValuePair>(); final List<NameValuePair> params = new LinkedList<NameValuePair>();
setParameter(params, API_DEV_KEY, this.apiKey); setParameter(params, API_DEV_KEY, this.apiKey);
setParameter(params, API_USER_NAME, name); setParameter(params, API_USER_NAME, name);
setParameter(params, API_USER_PASSWORD, password); setParameter(params, API_USER_PASSWORD, password);
final HttpPost request = final HttpPost request = new HttpPost("http://pastebin.com/api/api_login.php");
new HttpPost("http://pastebin.com/api/api_login.php");
request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
final HttpResponse response = this.httpClient.execute(request); final HttpResponse response = this.httpClient.execute(request);
final String content = final String content = IOUtils.toString(response.getEntity().getContent());
IOUtils.toString(response.getEntity().getContent());
APIException.throwIfError(content); APIException.throwIfError(content);
this.apiUserKey = content; this.apiUserKey = content;
} }
public String paste(final String code) throws Exception { public String paste(final String code) throws Exception
return this.paste(code, null, Format.NONE, Private.PUBLIC, {
Expiration.DAY_1); return this.paste(code, null, Format.NONE, Private.PUBLIC, Expiration.DAY_1);
} }
public String paste(final String code, final Private privat) public String paste(final String code, final Expiration expiration) throws Exception
throws Exception { {
return this.paste(code, null, Format.NONE, privat, 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 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 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 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)
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) throws Exception {
return this.paste(code, null, format, 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); return this.paste(code, null, Format.NONE, Private.PUBLIC, expiration);
} }
public String paste(final String code, final Private privat, public String paste(final String code, final Format format) throws Exception
final Expiration expiration) throws Exception { {
return this.paste(code, null, Format.NONE, privat, expiration); return this.paste(code, null, format, Private.PUBLIC, Expiration.DAY_1);
} }
public String paste(final String code, final Format format, public String paste(final String code, final Format format, final Expiration expiration) throws Exception
final Expiration expiration) throws Exception { {
return this.paste(code, null, format, Private.PUBLIC, expiration); return this.paste(code, null, format, Private.PUBLIC, expiration);
} }
public String paste(final String code, final Format format, public String paste(final String code, final Format format, final Private privat) throws Exception
final Private privat, final Expiration expiration) throws Exception { {
return this.paste(code, null, format, privat, 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); return this.paste(code, null, format, privat, expiration);
} }
public String paste(final String code, final String name, public String paste(final String code, final Private privat) throws Exception
final Format format, final Expiration expiration) throws Exception { {
return this.paste(code, null, Format.NONE, privat, Expiration.DAY_1);
}
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 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 String name, final Format format, final Expiration expiration) throws Exception
{
return this.paste(code, name, format, Private.PUBLIC, expiration); return this.paste(code, name, format, Private.PUBLIC, expiration);
} }
public String paste(final String code, final String name, public String paste(final String code, final String name, final Format format, final Private privat) throws Exception
final Format format, final Private privat, {
final Expiration expiration) 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<NameValuePair> params = new LinkedList<NameValuePair>(); final List<NameValuePair> params = new LinkedList<NameValuePair>();
setParameter(params, API_DEV_KEY, this.apiKey); setParameter(params, API_DEV_KEY, this.apiKey);
setParameter(params, API_USER_KEY, this.apiUserKey); setParameter(params, API_USER_KEY, this.apiUserKey);
@ -165,20 +163,24 @@ public class PastebinClient {
setParameter(params, API_PASTE_FORMAT, format.getValue()); setParameter(params, API_PASTE_FORMAT, format.getValue());
setParameter(params, API_PASTE_CODE, code); setParameter(params, API_PASTE_CODE, code);
final HttpPost request = final HttpPost request = new HttpPost("http://pastebin.com/api/api_post.php");
new HttpPost("http://pastebin.com/api/api_post.php");
request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
final HttpResponse response = this.httpClient.execute(request); final HttpResponse response = this.httpClient.execute(request);
final String content = final String content = IOUtils.toString(response.getEntity().getContent());
IOUtils.toString(response.getEntity().getContent());
APIException.throwIfError(content); APIException.throwIfError(content);
return content; return content;
} }
private static void setParameter(final List<NameValuePair> params, public String paste(final String code, final String name, final Private privat) throws Exception
final String name, final String value) { {
if (value == null) { return this.paste(code, name, Format.NONE, privat, Expiration.DAY_1);
}
private static void setParameter(final List<NameValuePair> params, final String name, final String value)
{
if (value == null)
{
return; return;
} }
params.add(new BasicNameValuePair(name, value)); params.add(new BasicNameValuePair(name, value));

View File

@ -19,16 +19,21 @@
*/ */
package fr.imirhil.april.hebdobot.pastebin; package fr.imirhil.april.hebdobot.pastebin;
public enum Private { public enum Private
PUBLIC("0"), UNLISTED("1"), PRIVATE("2"); {
PUBLIC("0"),
UNLISTED("1"),
PRIVATE("2");
private String value; private String value;
private Private(final String value) { private Private(final String value)
{
this.value = value; this.value = value;
} }
String getValue() { String getValue()
{
return this.value; return this.value;
} }
} }

View File

@ -24,28 +24,34 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
public class CollectiveTopic extends Topic { public class CollectiveTopic extends Topic
{
private final List<Message> messages = new LinkedList<Message>(); private final List<Message> messages = new LinkedList<Message>();
public CollectiveTopic(final String title) { public CollectiveTopic(final String title)
{
super(title); super(title);
} }
@Override @Override
public void add(final Message message) { public void add(final Message message)
{
this.messages.add(message); this.messages.add(message);
} }
public List<Message> getMessages()
{
return this.messages;
}
@Override @Override
public Set<String> getParticipants() { public Set<String> getParticipants()
{
final Set<String> participants = new HashSet<String>(); final Set<String> participants = new HashSet<String>();
for (final Message message : this.messages) { for (final Message message : this.messages)
{
participants.add(message.getAuthor()); participants.add(message.getAuthor());
} }
return participants; return participants;
} }
public List<Message> getMessages() {
return this.messages;
}
} }

View File

@ -25,33 +25,39 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
public class IndividualTopic extends Topic { public class IndividualTopic extends Topic
private final Map<String, List<Message>> messages = {
new HashMap<String, List<Message>>(); private final Map<String, List<Message>> messages = new HashMap<String, List<Message>>();
public IndividualTopic(final String title) { public IndividualTopic(final String title)
{
super(title); super(title);
} }
@Override @Override
public void add(final Message message) { public void add(final Message message)
{
final String author = message.getAuthor(); final String author = message.getAuthor();
if (!this.messages.containsKey(author)) { if (!this.messages.containsKey(author))
{
this.messages.put(author, new LinkedList<Message>()); this.messages.put(author, new LinkedList<Message>());
} }
this.messages.get(author).add(message); this.messages.get(author).add(message);
} }
@Override public List<Message> getMessages(final String author)
public Set<String> getParticipants() { {
return this.messages.keySet();
}
public List<Message> getMessages(final String author) {
return this.messages.get(author); return this.messages.get(author);
} }
public boolean hasParticipant(final String participant) { @Override
public Set<String> getParticipants()
{
return this.messages.keySet();
}
public boolean hasParticipant(final String participant)
{
return this.messages.containsKey(participant); return this.messages.containsKey(participant);
} }
} }

View File

@ -21,25 +21,30 @@ package fr.imirhil.april.hebdobot.review;
import org.joda.time.DateTime; import org.joda.time.DateTime;
public class Message { public class Message
{
private final DateTime date = new DateTime(); private final DateTime date = new DateTime();
private final String author; private final String author;
private final String content; private final String content;
public Message(final String author, final String content) { public Message(final String author, final String content)
{
this.author = author; this.author = author;
this.content = content; this.content = content;
} }
public DateTime getDate() { public String getAuthor()
return this.date; {
}
public String getAuthor() {
return this.author; return this.author;
} }
public String getContent() { public String getContent()
{
return this.content; return this.content;
} }
public DateTime getDate()
{
return this.date;
}
} }

View File

@ -32,60 +32,82 @@ import org.joda.time.format.DateTimeFormat;
import fr.imirhil.april.hebdobot.Context; import fr.imirhil.april.hebdobot.Context;
import fr.imirhil.april.hebdobot.xml.UserAlias; import fr.imirhil.april.hebdobot.xml.UserAlias;
public class Review { public class Review
{
private static final int LENGTH = 80; private static final int LENGTH = 80;
private static final UserAlias USER_ALIAS = Context private static final UserAlias USER_ALIAS = Context.getBean(UserAlias.class);
.getBean(UserAlias.class);
private final Set<String> participants = new HashSet<String>(); private final Set<String> participants = new HashSet<String>();
private final List<IndividualTopic> individualTopics = private final List<IndividualTopic> individualTopics = new LinkedList<IndividualTopic>();
new LinkedList<IndividualTopic>(); private final List<CollectiveTopic> collectiveTopics = new LinkedList<CollectiveTopic>();
private final List<CollectiveTopic> collectiveTopics =
new LinkedList<CollectiveTopic>();
private Topic currentTopic; private Topic currentTopic;
private final List<Message> messages = new LinkedList<Message>(); private final List<Message> messages = new LinkedList<Message>();
private final String owner; private final String owner;
public String getOwner() { public Review(final String owner)
return this.owner; {
}
public boolean isOwner(final String name) {
return this.owner.equalsIgnoreCase(name);
}
public Review(final String owner) {
this.owner = owner; this.owner = owner;
} }
public Topic getCurrentTopic() { public void add(final Message message)
return this.currentTopic; {
} if (this.currentTopic != null)
{
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 void add(final Message message) {
if (this.currentTopic != null) {
this.participants.add(message.getAuthor()); this.participants.add(message.getAuthor());
this.currentTopic.add(message); this.currentTopic.add(message);
} }
this.addRaw(message); this.addRaw(message);
} }
public void addRaw(final Message message) { public void addRaw(final Message message)
{
this.messages.add(message); this.messages.add(message);
} }
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 Topic getCurrentTopic()
{
return this.currentTopic;
}
public String getOwner()
{
return this.owner;
}
public Collection<String> getParticipants()
{
final Collection<String> reviewers = new HashSet<String>();
for (final Topic topic : this.individualTopics)
{
reviewers.addAll(topic.getParticipants());
}
for (final Topic topic : this.collectiveTopics)
{
reviewers.addAll(topic.getParticipants());
}
return reviewers;
}
public boolean isOwner(final String name)
{
return this.owner.equalsIgnoreCase(name);
}
@Override @Override
public String toString() { public String toString()
{
final StringBuffer buffer = new StringBuffer(); final StringBuffer buffer = new StringBuffer();
addLine(buffer, '='); addLine(buffer, '=');
addCenter(buffer, "Revue de la semaine en cours"); addCenter(buffer, "Revue de la semaine en cours");
@ -98,23 +120,28 @@ public class Review {
addLine(buffer, '='); addLine(buffer, '=');
addEmpty(buffer); addEmpty(buffer);
addCenter(buffer, "Participants", '-'); addCenter(buffer, "Participants", '-');
for (final String participant : this.participants) { for (final String participant : this.participants)
{
addChunk(buffer, "* " + USER_ALIAS.getRealName(participant) + "\n"); addChunk(buffer, "* " + USER_ALIAS.getRealName(participant) + "\n");
} }
if (!this.individualTopics.isEmpty()) { if (!this.individualTopics.isEmpty())
for (final String participant : this.participants) { {
for (final String participant : this.participants)
{
addEmpty(buffer); addEmpty(buffer);
addLine(buffer, '='); addLine(buffer, '=');
addEmpty(buffer); addEmpty(buffer);
addCenter(buffer, USER_ALIAS.getRealName(participant), '-'); addCenter(buffer, USER_ALIAS.getRealName(participant), '-');
for (final IndividualTopic topic : this.individualTopics) { for (final IndividualTopic topic : this.individualTopics)
if (topic.hasParticipant(participant)) { {
if (topic.hasParticipant(participant))
{
addEmpty(buffer); addEmpty(buffer);
add(buffer, getTopic(topic)); add(buffer, getTopic(topic));
addEmpty(buffer); addEmpty(buffer);
for (final Message message : topic for (final Message message : topic.getMessages(participant))
.getMessages(participant)) { {
addChunk(buffer, "* " + message.getContent() + "\n"); addChunk(buffer, "* " + message.getContent() + "\n");
} }
} }
@ -122,16 +149,18 @@ public class Review {
} }
} }
if (!this.collectiveTopics.isEmpty()) { if (!this.collectiveTopics.isEmpty())
for (final CollectiveTopic topic : this.collectiveTopics) { {
for (final CollectiveTopic topic : this.collectiveTopics)
{
addEmpty(buffer); addEmpty(buffer);
addLine(buffer, '='); addLine(buffer, '=');
addCenter(buffer, topic.getTitle()); addCenter(buffer, topic.getTitle());
addLine(buffer, '='); addLine(buffer, '=');
addEmpty(buffer); addEmpty(buffer);
for (final Message message : topic.getMessages()) { for (final Message message : topic.getMessages())
addChunk(buffer, "* " + message.getAuthor() + " : " {
+ message.getContent() + "\n"); addChunk(buffer, "* " + message.getAuthor() + " : " + message.getContent() + "\n");
} }
} }
} }
@ -139,67 +168,80 @@ public class Review {
addEmpty(buffer); addEmpty(buffer);
addCenter(buffer, "Log IRC brut"); addCenter(buffer, "Log IRC brut");
addEmpty(buffer); addEmpty(buffer);
for (final Message message : this.messages) { for (final Message message : this.messages)
addChunk(buffer, {
"* " + message.getAuthor() + " : " + message.getContent() addChunk(buffer, "* " + message.getAuthor() + " : " + message.getContent() + "\n");
+ "\n");
} }
return buffer.toString(); return buffer.toString();
} }
private static String getLine(final Character c) { private static void add(final StringBuffer buffer, final String content)
return StringUtils.repeat(c.toString(), LENGTH) + "\n"; {
buffer.append(content);
} }
private static String getLine(final String content, final char c) { private static void addCenter(final StringBuffer buffer, final String content)
return StringUtils.center(" " + content + " ", LENGTH, c) + "\n"; {
}
private static String getTopic(final Topic topic) {
return "=== " + topic.getTitle() + " ===\n";
}
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, ' '); addCenter(buffer, content, ' ');
} }
private static void addLine(final StringBuffer buffer, final char c) { private static void addCenter(final StringBuffer buffer, final String content, final char c)
buffer.append(getLine(c)); {
buffer.append(getLine(content, c));
} }
private static void addEmpty(final StringBuffer buffer) { private static void addChunk(final StringBuffer buffer, final String content)
{
add(buffer, chunk(content));
}
private static void addEmpty(final StringBuffer buffer)
{
buffer.append("\n"); buffer.append("\n");
} }
private static String chunk(final String content, final int length) { private static void addLine(final StringBuffer buffer, final char c)
{
buffer.append(getLine(c));
}
private static String chunk(final String content)
{
return chunk(content, LENGTH);
}
private static String chunk(final String content, final int length)
{
final String[] words = content.split(" "); final String[] words = content.split(" ");
final StringBuffer result = new StringBuffer(); final StringBuffer result = new StringBuffer();
StringBuffer current = new StringBuffer(); StringBuffer current = new StringBuffer();
for (final String word : words) { for (final String word : words)
if (current.length() + word.length() > length) { {
if (result.length() > 0) { if (current.length() + word.length() > length)
{
if (result.length() > 0)
{
result.append("\n"); result.append("\n");
} }
result.append(current); result.append(current);
current = new StringBuffer(word); current = new StringBuffer(word);
} else { }
if (current.length() > 0) { else
{
if (current.length() > 0)
{
current.append(" "); current.append(" ");
} }
current.append(word); current.append(word);
} }
} }
if (current.length() > 0) { if (current.length() > 0)
if (result.length() > 0) { {
if (result.length() > 0)
{
result.append("\n"); result.append("\n");
} }
result.append(current); result.append(current);
@ -208,28 +250,19 @@ public class Review {
return result.toString(); return result.toString();
} }
private static void add(final StringBuffer buffer, final String content) { private static String getLine(final Character c)
buffer.append(content); {
return StringUtils.repeat(c.toString(), LENGTH) + "\n";
} }
private static String chunk(final String content) { private static String getLine(final String content, final char c)
return chunk(content, LENGTH); {
return StringUtils.center(" " + content + " ", LENGTH, c) + "\n";
} }
private static void private static String getTopic(final Topic topic)
addChunk(final StringBuffer buffer, final String content) { {
add(buffer, chunk(content)); return "=== " + topic.getTitle() + " ===\n";
}
public Collection<String> getParticipants() {
final Collection<String> reviewers = new HashSet<String>();
for (final Topic topic : this.individualTopics) {
reviewers.addAll(topic.getParticipants());
}
for (final Topic topic : this.collectiveTopics) {
reviewers.addAll(topic.getParticipants());
}
return reviewers;
} }
} }

View File

@ -21,18 +21,21 @@ package fr.imirhil.april.hebdobot.review;
import java.util.Set; import java.util.Set;
public abstract class Topic { public abstract class Topic
{
private final String title; private final String title;
protected Topic(final String title) { protected Topic(final String title)
{
this.title = 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<String> getParticipants(); public abstract Set<String> getParticipants();
public String getTitle()
{
return this.title;
}
} }

View File

@ -31,41 +31,48 @@ import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.SchemaFactory; import javax.xml.validation.SchemaFactory;
import org.jibble.pircbot.User;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
public class UserAlias { public class UserAlias
{
private final Map<String, String> aliases = new HashMap<String, String>(); private final Map<String, String> aliases = new HashMap<String, String>();
public UserAlias(final InputStream source) { public UserAlias(final InputStream source)
try { {
final Unmarshaller u = try
JAXBContext.newInstance(Users.class).createUnmarshaller(); {
u.setSchema(SchemaFactory final Unmarshaller u = JAXBContext.newInstance(Users.class).createUnmarshaller();
.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) u.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
.newSchema( .newSchema(UserAlias.class.getResource("/fr/imirhil/april/hebdobot/users.xsd")));
UserAlias.class
.getResource("/fr/imirhil/april/hebdobot/users.xsd")));
for (final User user : u for (final User user : u.unmarshal(new StreamSource(source), Users.class).getValue().getUser())
.unmarshal(new StreamSource(source), Users.class) {
.getValue().getUser()) {
final String realName = user.getRealName(); final String realName = user.getRealName();
for (final String nick : user.getNick()) { for (final String nick : user.getNick())
{
this.aliases.put(nick, realName); this.aliases.put(nick, realName);
} }
} }
} catch (final SAXException e) { }
catch (final SAXException e)
{
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(e); throw new RuntimeException(e);
} catch (final JAXBException e) { }
catch (final JAXBException e)
{
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public String getRealName(final String nick) { public String getRealName(final String nick)
for (final Entry<String, String> entry : this.aliases.entrySet()) { {
if (nick.toLowerCase().contains(entry.getKey().toLowerCase())) { for (final Entry<String, String> entry : this.aliases.entrySet())
{
if (nick.toLowerCase().contains(entry.getKey().toLowerCase()))
{
return entry.getValue() + " ( " + nick + " )"; return entry.getValue() + " ( " + nick + " )";
} }
} }

View File

@ -40,66 +40,82 @@ import fr.imirhil.april.hebdobot.review.Review;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "/fr/imirhil/april/hebdobot/conf.xml") @ContextConfiguration(locations = "/fr/imirhil/april/hebdobot/conf.xml")
public class BotTest implements ReviewListener { public class BotTest implements ReviewListener
private static class BotMock extends Bot { {
public BotMock() throws Exception { private static class BotMock extends Bot
{
public BotMock() throws Exception
{
super("", 0, "bot", "channel"); super("", 0, "bot", "channel");
} }
@Override @Override
public void onMessage(final String channel, final String sender, public void onMessage(final String channel, final String sender, final String login, final String hostname, final String message)
final String login, final String hostname, final String message) { {
super.onMessage(channel, sender, login, hostname, message); super.onMessage(channel, sender, login, hostname, message);
} }
} }
@Test
public void redo() throws Exception {
final Bot bot = new BotMock();
bot.add(this);
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();
}
} finally {
isr.close();
}
} finally {
is.close();
}
}
@Override @Override
public void onEnd(final Review review) { public void onEnd(final Review review)
try { {
final String date = ISODateTimeFormat.basicDate().print( try
new DateTime()); {
final String date = ISODateTimeFormat.basicDate().print(new DateTime());
final String text = review.toString(); final String text = review.toString();
final File file = new File("target/" + date + "_revue.txt"); final File file = new File("target/" + date + "_revue.txt");
FileUtils.writeStringToFile(file, text); FileUtils.writeStringToFile(file, text);
} catch (final IOException e) { }
catch (final IOException e)
{
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@Test
public void redo() throws Exception
{
final Bot bot = new BotMock();
bot.add(this);
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();
}
}
finally
{
isr.close();
}
}
finally
{
is.close();
}
}
} }

View File

@ -21,12 +21,13 @@ package fr.imirhil.april.hebdobot.pastebin;
import org.junit.Test; import org.junit.Test;
public class PastebinClientTest { public class PastebinClientTest
private final PastebinClient client = new PastebinClient( {
"b95ea42d539ec9dca02a7da1f5b229c7"); private final PastebinClient client = new PastebinClient("b95ea42d539ec9dca02a7da1f5b229c7");
@Test @Test
public void testPaste() throws Exception { public void testPaste() throws Exception
{
System.out.println(this.client.paste("ééé", Expiration.MINUTE_10)); System.out.println(this.client.paste("ééé", Expiration.MINUTE_10));
} }
} }