Cleaned up msg.
This commit is contained in:
parent
d843c65f6f
commit
d6a85ef4af
21 changed files with 68 additions and 154 deletions
|
@ -850,7 +850,7 @@ public class Mobibot extends PircBot {
|
|||
* @param message The message.
|
||||
*/
|
||||
public final void send(final String who, final Message message) {
|
||||
send(message.isNotice() ? who : getChannel(), message.getText(), message.getColor(), message.isPrivate());
|
||||
send(message.isNotice() ? who : getChannel(), message.getMsg(), message.getColor(), message.isPrivate());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -101,7 +101,7 @@ public final class Joke extends ThreadedModule {
|
|||
@Override
|
||||
void run(final String sender, final String cmd, final String arg, final boolean isPrivate) {
|
||||
try {
|
||||
bot.send(Utils.cyan(randomJoke().getText()));
|
||||
bot.send(Utils.cyan(randomJoke().getMsg()));
|
||||
} catch (ModuleException e) {
|
||||
bot.getLogger().warn(e.getDebugMessage(), e);
|
||||
bot.send(sender, e.getMessage(), isPrivate);
|
||||
|
|
|
@ -258,7 +258,7 @@ public final class Twitter extends ThreadedModule {
|
|||
void run(final String sender, final String cmd, final String message, final boolean isPrivate) {
|
||||
try {
|
||||
bot.send(sender,
|
||||
post(sender, message + " (by " + sender + " on " + bot.getChannel() + ')', false).getText(),
|
||||
post(sender, message + " (by " + sender + " on " + bot.getChannel() + ')', false).getMsg(),
|
||||
isPrivate);
|
||||
} catch (ModuleException e) {
|
||||
bot.getLogger().warn(e.getDebugMessage(), e);
|
||||
|
|
|
@ -226,12 +226,12 @@ public final class WorldTime extends AbstractModule {
|
|||
} else {
|
||||
final Message msg = worldTime(args);
|
||||
if (isPrivate) {
|
||||
bot.send(sender, msg.getText(), true);
|
||||
bot.send(sender, msg.getMsg(), true);
|
||||
} else {
|
||||
if (msg.isError()) {
|
||||
bot.send(sender, msg.getText(), false);
|
||||
bot.send(sender, msg.getMsg(), false);
|
||||
} else {
|
||||
bot.send(msg.getText());
|
||||
bot.send(msg.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,29 +38,11 @@ package net.thauvin.erik.mobibot.msg
|
|||
* @created 2019-04-07
|
||||
* @since 1.0
|
||||
*/
|
||||
class ErrorMessage : Message {
|
||||
/**
|
||||
* Creates a new error message.
|
||||
*
|
||||
* @param text The error message.
|
||||
*/
|
||||
constructor(text: String) : super() {
|
||||
this.text = text
|
||||
isError = true
|
||||
isNotice = true
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new error message.
|
||||
*
|
||||
* @param text The message.
|
||||
* @param color The message color.
|
||||
*/
|
||||
@Suppress("unused")
|
||||
constructor(text: String, color: String) : super() {
|
||||
this.text = text
|
||||
isError = true
|
||||
isNotice = true
|
||||
class ErrorMessage @JvmOverloads constructor(msg: String, color: String = DEFAULT_COLOR) : Message() {
|
||||
init {
|
||||
this.msg = msg
|
||||
this.color = color
|
||||
isError = true
|
||||
isNotice = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,12 @@ import org.jibble.pircbot.Colors
|
|||
* @since 1.0
|
||||
*/
|
||||
open class Message {
|
||||
companion object {
|
||||
var DEFAULT_COLOR = Colors.NORMAL
|
||||
}
|
||||
|
||||
/** Color */
|
||||
var color = Colors.NORMAL
|
||||
var color = DEFAULT_COLOR
|
||||
|
||||
/** Error */
|
||||
var isError = false
|
||||
|
@ -54,7 +58,7 @@ open class Message {
|
|||
var isPrivate = false
|
||||
|
||||
/** Message text*/
|
||||
var text = ""
|
||||
var msg = ""
|
||||
|
||||
/** Creates a new message. */
|
||||
constructor() {
|
||||
|
@ -64,42 +68,18 @@ open class Message {
|
|||
/**
|
||||
* Creates a new message.
|
||||
*
|
||||
* @param text The message.
|
||||
* @param isNotice The notice flag.
|
||||
* @param isError The error flag.
|
||||
* @param isPrivate The Private message
|
||||
*/
|
||||
constructor(text: String, isNotice: Boolean, isError: Boolean, isPrivate: Boolean) {
|
||||
this.text = text
|
||||
this.isNotice = isNotice
|
||||
this.isError = isError
|
||||
this.isPrivate = isPrivate
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new message.
|
||||
*
|
||||
* @param text The message.
|
||||
* @param isNotice The notice flag.
|
||||
* @param isError The error flag.
|
||||
* @param isPrivate The Private message
|
||||
* @param msg The message.
|
||||
* @param color The color.
|
||||
* @param isNotice The notice flag.
|
||||
* @param isError The error flag.
|
||||
* @param isPrivate The private flag.
|
||||
*/
|
||||
constructor(
|
||||
text: String,
|
||||
isNotice: Boolean,
|
||||
isError: Boolean,
|
||||
isPrivate: Boolean,
|
||||
color: String
|
||||
) {
|
||||
this.text = text
|
||||
@JvmOverloads
|
||||
constructor(msg: String, color: String = DEFAULT_COLOR, isNotice: Boolean, isError: Boolean, isPrivate: Boolean) {
|
||||
this.msg = msg
|
||||
this.color = color
|
||||
this.isNotice = isNotice
|
||||
this.isError = isError
|
||||
this.isPrivate = isPrivate
|
||||
this.color = color
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Message(color='$color', isError=$isError, isNotice=$isNotice, isPrivate=$isPrivate, message='$text')"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,26 +38,10 @@ package net.thauvin.erik.mobibot.msg
|
|||
* @created 2019-04-07
|
||||
* @since 1.0
|
||||
*/
|
||||
class NoticeMessage : Message {
|
||||
/**
|
||||
* Creates a new notice.
|
||||
*
|
||||
* @param text The notice's message.
|
||||
*/
|
||||
constructor(text: String) : super() {
|
||||
this.text = text
|
||||
isNotice = true
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new notice.
|
||||
*
|
||||
* @param text The notice's message.
|
||||
* @param color The color.
|
||||
*/
|
||||
constructor(text: String, color: String) : super() {
|
||||
this.text = text
|
||||
isNotice = true
|
||||
class NoticeMessage @JvmOverloads constructor(msg: String, color: String = DEFAULT_COLOR) : Message() {
|
||||
init {
|
||||
this.msg = msg
|
||||
this.color = color
|
||||
isNotice = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,25 +39,9 @@ package net.thauvin.erik.mobibot.msg
|
|||
* @since 1.0
|
||||
*/
|
||||
@Suppress("unused")
|
||||
class PrivateMessage : Message {
|
||||
/**
|
||||
* Creates a new private message.
|
||||
*
|
||||
* @param text The message.
|
||||
*/
|
||||
constructor(text: String) : super() {
|
||||
this.text = text
|
||||
isPrivate = true
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new private message.
|
||||
*
|
||||
* @param text The message.
|
||||
* @param color The message color.
|
||||
*/
|
||||
constructor(text: String, color: String) : super() {
|
||||
this.text = text
|
||||
class PrivateMessage @JvmOverloads constructor(msg: String, color: String = DEFAULT_COLOR) : Message() {
|
||||
init {
|
||||
this.msg = msg
|
||||
this.color = color
|
||||
isPrivate = true
|
||||
}
|
||||
|
|
|
@ -38,25 +38,9 @@ package net.thauvin.erik.mobibot.msg
|
|||
* @created 2019-04-07
|
||||
* @since 1.0
|
||||
*/
|
||||
class PublicMessage : Message {
|
||||
/**
|
||||
* Creates a new public message.
|
||||
*
|
||||
* @param text The message.
|
||||
*/
|
||||
constructor(text: String) : super() {
|
||||
this.text = text
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new public message.
|
||||
*
|
||||
* @param text The message.
|
||||
* @param color The message color.
|
||||
*/
|
||||
@Suppress("unused")
|
||||
constructor(text: String, color: String) : super() {
|
||||
this.text = text
|
||||
class PublicMessage @JvmOverloads constructor(msg: String, color: String = DEFAULT_COLOR) : Message() {
|
||||
init {
|
||||
this.msg = msg
|
||||
this.color = color
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue