show error messages if the command is not in the appropriate room
This commit is contained in:
1
TODO.md
1
TODO.md
@ -22,7 +22,6 @@ This helps with scalability
|
||||
* Use tracker pings - either embedded logic or external mwtrackerd to add more sources to downloads
|
||||
|
||||
### Chat
|
||||
* echo "unknown/innappropriate command" in the console
|
||||
* break up lines on CR/LF, send multiple messages
|
||||
* enforce # in room names or ignore it
|
||||
* auto-create/join channel on server start
|
||||
|
@ -201,9 +201,19 @@ class ChatServer {
|
||||
return
|
||||
}
|
||||
|
||||
if ((command.action.console && e.room != CONSOLE) ||
|
||||
(!command.action.console && e.room == CONSOLE) ||
|
||||
!command.action.user)
|
||||
if (command.action.console && e.room != CONSOLE) {
|
||||
echo("/SAY ERROR: You can only execute that command in the chat console, not in a chat room.",
|
||||
e.sender.destination, e.room)
|
||||
return
|
||||
}
|
||||
|
||||
if (!command.action.console && e.room == CONSOLE) {
|
||||
echo("/SAY ERROR: You need to be in a chat room. Type /LIST for list of rooms or /JOIN to join or create a room.",
|
||||
e.sender.destination)
|
||||
return
|
||||
}
|
||||
|
||||
if (!command.action.user)
|
||||
return
|
||||
|
||||
if (command.action.local && e.sender != me)
|
||||
@ -300,17 +310,17 @@ class ChatServer {
|
||||
echo(help, d)
|
||||
}
|
||||
|
||||
private void echo(String payload, Destination d) {
|
||||
private void echo(String payload, Destination d, String room = CONSOLE) {
|
||||
log.info "echoing $payload"
|
||||
UUID uuid = UUID.randomUUID()
|
||||
long now = System.currentTimeMillis()
|
||||
byte [] sig = ChatConnection.sign(uuid, now, CONSOLE, payload, me, me, spk)
|
||||
byte [] sig = ChatConnection.sign(uuid, now, room, payload, me, me, spk)
|
||||
ChatMessageEvent echo = new ChatMessageEvent(
|
||||
uuid : uuid,
|
||||
payload : payload,
|
||||
sender : me,
|
||||
host : me,
|
||||
room : CONSOLE,
|
||||
room : room,
|
||||
chatTime : now,
|
||||
sig : sig
|
||||
)
|
||||
|
@ -65,7 +65,7 @@ class ChatRoomController {
|
||||
trimLines()
|
||||
}
|
||||
|
||||
if (command.action == ChatAction.JOIN) {
|
||||
if (command.action == ChatAction.JOIN && model.console) {
|
||||
String newRoom = command.payload
|
||||
String groupId = model.host.getHumanReadableName()+"-"+newRoom
|
||||
if (!mvcGroup.parentGroup.childrenGroups.containsKey(groupId)) {
|
||||
|
Reference in New Issue
Block a user