TikTok-mGBA-Emulator/node/source/classes/modules/tiktok/Message.ts

46 lines
No EOL
1.3 KiB
TypeScript

export class Message {
private messageId: string;
private createdAt: Date;
private content: string;
/**
* Create a new Message object
* @param data { messageId: string, content: string }
*/
constructor(data: { messageId: string, content: string }) {
this.messageId = data.messageId;
this.content = data.content;
this.createdAt = new Date();
}
/**
* Try to get the game key from the message content, otherwise return false
* @returns {string|boolean} Returns the game key for the GBA or false if it is not a valid game key
*/
public getMessageGameKey(): string|boolean {
switch(this.content.toLowerCase().trim()) {
case "start":
return "Start";
case "select":
return "Select";
case "a":
return "A";
case "b":
return "B";
case "r":
return "Right";
case "l":
return "Left";
case "u":
return "Up";
case "d":
return "Down";
case "rt":
return "R";
case "lt":
return "L";
default:
return false;
}
}
}