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 text = review.toString(); final String date = ISODateTimeFormat.basicDate().print(new DateTime());
try { final String text = review.toString();
this.bot.sendMessage("% Compte-rendu de la revue : " try
+ this.pastebinClient.paste(text, "Revue APRIL " + date, {
Private.UNLISTED)); 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); catch (final Exception 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,28 +26,33 @@ 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()
return CONTEXT.getBean(clazz); {
} if (CONTEXT instanceof ConfigurableApplicationContext)
{
((ConfigurableApplicationContext) CONTEXT).close();
}
}
public static void close() { public static <T> T getBean(final Class<T> clazz)
if (CONTEXT instanceof ConfigurableApplicationContext) { {
((ConfigurableApplicationContext)CONTEXT).close(); return CONTEXT.getBean(clazz);
} }
}
@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,37 +25,44 @@ 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 {
private Bot bot; @Resource
@Resource private Bot bot;
private TwitterTemplate twitterClient; @Resource
private String tweet; private TwitterTemplate twitterClient;
private String irc; private String tweet;
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.bot.sendMessage(String.format(this.irc, min)); {
final String tweet = String.format(this.tweet, min); this.notify(5);
this.twitterClient.timelineOperations().updateStatus(tweet); }
}
public void at30() { private void notify(final int min)
this.notify(30); {
} this.bot.sendMessage(String.format(this.irc, min));
final String tweet = String.format(this.tweet, min);
this.twitterClient.timelineOperations().updateStatus(tweet);
}
public void at45() { public void setIrc(final String message)
this.notify(15); {
} this.irc = message;
}
public void at55() { public void setTweet(final String message)
this.notify(5); {
} this.tweet = message;
}
} }

View File

@ -27,22 +27,19 @@ 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( final Token requestToken = service.getRequestToken();
"KUH2O77u5RJfqZ2rE8qV6Ak1HBKQRg70DUIVAXDr6oo") final String authUrl = service.getAuthorizationUrl(requestToken);
.build(); System.out.println(authUrl);
final Token requestToken = service.getRequestToken();
final String authUrl = service.getAuthorizationUrl(requestToken);
System.out.println(authUrl);
final String value = new Scanner(System.in).nextLine(); final String value = new Scanner(System.in).nextLine();
final Verifier v = new Verifier(value); final Verifier v = new Verifier(value);
final Token accessToken = service.getAccessToken(requestToken, v); final Token accessToken = service.getAccessToken(requestToken, v);
System.out.println(accessToken); System.out.println(accessToken);
} }
} }

View File

@ -36,304 +36,325 @@ 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 { {
public abstract boolean handle(String sender, String message); 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 String host;
private final int port; private final int port;
private final String channel; private final String channel;
private Review review = null; private Review review = null;
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.connect(this.host, this.port); {
this.joinChannel(this.channel); this.listeners.add(listener);
}
this.registerHandlers(); public void close()
} {
this.disconnect();
this.dispose();
}
private void registerHandlers() { public void init() throws Exception
// Help {
this.handlers.add(new Handler() { this.connect(this.host, this.port);
@Override this.joinChannel(this.channel);
public boolean handle(final String sender, final String message) {
if (!"!help".equalsIgnoreCase(message)) {
return false;
}
Bot.this.sendMessage(sender, "Bienvenue " + sender); this.registerHandlers();
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;
}
});
// Die @Override
this.handlers.add(new Handler() { protected void onMessage(final String channel, final String sender, final String login, final String hostname, String message)
@Override {
public boolean handle(final String sender, final String message) { LOGGER.debug("Message received - channel : {}, sender : {}, message : {}", new Object[] { channel, sender, message });
if (!"!stop".equalsIgnoreCase(message)) { if (!channel.equalsIgnoreCase(this.channel))
return false; {
} return;
}
if (Bot.this.review != null) { message = message.trim();
Bot.this.sendMessage("% Une revue est en cours, arrêt impossible");
return false;
}
Context.close(); for (final Handler handler : this.handlers)
return true; {
} if (handler.handle(sender, message))
}); {
break;
}
}
}
// Start private void registerHandlers()
this.handlers.add(new Handler() { {
@Override // Help
public boolean handle(final String sender, final String message) { this.handlers.add(new Handler()
if (!"!debut".equalsIgnoreCase(message)) { {
return false; @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, "Bienvenue " + sender);
Bot.this.sendMessage(sender, Bot.this.sendMessage(sender, "Je suis " + Bot.this.getName() + ", le robot de gestion des revues hebdomadaires de l'APRIL");
"Vous êtes le conducteur de réunion"); Bot.this.sendMessage(sender, "Voici les commandes que je comprend :");
Bot.this.sendMessage(sender, Bot.this.sendMessage(sender, " ");
"Pour terminer la réunion, tapez \"!fin\""); Bot.this.sendMessage(sender, "— !debut : commencer une nouvelle revue");
Bot.this.sendMessage("% Début de la réunion hebdomadaire"); Bot.this.sendMessage(sender, "— !fin : terminer la revue en cours");
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(sender, "— # titre : démarrer un sujet individuel");
return true; 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 // Die
this.handlers.add(new Handler() { this.handlers.add(new Handler()
@Override {
public boolean handle(final String sender, final String message) { @Override
if (Bot.this.review == null public boolean handle(final String sender, final String message)
|| !"!fin".equalsIgnoreCase(message)) { {
return false; if (!"!stop".equalsIgnoreCase(message))
} {
return false;
}
if (!Bot.this.review.isOwner(sender)) { if (Bot.this.review != null)
Bot.this.sendMessage(sender {
+ ", vous n'êtes pas le conducteur de la réunion"); Bot.this.sendMessage("% Une revue est en cours, arrêt impossible");
return false; return false;
} }
for (final ReviewListener listener : Bot.this.listeners) { Context.close();
listener.onEnd(Bot.this.review); return true;
} }
});
Bot.this.sendMessage("% " // Start
+ Bot.this.review.getOwner() this.handlers.add(new Handler()
+ ", ne pas oublier d'ajouter le compte-rendu de la revue sur https://agir.april.org/issues/135"); {
final String participants = StringUtils.join( @Override
Bot.this.review.getParticipants(), " "); public boolean handle(final String sender, final String message)
Bot.this.sendMessage("% " {
+ participants if (!"!debut".equalsIgnoreCase(message))
+ ", pensez à noter votre bénévalo : http://www.april.org/my?action=benevalo"); {
Bot.this.sendMessage("% Fin de la revue hebdomadaire"); return false;
Bot.this.review = null; }
return true;
}
});
// Collective topic, must be before individual topic Bot.this.review = new Review(sender);
this.handlers.add(new Handler() { Bot.this.sendMessage(sender, "Vous êtes le conducteur de réunion");
@Override Bot.this.sendMessage(sender, "Pour terminer la réunion, tapez \"!fin\"");
public boolean handle(final String sender, final String message) { Bot.this.sendMessage("% Début de la réunion hebdomadaire");
if (Bot.this.review == null || !message.matches("\\s*##.*")) { Bot.this.sendMessage(
return false; "% 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)) { // Stop
Bot.this.sendMessage(sender this.handlers.add(new Handler()
+ ", vous n'êtes pas le conducteur de la réunion"); {
return false; @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 if (!Bot.this.review.isOwner(sender))
.replaceFirst("##", "").trim()); {
Bot.this.review.begin(topic); Bot.this.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
Bot.this.sendMessage("Sujet collectif : " + topic.getTitle()); return false;
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;
}
});
// Individual topic for (final ReviewListener listener : Bot.this.listeners)
this.handlers.add(new Handler() { {
@Override listener.onEnd(Bot.this.review);
public boolean handle(final String sender, final String message) { }
if (Bot.this.review == null || !message.matches("\\s*#[^#].*")) {
return false;
}
if (!Bot.this.review.isOwner(sender)) { Bot.this.sendMessage("% " + Bot.this.review.getOwner()
Bot.this.sendMessage(sender + ", ne pas oublier d'ajouter le compte-rendu de la revue sur https://agir.april.org/issues/135");
+ ", vous n'êtes pas le conducteur de la réunion"); final String participants = StringUtils.join(Bot.this.review.getParticipants(), " ");
return false; 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 // Collective topic, must be before individual topic
.replaceFirst("#", "").trim()); this.handlers.add(new Handler()
Bot.this.review.begin(topic); {
Bot.this.sendMessage("Sujet individuel : " + topic.getTitle()); @Override
Bot.this.sendMessage("% quand vous avez fini vous le dites par % fini"); public boolean handle(final String sender, final String message)
return true; {
} if (Bot.this.review == null || !message.matches("\\s*##.*"))
}); {
return false;
}
// Missing if (!Bot.this.review.isOwner(sender))
this.handlers.add(new Handler() { {
@Override Bot.this.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
public boolean handle(final String sender, final String message) { return false;
if (Bot.this.review == null }
|| !"!manquants".equalsIgnoreCase(message)) {
return false;
}
final Topic topic = Bot.this.review.getCurrentTopic(); final CollectiveTopic topic = new CollectiveTopic(message.replaceFirst("##", "").trim());
if (topic == null) { Bot.this.review.begin(topic);
Bot.this.sendMessage("Aucun sujet traité"); Bot.this.sendMessage("Sujet collectif : " + topic.getTitle());
return true; 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<String> participants = Bot.this.review // Individual topic
.getParticipants(); this.handlers.add(new Handler()
final Collection<String> currentParticipants = topic {
.getParticipants(); @Override
public boolean handle(final String sender, final String message)
{
if (Bot.this.review == null || !message.matches("\\s*#[^#].*"))
{
return false;
}
@SuppressWarnings("unchecked") if (!Bot.this.review.isOwner(sender))
final Collection<String> missing = CollectionUtils.subtract( {
participants, currentParticipants); Bot.this.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
if (missing.isEmpty()) { return false;
Bot.this.sendMessage("Aucun participant manquant \\o/"); }
return true;
}
Bot.this.sendMessage(String.format( final IndividualTopic topic = new IndividualTopic(message.replaceFirst("#", "").trim());
"Les participants suivants sont manquants : %1s", Bot.this.review.begin(topic);
StringUtils.join(missing, ", "))); Bot.this.sendMessage("Sujet individuel : " + topic.getTitle());
return true; Bot.this.sendMessage("% quand vous avez fini vous le dites par % fini");
} return true;
}); }
});
// Current // Missing
this.handlers.add(new Handler() { this.handlers.add(new Handler()
@Override {
public boolean handle(final String sender, final String message) { @Override
if (Bot.this.review == null public boolean handle(final String sender, final String message)
|| !"!courant".equalsIgnoreCase(message)) { {
return false; if (Bot.this.review == null || !"!manquants".equalsIgnoreCase(message))
} {
return false;
}
final Topic current = Bot.this.review.getCurrentTopic(); final Topic topic = Bot.this.review.getCurrentTopic();
if (current == null) { if (topic == null)
Bot.this.sendMessage("% Pas de sujet en cours"); {
} else if (current instanceof IndividualTopic) { Bot.this.sendMessage("Aucun sujet traité");
Bot.this.sendMessage("% Sujet individuel en cours : " return true;
+ current.getTitle()); }
} else if (current instanceof CollectiveTopic) {
Bot.this.sendMessage("% Sujet collectif en cours : "
+ current.getTitle());
}
return true;
}
});
// Topic message final Collection<String> participants = Bot.this.review.getParticipants();
this.handlers.add(new Handler() { final Collection<String> currentParticipants = topic.getParticipants();
@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;
}
});
// All the other @SuppressWarnings("unchecked")
this.handlers.add(new Handler() { final Collection<String> missing = CollectionUtils.subtract(participants, currentParticipants);
@Override if (missing.isEmpty())
public boolean handle(final String sender, final String message) { {
if (Bot.this.review == null) { Bot.this.sendMessage("Aucun participant manquant \\o/");
return false; return true;
} }
Bot.this.review.addRaw(new Message(sender, message));
return true;
}
});
}
public void close() { Bot.this.sendMessage(String.format("Les participants suivants sont manquants : %1s", StringUtils.join(missing, ", ")));
this.disconnect(); return true;
this.dispose(); }
} });
public void add(final ReviewListener listener) { // Current
this.listeners.add(listener); 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 final Topic current = Bot.this.review.getCurrentTopic();
protected void onMessage(final String channel, final String sender, if (current == null)
final String login, final String hostname, String message) { {
LOGGER.debug( Bot.this.sendMessage("% Pas de sujet en cours");
"Message received - channel : {}, sender : {}, message : {}", }
new Object[] { channel, sender, message }); else if (current instanceof IndividualTopic)
if (!channel.equalsIgnoreCase(this.channel)) { {
return; 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) { // All the other
if (handler.handle(sender, message)) { this.handlers.add(new Handler()
break; {
} @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) { public void sendMessage(final String message)
LOGGER.debug("Send message : {}", message); {
this.sendMessage(this.channel, message); LOGGER.debug("Send message : {}", 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,155 +32,157 @@ 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
private static final String API_DEV_KEY = "api_dev_key"; {
private static final String API_USER_KEY = "api_user_key"; public static class APIException extends Exception
private static final String API_USER_NAME = "api_user_name"; {
private static final String API_USER_PASSWORD = "api_user_password"; private static final long serialVersionUID = 1L;
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";
private static final String API_ERROR = "Bad API request,"; private APIException(final String message)
{
super(message);
}
public static class APIException extends Exception { private static void throwIfError(final String content) throws APIException
private static final long serialVersionUID = 1L; {
if (content.contains(API_ERROR))
{
throw new APIException(content.replaceFirst(API_ERROR, ""));
}
}
}
private APIException(final String message) { private static final String API_DEV_KEY = "api_dev_key";
super(message); 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) private static final String API_PASTE_CODE = "api_paste_code";
throws APIException {
if (content.contains(API_ERROR)) {
throw new APIException(content.replaceFirst(API_ERROR, ""));
}
}
}
private final String apiKey; private static final String API_ERROR = "Bad API request,";
private String apiUserKey = null;
HttpClient httpClient = new DefaultHttpClient();
public PastebinClient(final String apiKey) { private final String apiKey;
this.apiKey = apiKey; private String apiUserKey = null;
} HttpClient httpClient = new DefaultHttpClient();
public void login(final String name, final String password) public PastebinClient(final String apiKey)
throws Exception { {
final List<NameValuePair> params = new LinkedList<NameValuePair>(); this.apiKey = apiKey;
setParameter(params, API_DEV_KEY, this.apiKey); }
setParameter(params, API_USER_NAME, name);
setParameter(params, API_USER_PASSWORD, password);
final HttpPost request = public void login(final String name, final String password) throws Exception
new HttpPost("http://pastebin.com/api/api_login.php"); {
request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); final List<NameValuePair> params = new LinkedList<NameValuePair>();
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 HttpPost request = new HttpPost("http://pastebin.com/api/api_login.php");
final String content = request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
IOUtils.toString(response.getEntity().getContent());
APIException.throwIfError(content);
this.apiUserKey = content;
}
public String paste(final String code) throws Exception { final HttpResponse response = this.httpClient.execute(request);
return this.paste(code, null, Format.NONE, Private.PUBLIC, final String content = IOUtils.toString(response.getEntity().getContent());
Expiration.DAY_1); APIException.throwIfError(content);
} this.apiUserKey = content;
}
public String paste(final String code, final Private privat) public String paste(final String code) throws Exception
throws Exception { {
return this.paste(code, null, Format.NONE, privat, Expiration.DAY_1); return this.paste(code, null, Format.NONE, Private.PUBLIC, Expiration.DAY_1);
} }
public String paste(final String code, final String name) throws Exception { public String paste(final String code, final Expiration expiration) throws Exception
return this.paste(code, name, Format.NONE, Private.PUBLIC, {
Expiration.DAY_1); return this.paste(code, null, Format.NONE, Private.PUBLIC, expiration);
} }
public String paste(final String code, final String name, public String paste(final String code, final Format format) throws Exception
final Private privat) throws Exception { {
return this.paste(code, name, Format.NONE, privat, Expiration.DAY_1); return this.paste(code, null, format, Private.PUBLIC, Expiration.DAY_1);
} }
public String paste(final String code, final String name, public String paste(final String code, final Format format, final Expiration expiration) throws Exception
final Format format) throws Exception { {
return this.paste(code, name, format, Private.PUBLIC, Expiration.DAY_1); return this.paste(code, null, format, Private.PUBLIC, expiration);
} }
public String paste(final String code, final String name, public String paste(final String code, final Format format, final Private privat) throws Exception
final Format format, final Private privat) throws Exception { {
return this.paste(code, name, format, privat, Expiration.DAY_1); return this.paste(code, null, format, privat, Expiration.DAY_1);
} }
public String paste(final String code, final Format format) public String paste(final String code, final Format format, final Private privat, final Expiration expiration) throws Exception
throws Exception { {
return this.paste(code, null, format, Private.PUBLIC, Expiration.DAY_1); return this.paste(code, null, format, privat, expiration);
} }
public String paste(final String code, final Format format, public String paste(final String code, final Private privat) throws Exception
final Private privat) throws Exception { {
return this.paste(code, null, format, privat, Expiration.DAY_1); return this.paste(code, null, Format.NONE, privat, Expiration.DAY_1);
} }
public String paste(final String code, final Expiration expiration) public String paste(final String code, final Private privat, final Expiration expiration) throws Exception
throws Exception { {
return this.paste(code, null, Format.NONE, Private.PUBLIC, expiration); return this.paste(code, null, Format.NONE, privat, expiration);
} }
public String paste(final String code, final Private privat, public String paste(final String code, final String name) throws Exception
final Expiration expiration) throws Exception { {
return this.paste(code, null, Format.NONE, privat, expiration); return this.paste(code, name, Format.NONE, Private.PUBLIC, Expiration.DAY_1);
} }
public String paste(final String code, final Format format, public String paste(final String code, final String name, final Format format) throws Exception
final Expiration expiration) throws Exception { {
return this.paste(code, null, format, Private.PUBLIC, expiration); return this.paste(code, name, format, Private.PUBLIC, Expiration.DAY_1);
} }
public String paste(final String code, final Format format, public String paste(final String code, final String name, final Format format, final Expiration expiration) throws Exception
final Private privat, final Expiration expiration) throws Exception { {
return this.paste(code, null, format, privat, 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 Expiration expiration) throws Exception { {
return this.paste(code, name, format, Private.PUBLIC, expiration); return this.paste(code, name, format, privat, Expiration.DAY_1);
} }
public String paste(final String code, final String name, public String paste(final String code, final String name, final Format format, final Private privat, final Expiration expiration) throws Exception
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); setParameter(params, API_OPTION, Option.PASTE.getValue());
setParameter(params, API_OPTION, Option.PASTE.getValue()); setParameter(params, API_PASTE_PRIVATE, privat.getValue());
setParameter(params, API_PASTE_PRIVATE, privat.getValue()); setParameter(params, API_PASTE_NAME, name);
setParameter(params, API_PASTE_NAME, name); setParameter(params, API_PASTE_EXPIRATION, expiration.getValue());
setParameter(params, API_PASTE_EXPIRATION, expiration.getValue()); 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);
return; }
}
params.add(new BasicNameValuePair(name, value)); private static void setParameter(final List<NameValuePair> params, final String name, final String value)
} {
if (value == null)
{
return;
}
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);
}
@Override public List<Message> getMessages()
public Set<String> getParticipants() { {
final Set<String> participants = new HashSet<String>(); return this.messages;
for (final Message message : this.messages) { }
participants.add(message.getAuthor());
}
return participants;
}
public List<Message> getMessages() { @Override
return this.messages; public Set<String> getParticipants()
} {
final Set<String> participants = new HashSet<String>();
for (final Message message : this.messages)
{
participants.add(message.getAuthor());
}
return participants;
}
} }

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(); {
if (!this.messages.containsKey(author)) { final String author = message.getAuthor();
this.messages.put(author, new LinkedList<Message>()); if (!this.messages.containsKey(author))
} {
this.messages.get(author).add(message); this.messages.put(author, new LinkedList<Message>());
} }
this.messages.get(author).add(message);
}
@Override public List<Message> getMessages(final String author)
public Set<String> getParticipants() { {
return this.messages.keySet(); return this.messages.get(author);
} }
public List<Message> getMessages(final String author) { @Override
return this.messages.get(author); public Set<String> getParticipants()
} {
return this.messages.keySet();
}
public boolean hasParticipant(final String participant) { 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 String author; private final DateTime date = new DateTime();
private final String content; private final String author;
private final String content;
public Message(final String author, final String content) { public Message(final String author, final String content)
this.author = author; {
this.content = content; this.author = author;
} this.content = content;
}
public DateTime getDate() { public String getAuthor()
return this.date; {
} return this.author;
}
public String getAuthor() { public String getContent()
return this.author; {
} return this.content;
}
public String getContent() { public DateTime getDate()
return this.content; {
} return this.date;
}
} }

View File

@ -32,204 +32,237 @@ 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 = new LinkedList<IndividualTopic>();
private final List<IndividualTopic> individualTopics = private final List<CollectiveTopic> collectiveTopics = new LinkedList<CollectiveTopic>();
new LinkedList<IndividualTopic>(); private Topic currentTopic;
private final List<CollectiveTopic> collectiveTopics = private final List<Message> messages = new LinkedList<Message>();
new LinkedList<CollectiveTopic>(); private final String owner;
private Topic currentTopic;
private final List<Message> messages = new LinkedList<Message>();
private final String owner;
public String getOwner() { public Review(final String owner)
return this.owner; {
} this.owner = owner;
}
public boolean isOwner(final String name) { public void add(final Message message)
return this.owner.equalsIgnoreCase(name); {
} if (this.currentTopic != null)
{
this.participants.add(message.getAuthor());
this.currentTopic.add(message);
}
this.addRaw(message);
}
public Review(final String owner) { public void addRaw(final Message message)
this.owner = owner; {
} this.messages.add(message);
}
public Topic getCurrentTopic() { public void begin(final CollectiveTopic topic)
return this.currentTopic; {
} this.collectiveTopics.add(topic);
this.currentTopic = topic;
}
public void begin(final IndividualTopic topic) { public void begin(final IndividualTopic topic)
this.individualTopics.add(topic); {
this.currentTopic = topic; this.individualTopics.add(topic);
} this.currentTopic = topic;
}
public void begin(final CollectiveTopic topic) { public Topic getCurrentTopic()
this.collectiveTopics.add(topic); {
this.currentTopic = topic; return this.currentTopic;
} }
public void add(final Message message) { public String getOwner()
if (this.currentTopic != null) { {
this.participants.add(message.getAuthor()); return this.owner;
this.currentTopic.add(message); }
}
this.addRaw(message);
}
public void addRaw(final Message message) { public Collection<String> getParticipants()
this.messages.add(message); {
} 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;
}
@Override public boolean isOwner(final String name)
public String toString() { {
final StringBuffer buffer = new StringBuffer(); return this.owner.equalsIgnoreCase(name);
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);
addLine(buffer, '='); @Override
addEmpty(buffer); public String toString()
addCenter(buffer, "Participants", '-'); {
for (final String participant : this.participants) { final StringBuffer buffer = new StringBuffer();
addChunk(buffer, "* " + USER_ALIAS.getRealName(participant) + "\n"); 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()) { addLine(buffer, '=');
for (final String participant : this.participants) { addEmpty(buffer);
addEmpty(buffer); addCenter(buffer, "Participants", '-');
addLine(buffer, '='); for (final String participant : this.participants)
addEmpty(buffer); {
addCenter(buffer, USER_ALIAS.getRealName(participant), '-'); addChunk(buffer, "* " + USER_ALIAS.getRealName(participant) + "\n");
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");
}
}
}
}
}
if (!this.collectiveTopics.isEmpty()) { if (!this.individualTopics.isEmpty())
for (final CollectiveTopic topic : this.collectiveTopics) { {
addEmpty(buffer); for (final String participant : this.participants)
addLine(buffer, '='); {
addCenter(buffer, topic.getTitle()); addEmpty(buffer);
addLine(buffer, '='); addLine(buffer, '=');
addEmpty(buffer); addEmpty(buffer);
for (final Message message : topic.getMessages()) { addCenter(buffer, USER_ALIAS.getRealName(participant), '-');
addChunk(buffer, "* " + message.getAuthor() + " : " for (final IndividualTopic topic : this.individualTopics)
+ message.getContent() + "\n"); {
} 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); if (!this.collectiveTopics.isEmpty())
addCenter(buffer, "Log IRC brut"); {
addEmpty(buffer); for (final CollectiveTopic topic : this.collectiveTopics)
for (final Message message : this.messages) { {
addChunk(buffer, addEmpty(buffer);
"* " + message.getAuthor() + " : " + message.getContent() addLine(buffer, '=');
+ "\n"); 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 buffer.toString();
return StringUtils.repeat(c.toString(), LENGTH) + "\n"; }
}
private static String getLine(final String content, final char c) { private static void add(final StringBuffer buffer, final String content)
return StringUtils.center(" " + content + " ", LENGTH, c) + "\n"; {
} buffer.append(content);
}
private static String getTopic(final Topic topic) { private static void addCenter(final StringBuffer buffer, final String content)
return "=== " + topic.getTitle() + " ===\n"; {
} addCenter(buffer, content, ' ');
}
private static void addCenter(final StringBuffer buffer, private static void addCenter(final StringBuffer buffer, final String content, final char c)
final String content, final char c) { {
buffer.append(getLine(content, c)); buffer.append(getLine(content, c));
} }
private static void addCenter(final StringBuffer buffer, private static void addChunk(final StringBuffer buffer, final String content)
final String content) { {
addCenter(buffer, content, ' '); add(buffer, chunk(content));
} }
private static void addLine(final StringBuffer buffer, final char c) { private static void addEmpty(final StringBuffer buffer)
buffer.append(getLine(c)); {
} buffer.append("\n");
}
private static void addEmpty(final StringBuffer buffer) { private static void addLine(final StringBuffer buffer, final char c)
buffer.append("\n"); {
} buffer.append(getLine(c));
}
private static String chunk(final String content, final int length) { private static String chunk(final String content)
final String[] words = content.split(" "); {
final StringBuffer result = new StringBuffer(); return chunk(content, LENGTH);
StringBuffer current = new StringBuffer(); }
for (final String word : words) { private static String chunk(final String content, final int length)
if (current.length() + word.length() > length) { {
if (result.length() > 0) { final String[] words = content.split(" ");
result.append("\n"); final StringBuffer result = new StringBuffer();
} StringBuffer current = new StringBuffer();
result.append(current);
current = new StringBuffer(word);
} else {
if (current.length() > 0) {
current.append(" ");
}
current.append(word);
}
}
if (current.length() > 0) { for (final String word : words)
if (result.length() > 0) { {
result.append("\n"); if (current.length() + word.length() > length)
} {
result.append(current); 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) { return result.toString();
buffer.append(content); }
}
private static String chunk(final String content) { private static String getLine(final Character c)
return chunk(content, LENGTH); {
} return StringUtils.repeat(c.toString(), LENGTH) + "\n";
}
private static void private static String getLine(final String content, final char c)
addChunk(final StringBuffer buffer, final String content) { {
add(buffer, chunk(content)); return StringUtils.center(" " + content + " ", LENGTH, c) + "\n";
} }
public Collection<String> getParticipants() { private static String getTopic(final Topic topic)
final Collection<String> reviewers = new HashSet<String>(); {
for (final Topic topic : this.individualTopics) { return "=== " + topic.getTitle() + " ===\n";
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() { public abstract void add(Message message);
return this.title;
}
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,44 +31,51 @@ 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) { }
e.printStackTrace(); catch (final SAXException e)
throw new RuntimeException(e); {
} catch (final JAXBException e) { e.printStackTrace();
e.printStackTrace(); throw new RuntimeException(e);
throw new RuntimeException(e); }
} catch (final JAXBException e)
} {
e.printStackTrace();
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())
return entry.getValue() + " ( " + nick + " )"; {
} if (nick.toLowerCase().contains(entry.getKey().toLowerCase()))
} {
return nick; return entry.getValue() + " ( " + nick + " )";
} }
}
return 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
super("", 0, "bot", "channel"); {
} public BotMock() throws Exception
{
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 @Override
public void redo() throws Exception { public void onEnd(final Review review)
final Bot bot = new BotMock(); {
bot.add(this); 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 @Test
.getResourceAsStream("/fr/imirhil/april/hebdobot/review.log"); public void redo() throws Exception
if (is == null) { {
return; final Bot bot = new BotMock();
} bot.add(this);
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 { final InputStream is = BotTest.class.getResourceAsStream("/fr/imirhil/april/hebdobot/review.log");
isr.close(); if (is == null)
} {
} finally { return;
is.close(); }
} 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) { finally
try { {
final String date = ISODateTimeFormat.basicDate().print( isr.close();
new DateTime()); }
final String text = review.toString(); }
final File file = new File("target/" + date + "_revue.txt"); finally
FileUtils.writeStringToFile(file, text); {
} catch (final IOException e) { is.close();
throw new RuntimeException(e); }
} }
}
} }

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));
}
} }