File tree Expand file tree Collapse file tree 2 files changed +54
-2
lines changed
plugin/src/main/groovy/org/bot4j/telegram/message Expand file tree Collapse file tree 2 files changed +54
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ public abstract class MessageFactory {
55 /**
66 * Create a MarkdownBuilder instance.
77 *
8- * @return MarkdownBuilder instance
8+ * @return MarkdownBuilder instance, class {@link MarkdownBuilder}
99 */
1010 public static MarkdownBuilder markdown () {
1111 return new MarkdownBuilder ();
@@ -14,9 +14,27 @@ public static MarkdownBuilder markdown() {
1414 /**
1515 * Create a HtmlBuilder instance.
1616 *
17- * @return HtmlBuilder instance
17+ * @return HtmlBuilder instance, class {@link HtmlBuilder}
1818 */
1919 public static HtmlBuilder html () {
2020 return new HtmlBuilder ();
2121 }
22+
23+ /**
24+ * Create a HttpBuilder instance.
25+ *
26+ * @return HttpBuilder instance, class {@link HttpBuilder}
27+ */
28+ public static HttpBuilder http () {
29+ return new HttpBuilder ();
30+ }
31+
32+ /**
33+ * Create a HttpBuilder instance.
34+ *
35+ * @return HttpBuilder instance, class {@link NotifyBuilder}
36+ */
37+ public static NotifyBuilder reveal () {
38+ return new NotifyBuilder ();
39+ }
2240}
Original file line number Diff line number Diff line change 1+ package org .bot4j .telegram .message ;
2+
3+ import org .alpha4j .common .Map4j ;
4+
5+ public class NotifyBuilder extends MarkdownBuilder {
6+ protected final Map4j <String , Object > placeholders ;
7+
8+ public NotifyBuilder () {
9+ super ();
10+ this .placeholders = new Map4j <>();
11+ }
12+
13+ protected static class Index {
14+ public static final String CAUSE_INDEX = "cause_index" ;
15+ }
16+
17+ public NotifyBuilder cause (Throwable e ) {
18+ if (e == null ) {
19+ return this ;
20+ }
21+ this .placeholders .put (Index .CAUSE_INDEX , e .getMessage ());
22+ return this ;
23+ }
24+
25+ @ Override
26+ public String toString () {
27+ if (this .placeholders .containsKey (Index .CAUSE_INDEX )) {
28+ this .line ().bold ("Cause:" )
29+ .preformatted ("bash" , (String ) this .placeholders .get (Index .CAUSE_INDEX ))
30+ .line ();
31+ }
32+ return super .toString ();
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments