public final class Utils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addBotToMDC(PircBotX bot) |
static void |
dispatchEvent(PircBotX bot,
Event event) |
static String |
format(String messagePattern,
Object... args) |
static String |
parseCommand(String expectedPrefix,
GenericMessageEvent event)
Gets the message from the event and calls
parseCommand(java.lang.String, java.lang.String) |
static String |
parseCommand(String expectedPrefix,
String rawCommand)
Parse given command, if it starts with the prefix return the line minus
the prefix (the arguments), otherwise return null
|
static void |
sendRawLineToServer(PircBotX bot,
String rawLine)
Sends a raw line to the server.
|
static void |
setNickServIdentified(PircBotX bot)
Sets bot as identified to nickserv.
|
static List<String> |
tokenizeLine(String input)
Tokenize IRC raw input into it's components, keeping the 'sender' and
'message' fields intact.
|
static <V> V |
tryGetIndex(List<V> list,
int index,
V defaultValue) |
static int |
tryParseInt(String intString,
int defaultValue)
Try to parse int string, returning -1 if it fails.
|
static long |
tryParseLong(String longString,
int defaultValue)
Try to parse long string, returning -1 if it fails.
|
static String |
unescapeV3TagValue(String v3TagValue)
Unescape IRCv3 message tag values which have been escaped before
(e.g.
|
public static int tryParseInt(String intString, int defaultValue)
public static long tryParseLong(String longString, int defaultValue)
longString
- public static <V> V tryGetIndex(List<V> list, int index, V defaultValue)
@Nullable public static String parseCommand(String expectedPrefix, GenericMessageEvent event)
parseCommand(java.lang.String, java.lang.String)
@Nullable public static String parseCommand(@NonNull String expectedPrefix, @NonNull String rawCommand)
expectedPrefix
- The prefix the command must start with and will be
removed when returnedrawCommand
- Raw input stringpublic static void addBotToMDC(PircBotX bot)
public static void sendRawLineToServer(PircBotX bot, String rawLine) throws IOException
PircBotX.sendRawLineToServer(java.lang.String)
can stay protected but still be callable from the org.pircbotx.output
packagebot
- The bot that sends the raw linerawLine
- The raw line to sendIOException
public static void setNickServIdentified(PircBotX bot)
PircBotX.setNickservIdentified(boolean)
can stay protectedbot
- public static List<String> tokenizeLine(String input)
input
- A string in the format [:]item [item] ... [:item [item] ...]public static String unescapeV3TagValue(String v3TagValue)
v3TagValue
- Escaped IRCv3 message tag valueCopyright © 2010–2020 Leon Blakey. All rights reserved.