Skip to content

Commit

Permalink
Say Commands (#103)
Browse files Browse the repository at this point in the history
* Say Commands

- Add mute toggle
- Favor state over thread flags
- General chaos
- README updates
  • Loading branch information
mgeitz authored Mar 18, 2022
1 parent 23977b1 commit 03d96e3
Show file tree
Hide file tree
Showing 9 changed files with 413 additions and 209 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ An Everquest Emulator Log Parser with NCurses Interface for Linux
Install from pypi
```sh
$ # Install Stable
$ pip3 install eqalert==2.2.5
$ pip3 install eqalert==2.3.2
$
$ # Install whatever I just pushed to pypi
$ pip3 install eqalert
Expand Down Expand Up @@ -47,7 +47,8 @@ Spot check these default paths generated in `config.json`
"paths": {
"alert_log": "[$HOME/.eqa/]log/",
"char_log": "[$HOME]/.wine/drive_c/Program Files/Sony/EverQuest/Logs/",
"sound": "[$HOME/.eqa/]sound/"
"sound": "[$HOME/.eqa/]sound/",
"tmp_sound": "/tmp/eqa/sound/"
},
```
> Press `F12` to reload your config or restart the program if any changes were made to the config
Expand All @@ -67,6 +68,7 @@ Spot check these default paths generated in `config.json`
- c : Clear event box
- r : Toggle raid mode
- d : Toggle debug mode
- m : Toggle audio mute

#### Settings
- up : Cycle up in selection
Expand All @@ -79,6 +81,8 @@ Spot check these default paths generated in `config.json`

Modify `~/.eqa/config.json` to customize alerts.

### Line Types

Here is a an example configuration for a given line type in the config:
```
"line_type": {
Expand All @@ -96,7 +100,7 @@ There is a configuration entry for all lines matched by the parser. If a new on

- `false`: Disable alerting for this line type
- `true`: Alert for matching strings under `alert` for the line type, using the set sound
- `speak`: Full text-to-speech for the entire line (probably don't enable this for `combat_other_melee`
- `speak`: Full text-to-speech for the entire line (probably don't enable this for `combat_other_melee`)
- `all`: Alert for all lines of a given line type, using the set sound

#### Alert Keys
Expand Down Expand Up @@ -126,3 +130,10 @@ For instance, the following example will alert for the word `hey` when someone e
- You can type anything you want as the value here and it will be the text-to-speech alert you hear when an enabled alert is found in the line type and reaction is set to true.

> One exception to this, `false` cannot be used as a text-to-speech alert, it indicates you don't want a sound alert. This is useful if you only want something to show as an event on the display and make no sound.
### Zones

Right now, there are only two valid settings for a zones value:

- `false`: Considered a non-raid zone
- `raid`: A raid zone, parser raid mode will auto-enable when this zone is detected
275 changes: 240 additions & 35 deletions eqa/eqalert.py

Large diffs are not rendered by default.

105 changes: 77 additions & 28 deletions eqa/lib/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@


def process(
config,
base_path,
state,
action_q,
system_q,
display_q,
sound_q,
exit_flag,
raid,
cfg_reload,
debug_mode,
config,
base_path,
):
"""
Process: action_q
Expand All @@ -59,7 +58,7 @@ def process(
check_line = new_message.payload

# Line specific checks
if line_type == "undetermined" and debug_mode.is_set():
if line_type == "undetermined" and state.debug == "true":
undetermined_line(check_line, base_path)
elif line_type == "location":
y, x, z = re.findall("[-]?(?:\d*\.)?\d+", check_line)
Expand All @@ -83,6 +82,72 @@ def process(
direction[0],
)
)
elif line_type == "you_say":
if (
re.fullmatch(r"^You say, \'parser mute\'$", check_line)
is not None
):
system_q.put(
eqa_struct.message(
eqa_settings.eqa_time(),
"system",
"mute",
"null",
"all",
)
)
elif (
re.fullmatch(r"^You say, \'parser mute speak\'$", check_line)
is not None
):
system_q.put(
eqa_struct.message(
eqa_settings.eqa_time(),
"system",
"mute",
"null",
"speak",
)
)
elif (
re.fullmatch(r"^You say, \'parser mute alert\'$", check_line)
is not None
):
system_q.put(
eqa_struct.message(
eqa_settings.eqa_time(),
"system",
"mute",
"null",
"alert",
)
)
elif (
re.fullmatch(r"^You say, \'parser raid\'$", check_line)
is not None
):
system_q.put(
eqa_struct.message(
eqa_settings.eqa_time(),
"system",
"raid",
"toggle",
"null",
)
)
elif (
re.fullmatch(r"^You say, \'parser debug\'$", check_line)
is not None
):
system_q.put(
eqa_struct.message(
eqa_settings.eqa_time(),
"system",
"debug",
"toggle",
"null",
)
)
elif line_type.startswith("you_afk"):
if line_type == "you_afk_on":
display_q.put(
Expand Down Expand Up @@ -138,49 +203,33 @@ def process(
if current_zone[0] not in config["zones"].keys():
eqa_config.add_zone(current_zone[0], base_path)
elif (
current_zone[0] in config["zones"].keys() and not raid.is_set()
current_zone[0] in config["zones"].keys()
and not state.raid == "true"
):
if config["zones"][current_zone[0]] == "raid":
raid.set()
system_q.put(
eqa_struct.message(
eqa_settings.eqa_time(),
"system",
"raid",
"null",
"true",
)
)
display_q.put(
eqa_struct.display(
eqa_settings.eqa_time(),
"event",
"events",
"Raid mode auto-enabled",
)
)
sound_q.put(eqa_struct.sound("speak", "Raid mode enabled"))
elif current_zone[0] in config["zones"].keys() and raid.is_set():
elif (
current_zone[0] in config["zones"].keys()
and state.raid == "true"
):
if config["zones"][current_zone[0]] != "raid":
raid.clear()
system_q.put(
eqa_struct.message(
eqa_settings.eqa_time(),
"system",
"raid",
"null",
"false",
)
)
display_q.put(
eqa_struct.display(
eqa_settings.eqa_time(),
"event",
"events",
"Raid mode auto-disabled",
)
)
sound_q.put(eqa_struct.sound("speak", "Raid mode disabled"))

# If line_type is a parsable type
if line_type in config["line"].keys():
Expand All @@ -205,7 +254,7 @@ def process(
elif (
str(keyphrase).lower() in check_line.lower()
and value == "raid"
and raid.is_set()
and state.raid == "true"
):
if keyphrase == "assist" or keyphrase == "rampage":
target = re.findall("^([\w\-]+)", check_line)
Expand Down
15 changes: 9 additions & 6 deletions eqa/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def bootstrap_state(base_path, char, server):
"afk": "false",
"raid": "false",
"debug": "false",
"mute": "false",
}
)
json_data = open(base_path + "config.json", "w", encoding="utf-8")
Expand Down Expand Up @@ -192,6 +193,7 @@ def set_last_state(state, base_path):
"afk": str(state.afk),
"raid": str(state.raid),
"debug": str(state.debug),
"mute": str(state.mute),
}
)
data["char_logs"][state.char + "_" + state.server].update(
Expand Down Expand Up @@ -256,13 +258,14 @@ def get_last_state(base_path):
afk = data["last_state"]["afk"]
raid = data["last_state"]["raid"]
debug = data["last_state"]["debug"]
mute = data["last_state"]["mute"]

# Get chars
chars = get_config_chars(data)

# Populate and return a new state
state = eqa_state.EQA_State(
char, chars, zone, location, direction, afk, server, raid, debug
char, chars, zone, location, direction, afk, server, raid, debug, mute
)

return state
Expand Down Expand Up @@ -1120,7 +1123,7 @@ def build_config(base_path):
"sound": "%ssound/",
"tmp_sound": "/tmp/eqa/sound/"
},
"version": "2.2.7"
"version": "2.3.2"
},
"zones": {
"An Arena (PVP) Area": "false",
Expand Down Expand Up @@ -1158,7 +1161,7 @@ def build_config(base_path):
"Icewell Keep": "raid",
"Infected Paw": "false",
"Innothule Swamp": "false",
"Kael Drakkel": "false",
"Kael Drakkel": "raid",
"Karnor's Castle": "false",
"Kedge Keep": "false",
"Kithicor Woods": "false",
Expand All @@ -1181,7 +1184,7 @@ def build_config(base_path):
"Old Sebilis": "false",
"Paineel": "false",
"Permafrost Caverns": "false",
"Plane of Air": "false",
"Plane of Air": "raid",
"Plane of Fear": "raid",
"Plane of Growth": "false",
"Plane of Hate": "raid",
Expand All @@ -1193,7 +1196,7 @@ def build_config(base_path):
"Sirens Grotto": "false",
"Skyfire Mountains": "false",
"Skyshrine": "false",
"Sleepers Tomb": "false",
"Sleepers Tomb": "raid",
"South Kaladim": "false",
"Southern Desert of Ro": "false",
"Southern Felwithe": "false",
Expand Down Expand Up @@ -1222,7 +1225,7 @@ def build_config(base_path):
"West Freeport": "false",
"Western Plains of Karana": "false",
"Western Wastelands": "false",
"Western Wastes": "false"
"Western Wastes": "raid"
}
}
Expand Down
Loading

0 comments on commit 03d96e3

Please sign in to comment.