Verified Commit a18a6b44 authored by aguestuser's avatar aguestuser
Browse files

[ns] cleanup help command response

* don't mention HELLO in admin commands (to avoid them subscribing,
  pending better fix for admin/subscriber combo)
* point more explicitly to INFO
* spruce up INFO response
parent e5c09686
......@@ -10,12 +10,12 @@ const support = `
HOW IT WORKS
----------------------------
-> Signalboost numbers have admins and subscribers.
-> Admins send announcements that are broadcasted to subscribers.
-> Subscribe to announcements by sending "HELLO" to a number.
-> Unsubscribe by sending "GOODBYE" to the number.
-> Send "HELP" to a number to list commands that make it do things.
-> Learn more: https://0xacab.org/team-friendo/signalboost
-> Signalboost has admins and subscribers.
-> Admins send announcements that are broadcast to subscribers.
-> People can subscribe by sending HELLO or HOLA to this number.
-> Unsubscribe by sending GOODBYE or ADÍOS to this number.
-> Send HELP or AYUDA to list commands that make Signalboost do things.
-> Learn more: https://signalboost.info
`
const notifications = {
......@@ -67,44 +67,44 @@ const commandResponses = {
},
// HELP
help: {
publisher: `
HELLO / HOLA
-> subscribes to this channel
GOODBYE / ADIOS
-> unsubscribes from this channel
publisher: `[COMMANDS I UNDERSTAND:]
HELP / AYUDA
-> lists commands
INFO
-> shows stats, explains signalboost
-> shows stats, explains how signalboost works
RENAME new name
-> renames channel to "new name"
RESPONSES ON / RESPONSES OFF
-> enables/disables subscscriber responses
ADD +1-555-555-5555
-> makes +1-555-555-5555 an admin
REMOVE +1-555-555-5555
-> removes +1-555-555-5555 as an admin`,
subscriber: `
-> removes +1-555-555-5555 as an admin
RESPONSES ON
-> allows subscribers to send messages to admins
RESPONSES OFF
-> disables subscribers from sending messages to admins
GOODBYE / ADIOS
-> leaves this channel`,
subscriber: `[COMMANDS I UNDERSTAND:]
HELP / AYUDA
-> lists commands
INFO
-> explains signalboost
-> shows stats, explains how signalboost works
HELLO / HOLA
-> subscribes you to messages
-> subscribes you to announcements
GOODBYE / ADIOS
-> unsubscribes you
`,
-> unsubscribes you from announcements`,
},
// INFO
......@@ -187,8 +187,7 @@ Reply with HELP to learn more or GOODBYE to unsubscribe.`
}
const prefixes = {
helpResponse: `COMMANDS I UNDERSTAND...`,
broadcastResponse: `SUBSCRIBER RESPONSE...`,
broadcastResponse: `SUBSCRIBER RESPONSE:`,
}
const EN = {
......
......@@ -187,15 +187,11 @@ const format = ({ channel, sdMessage, messageType, command, language }) => {
// Channel, string, string, string -> string
const resolvePrefix = (channel, messageType, command, language) => {
const prefixes = messagesIn(language).prefixes
if (command === commands.RENAME || command === commands.INFO) {
if (command === commands.RENAME || command === commands.INFO || command === commands.HELP) {
// RENAME messages must provide their own header (b/c channel name changed since last query)
// INFO messages don't need a name prefix b/c they provide channel name as part of message
// INFO & HELP messages provide their own prefixes
return ''
}
if (command === commands.HELP) {
// HELP responses flag that they contain commands instead of listing channel name
return `[${prefixes.helpResponse}]\n`
}
if (messageType === BROADCAST_RESPONSE) {
// subscriber responses get a special header so they don't look like broadcast messages from admins
// we clone message to preserve attachments
......
......@@ -190,7 +190,7 @@ describe('messenger service', () => {
expect(broadcastMessageStub.getCall(0).args).to.eql([
sock,
publisherNumbers,
{ ...sdMessage, messageBody: `[SUBSCRIBER RESPONSE...]\n${sdMessage.messageBody}` },
{ ...sdMessage, messageBody: `[SUBSCRIBER RESPONSE:]\n${sdMessage.messageBody}` },
])
})
......@@ -222,7 +222,7 @@ describe('messenger service', () => {
expect(broadcastMessageStub.getCall(0).args).to.eql([
sock,
publisherNumbers,
{ ...sdMessage, messageBody: `[SUBSCRIBER RESPONSE...]\n${sdMessage.messageBody}` },
{ ...sdMessage, messageBody: `[SUBSCRIBER RESPONSE:]\n${sdMessage.messageBody}` },
])
})
......@@ -384,7 +384,7 @@ describe('messenger service', () => {
messageType: messageTypes.BROADCAST_RESPONSE,
language: languages.EN,
}
expect(messenger.format(msg)).to.eql(sdMessageOf(channel, '[SUBSCRIBER RESPONSE...]\nblah'))
expect(messenger.format(msg)).to.eql(sdMessageOf(channel, '[SUBSCRIBER RESPONSE:]\nblah'))
})
})
......@@ -414,7 +414,7 @@ describe('messenger service', () => {
})
describe('response to a HELP command', () => {
it('adds a help prefix', () => {
it('does not add a prefix', () => {
const msg = {
channel,
sdMessage,
......@@ -423,7 +423,7 @@ describe('messenger service', () => {
}
expect(messenger.format(msg)).to.eql({
...sdMessage,
messageBody: `[COMMANDS I UNDERSTAND...]\n${sdMessage.messageBody}`,
messageBody: `${sdMessage.messageBody}`,
})
})
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment