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
|
* Use tracker pings - either embedded logic or external mwtrackerd to add more sources to downloads
|
||||||
|
|
||||||
### Chat
|
### Chat
|
||||||
* echo "unknown/innappropriate command" in the console
|
|
||||||
* break up lines on CR/LF, send multiple messages
|
* break up lines on CR/LF, send multiple messages
|
||||||
* enforce # in room names or ignore it
|
* enforce # in room names or ignore it
|
||||||
* auto-create/join channel on server start
|
* auto-create/join channel on server start
|
||||||
|
@ -201,9 +201,19 @@ class ChatServer {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((command.action.console && e.room != CONSOLE) ||
|
if (command.action.console && e.room != CONSOLE) {
|
||||||
(!command.action.console && e.room == CONSOLE) ||
|
echo("/SAY ERROR: You can only execute that command in the chat console, not in a chat room.",
|
||||||
!command.action.user)
|
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
|
return
|
||||||
|
|
||||||
if (command.action.local && e.sender != me)
|
if (command.action.local && e.sender != me)
|
||||||
@ -300,17 +310,17 @@ class ChatServer {
|
|||||||
echo(help, d)
|
echo(help, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
private void echo(String payload, Destination d) {
|
private void echo(String payload, Destination d, String room = CONSOLE) {
|
||||||
log.info "echoing $payload"
|
log.info "echoing $payload"
|
||||||
UUID uuid = UUID.randomUUID()
|
UUID uuid = UUID.randomUUID()
|
||||||
long now = System.currentTimeMillis()
|
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(
|
ChatMessageEvent echo = new ChatMessageEvent(
|
||||||
uuid : uuid,
|
uuid : uuid,
|
||||||
payload : payload,
|
payload : payload,
|
||||||
sender : me,
|
sender : me,
|
||||||
host : me,
|
host : me,
|
||||||
room : CONSOLE,
|
room : room,
|
||||||
chatTime : now,
|
chatTime : now,
|
||||||
sig : sig
|
sig : sig
|
||||||
)
|
)
|
||||||
|
@ -65,7 +65,7 @@ class ChatRoomController {
|
|||||||
trimLines()
|
trimLines()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.action == ChatAction.JOIN) {
|
if (command.action == ChatAction.JOIN && model.console) {
|
||||||
String newRoom = command.payload
|
String newRoom = command.payload
|
||||||
String groupId = model.host.getHumanReadableName()+"-"+newRoom
|
String groupId = model.host.getHumanReadableName()+"-"+newRoom
|
||||||
if (!mvcGroup.parentGroup.childrenGroups.containsKey(groupId)) {
|
if (!mvcGroup.parentGroup.childrenGroups.containsKey(groupId)) {
|
||||||
|
Reference in New Issue
Block a user