View Javadoc

1   /*
2      IMPORTANT !!!
3   
4      DO NOT EDIT THIS FILE. IT IS GENERATED FROM APPROPRIATE XML FILE
5      BY THE MessagesGenerator.xslt.
6      MODIFY THAT FILE INSTEAD OF THIS ONE.
7   
8    */
9   package cz.cuni.amis.pogamut.defcon.communication.messages.commands;
10  
11  import cz.cuni.amis.pogamut.base.communication.messages.*;
12  import cz.cuni.amis.pogamut.base.communication.worldview.*;
13  import cz.cuni.amis.pogamut.base.communication.worldview.object.*;
14  import cz.cuni.amis.pogamut.defcon.base3d.worldview.object.DefConLocation;
15  import cz.cuni.amis.pogamut.defcon.communication.messages.*;
16  import cz.cuni.amis.pogamut.defcon.communication.messages.commands.*;
17  import cz.cuni.amis.pogamut.defcon.communication.messages.infos.*;
18  import cz.cuni.amis.pogamut.defcon.consts.*;
19  import cz.cuni.amis.pogamut.defcon.consts.state.*;
20  import cz.cuni.amis.utils.exception.*;
21  
22  import java.util.*;
23  
24  import javabot.*;
25  
26  
27  /**
28   * Sends the message down to the specified chat channel inside the DefCon.
29   */
30  public class SendChatMessage extends DefConCommand {
31      /**
32       * Message to send.
33       */
34      private String message = null;
35  
36      /**
37       * Chat channel to use.
38       */
39      private ChatChannel channel = ChatChannel.PUBLIC;
40  
41  /**
42                       * Creates new instance of command SendChatMessage.
43                            
44                  Sends the message down to the specified chat channel inside the DefCon. 
45          
46                       @param
47                        message Message to send.
48                       @param
49                        channel Chat channel to use.
50                   */
51      public SendChatMessage(String message, ChatChannel channel) {
52          this.message = message;
53  
54          this.channel = channel;
55      }
56  
57  /**
58                           * Cloning constructor...
59                           * @param original
60                           */
61      public SendChatMessage(SendChatMessage original) {
62          this.message = original.message;
63  
64          this.channel = original.channel;
65      }
66  
67      /**
68       * Message to send.
69       *
70       * @return String
71       */
72      public String getMessage() {
73          return this.message;
74      }
75  
76      /**
77       * Message to send.
78       *
79       * @param message
80       *
81       * @return this object, allows you to chain setters
82       */
83      public SendChatMessage setMessage(String message) {
84          this.message = message;
85  
86          return this;
87      }
88  
89      /**
90       * Chat channel to use.
91       *
92       * @return ChatChannel
93       */
94      public ChatChannel getChannel() {
95          return this.channel;
96      }
97  
98      /**
99       * Chat channel to use.
100      *
101      * @param channel
102      *
103      * @return this object, allows you to chain setters
104      */
105     public SendChatMessage setChannel(ChatChannel channel) {
106         this.channel = channel;
107 
108         return this;
109     }
110 
111     /**
112      * Performs the command - to be used only by the {@link DefConCommandExecutor}.
113      */
114     @Override
115     public void perform() {
116         JBot.SendChatMessage(getMessage(), getChannel().id);
117     }
118 
119     /**
120      * Returns human readable serialization of the message.
121      *
122      * @return human readable string
123      */
124     @Override
125     public String toString() {
126         return "SendChatMessage[" + getStringizedFields() + "; Message = " + this.message +
127         "; Channel = " + this.channel + "]";
128     }
129 
130     /**
131      * Returns message in html format.
132      *
133      * @return html message
134      */
135     public String toHtmlString() {
136         return "<p><b>SendChatMessage:</b></p>" + "<p><i>Message:</i> " + this.message + "</p>" +
137         "<p><i>Channel:</i> " + this.channel + "</p>";
138     }
139 }