Added /me support for action messages on IRC
This commit is contained in:
parent
c141a38e9c
commit
e44d0ddeb6
35
src/main.ino
35
src/main.ino
@ -298,6 +298,19 @@ void displayLines() {
|
||||
String modeChange = line.substring(5);
|
||||
tft.setTextColor(TFT_WHITE);
|
||||
tft.print(modeChange);
|
||||
cursorY += CHAR_HEIGHT;
|
||||
} else if (line.startsWith("* ")) { // Check for action message
|
||||
int spacePos = line.indexOf(' ', 2);
|
||||
String senderNick = line.substring(2, spacePos);
|
||||
String actionMessage = line.substring(spacePos + 1);
|
||||
|
||||
tft.setTextColor(TFT_WHITE);
|
||||
tft.print("* ");
|
||||
tft.setTextColor(nickColors[senderNick]);
|
||||
tft.print(senderNick + " ");
|
||||
tft.setTextColor(TFT_WHITE);
|
||||
tft.print(actionMessage);
|
||||
|
||||
cursorY += CHAR_HEIGHT;
|
||||
} else {
|
||||
int colonPos = line.indexOf(':');
|
||||
@ -321,6 +334,7 @@ void displayLines() {
|
||||
displayInputLine();
|
||||
}
|
||||
|
||||
|
||||
void addLine(String senderNick, String message, String type, bool mention = false) {
|
||||
if (nickColors.find(senderNick) == nickColors.end())
|
||||
nickColors[senderNick] = generateRandomColor();
|
||||
@ -344,6 +358,8 @@ void addLine(String senderNick, String message, String type, bool mention = fals
|
||||
formattedMessage = "KICK " + senderNick + message;
|
||||
} else if (type == "mode") {
|
||||
formattedMessage = "MODE " + message;
|
||||
} else if (type == "action") {
|
||||
formattedMessage = "* " + senderNick + " " + message;
|
||||
} else {
|
||||
formattedMessage = senderNick + ": " + message;
|
||||
}
|
||||
@ -361,6 +377,7 @@ void addLine(String senderNick, String message, String type, bool mention = fals
|
||||
displayLines();
|
||||
}
|
||||
|
||||
|
||||
void displayDeviceInfo() {
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
printDeviceInfo();
|
||||
@ -510,8 +527,15 @@ void parseAndDisplay(String line) {
|
||||
String message = line.substring(colonPos + 1);
|
||||
String senderNick = line.substring(1, line.indexOf('!'));
|
||||
bool mention = message.indexOf(nick) != -1;
|
||||
|
||||
// This doesn't work for some annoying reason... even with \001
|
||||
if (message.startsWith("\x01ACTION ") && message.endsWith("\x01")) {
|
||||
String actionMessage = message.substring(8, message.length() - 1);
|
||||
addLine(senderNick, actionMessage, "action");
|
||||
} else {
|
||||
addLine(senderNick, message, "message", mention);
|
||||
}
|
||||
}
|
||||
} else if (command == "JOIN" && line.indexOf(channel) != -1) {
|
||||
String senderNick = line.substring(1, line.indexOf('!'));
|
||||
addLine(senderNick, " has joined " + String(channel), "join");
|
||||
@ -538,6 +562,8 @@ void parseAndDisplay(String line) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void handleKeyboardInput(char key) {
|
||||
if (key == '\n' || key == '\r') { // Enter
|
||||
if (inputBuffer.startsWith("/debug")) {
|
||||
@ -548,6 +574,11 @@ void handleKeyboardInput(char key) {
|
||||
} else if (inputBuffer.startsWith("/raw ")) {
|
||||
String rawCommand = inputBuffer.substring(5);
|
||||
sendRawCommand(rawCommand);
|
||||
} else if (inputBuffer.startsWith("/me ")) {
|
||||
String actionMessage = inputBuffer.substring(4);
|
||||
sendIRC("PRIVMSG " + String(channel) + " :\001ACTION " + actionMessage + "\001");
|
||||
addLine(nick, actionMessage, "action");
|
||||
inputBuffer = "";
|
||||
} else {
|
||||
sendIRC("PRIVMSG " + String(channel) + " :" + inputBuffer);
|
||||
addLine(nick, inputBuffer, "message");
|
||||
@ -892,9 +923,7 @@ void printDeviceInfo() {
|
||||
uint32_t chipId = ESP.getEfuseMac(); // Unique ID
|
||||
esp_chip_info_t chip_info;
|
||||
esp_chip_info(&chip_info);
|
||||
String chipInfo = String(chip_info.model) + " Rev " + String(chip_info.revision) +
|
||||
", " + String(chip_info.cores) + " cores, " +
|
||||
String(ESP.getCpuFreqMHz()) + " MHz";
|
||||
String chipInfo = String(chip_info.model) + " Rev " + String(chip_info.revision) + ", " + String(chip_info.cores) + " cores, " + String(ESP.getCpuFreqMHz()) + " MHz";
|
||||
|
||||
// Get Flash Info
|
||||
size_t flashSize = spi_flash_get_chip_size();
|
||||
|
Loading…
Reference in New Issue
Block a user