Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tkael/cccdcbde8709fe56696412541c0abc1a to your computer and use it in GitHub Desktop.
Save Tkael/cccdcbde8709fe56696412541c0abc1a to your computer and use it in GitHub Desktop.
EDDI message received script update
{_ Is this the same sender or message as the last message we've received? }
{_ If so then the appropriate value(s) below shall be set to 'true' _}
{set duplicate to [
"from": event.from = state.eddi_context_message_name,
"message": event.message = state.eddi_context_message_content,
]}
{_ Context _}
{SetState('eddi_context_last_subject', 'message')}
{SetState('eddi_context_last_action', 'receive')}
{SetState('eddi_context_message_name', event.from)}
{SetState('eddi_context_message_content', event.message)}
{_ "true" means spoken and "false" means muted.}
{_ "npc" controls whether NPC comms will be spoken.}
{_ "player" controls direct messages to you will be spoken.}
{_ "starsystem" controls whether player comms across game modes will be spoken.}
{set spokenChannels to [
"friend": true,
"local": true,
"multicrew": true,
"npc": true,
"player": true,
"squadron": true,
"starsystem": false,
"voicechat": false,
"wing": true,
]}
{_ "true" means spoken and "false" means muted.}
{_ "NPC" is the default source for NPC comms.}
{set spokenNpcSources to [
"Ambushed pilot" : true,
"Bounty hunter" : true,
"Capital ship" : true,
"Cargo hunter" : true,
"Civilian pilot" : true,
"Conflict zone" : true,
"Cruise liner" : false,
"Escort" : true,
"Exploration convoy" : true,
"Hitman" : true,
"Messenger" : true,
"Military" : true,
"Miner" : true,
"NPC" : true,
"Passenger hunter" : true,
"Passenger liner" : false,
"Pirate" : true,
"Police" : true,
"Propagandist" : false,
"Protester" : false,
"Refugee" : true,
"Rival power's agent" : true,
"Search and rescue" : true,
"Starship One" : true,
"Station" : false,
"Wedding convoy" : false,
]}
{_ Exclude the active voice and any other voices you include below from voice selections }
{set spokenVoiceExemptions to
[
VoiceDetails().name,
]}
{declare speakMessage(msg) as:
{set voiceNames to []}
{_ This sorts the available voices using the senderID as a seed value }
{for voiceDetail in VoiceDetails(event.seed):
{if find(spokenVoiceExemptions, voiceDetail.name) > 0:
{_ This is an excluded voice, skip it }
|else:
{set voiceNames to cat(voiceNames, [voiceDetail.name])}
}
}
{_ If any voices are left, speak using the first non-excluded voice name }
{if len(voiceNames) > 0:
{Transmit(Voice(msg, voiceNames[0]))}
|else:
{_ otherwise, use the default voice, because presumable the user only *has* one voice. _}
{Transmit(msg)}
}
}
{if spokenChannels[event.channel_invariant] = true:
{if event.player = true:
{set words to split(event.message, " ")}
{set msg to []}
{set cur to 0}
{while cur < len(words):
{set o7match to match(words[cur], "(?<!\\w)([o|O|0]7)(?!\\w)")}
{if len(o7match) > 0:
{set remainder to slice(words[cur], 2)}
{if len(words) = 1:
{if event.channel_invariant = 'player': {set you to " you"}}
{set salute to cat("salutes", you)}
{set msg to cat(msg, [cat(salute, remainder)])}
|else:
{set msg to cat(msg, [cat("salute", remainder)])}
}
|else:
{set msg to cat(msg, [words[cur]])}
}
{set cur to cur + 1}
}
{if !duplicate["from"]: {event.source} {event.from} sends:}
{speakMessage(join(msg, " "))}
|elif spokenNpcSources[event.source_invariant] = true:
{_ Replace common abbreviations in NPC messages}
{set msg to event.message}
{set msg to join(split(msg, " cr of cargo"), " credits of cargo")}
{set msg to join(split(msg, "t of cargo"), " tons of cargo")}
{speakMessage(msg)}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment