Skip to content

Commit 37fa444

Browse files
committed
Add toggle_afk command
Add afk sign Add global name to show_reactions Add warning about third party forks
1 parent ae1e985 commit 37fa444

File tree

8 files changed

+33
-3
lines changed

8 files changed

+33
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ Open link in browser - `Alt+O`
369369
This mode entirely replaces curses with pygame-ce GUI library. This means Endcord runs in its own window, not in terminal, but UI remains terminal-like.
370370
Tray icon will also be enabled, so closing window will only minimize it to tray.
371371
Keybinding remain the same, but all codes are like on Linux, so old keybinding codes may not work on Windows.
372-
If using external editor, use some with graphical interface. TUI editors will not work, as this is no longer in terminal.
372+
If using external editor, use editor with graphical interface. TUI editors will not work, as this is no longer in terminal.
373+
Also, endcord built-in media player will not work because its standalone TUI thats not using curses. All meda will be opened in native player.
373374
Building with nuitka on python >=3.13 will create executable that segfaults! Building with pyinstaller is not recommended because it generates huge binary.
374375
You can toggle experimental mode bu running: `uv run build.py --experimental`.
375376
Then run endcord from source: `uv run main.py`.
@@ -435,6 +436,7 @@ Never tested on macOS. Feedback is welcome.
435436
> **Use endcord at your own risk!**
436437
> For more info see [FAQ](#FAQ).
437438
439+
Third party endcord forks may add features that can lead to account ban, or contain malicious code, cause instability, especially if they include LLM generated/modified code.
438440

439441
## Building
440442
To see all build script options, run: `uv run build.py -h`.

commands.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
Set custom status emoji.
9898
- `custom_status_remove`
9999
Remove custom status.
100+
- `toggle_afk`
101+
Toggle afk state. If afk, mobile devices will receive notifications.
100102
- `block *ignore <@[user_id]>`
101103
Block user. `ignore` is optional.
102104
- `unblock *ignore <@[user_id]>`

endcord/app.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ def reset(self, online=False):
584584
"custom_status": None,
585585
"custom_status_emoji": None,
586586
"activities": [],
587+
"afk": False,
587588
"client_state": "OFFLINE",
588589
}
589590
for num, _ in enumerate(self.channel_cache):
@@ -623,6 +624,7 @@ def reconnect(self):
623624
custom_status=self.my_status["custom_status"],
624625
custom_status_emoji=self.my_status["custom_status_emoji"],
625626
activities=self.my_activities,
627+
afk=self.my_status["afk"],
626628
)
627629

628630
new_messages = self.get_messages_with_members()
@@ -3301,6 +3303,7 @@ def execute_command(self, cmd_type, cmd_args, cmd_text, chat_sel, tree_sel):
33013303
custom_status=self.my_status["custom_status"],
33023304
custom_status_emoji=self.my_status["custom_status_emoji"],
33033305
activities=self.my_activities,
3306+
afk=self.my_status["afk"],
33043307
)
33053308

33063309
elif cmd_type == 45: # BLOCK
@@ -3491,6 +3494,17 @@ def execute_command(self, cmd_type, cmd_args, cmd_text, chat_sel, tree_sel):
34913494

34923495
# 64 - COPY_LINK is handled together with 5 - OPEN_LINK
34933496

3497+
elif cmd_type == 65: # TOGGLE_AFK
3498+
self.my_status["afk"] = not self.my_status["afk"]
3499+
self.gateway.update_presence(
3500+
self.my_status["status"],
3501+
custom_status=self.my_status["custom_status"],
3502+
custom_status_emoji=self.my_status["custom_status_emoji"],
3503+
activities=self.my_activities,
3504+
afk=self.my_status["afk"],
3505+
)
3506+
self.update_status_line()
3507+
34943508
elif cmd_type == 66 and self.fun: # 666
34953509
self.fun = 1 if self.fun == 2 else 2
34963510
self.tui.set_fun(self.fun)
@@ -4379,6 +4393,7 @@ def set_status(self, status):
43794393
custom_status=self.my_status["custom_status"],
43804394
custom_status_emoji=self.my_status["custom_status_emoji"],
43814395
activities=self.my_activities,
4396+
afk=self.my_status["afk"],
43824397
)
43834398
if self.my_status["custom_status_emoji"]:
43844399
custom_status_emoji_name = self.my_status["custom_status_emoji"]["name"]
@@ -7023,6 +7038,7 @@ def main(self):
70237038
custom_status=self.my_status["custom_status"],
70247039
custom_status_emoji=self.my_status["custom_status_emoji"],
70257040
activities=self.my_activities,
7041+
afk=self.my_status["afk"],
70267042
)
70277043

70287044
# start input and sender threads
@@ -7184,6 +7200,7 @@ def main(self):
71847200
custom_status=self.my_status["custom_status"],
71857201
custom_status_emoji=self.my_status["custom_status_emoji"],
71867202
activities=self.my_activities,
7203+
afk=self.my_status["afk"],
71877204
)
71887205

71897206
# send new detectable games activities
@@ -7199,6 +7216,7 @@ def main(self):
71997216
custom_status=self.my_status["custom_status"],
72007217
custom_status_emoji=self.my_status["custom_status_emoji"],
72017218
activities=self.my_activities,
7219+
afk=self.my_status["afk"],
72027220
)
72037221

72047222
# remove expired typing
@@ -7309,6 +7327,7 @@ def main(self):
73097327
custom_status=self.my_status["custom_status"],
73107328
custom_status_emoji=self.my_status["custom_status_emoji"],
73117329
activities=self.my_activities,
7330+
afk=self.my_status["afk"],
73127331
)
73137332

73147333
# check changes in presences and update tree

endcord/assist_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
("custom_status [string] - set custom status text", "custom_status"),
5555
("custom_status_emoji [emoji] - set custom status emoji", "custom_status_emoji"),
5656
("custom_status_remove - remove custom status", "custom_status_remove"),
57+
("toggle_afk - toggle afk state; if afk, mobile devices will receive notifications", "toggle_afk"),
5758
("block *ignore <@[user_id]> - block/ignore user", "block"),
5859
("unblock *ignore <@[user_id]> - unblock/unignore user", "unblock"),
5960
("toggle_blocked_messages - toggle showing messages from blocked users in chat", "toggle_blocked_messages"),

endcord/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"format_interaction": " ╭──⤙ %global_name used [%command]",
8686
"format_one_reaction": "%count:%reaction",
8787
"format_timestamp": "%H:%M",
88-
"format_status_line_l": " %global_name (%username) - %status %unreads %action %typing",
88+
"format_status_line_l": " %global_name (%username) - %status %afk %unreads %action %typing",
8989
"format_status_line_r": "%slowmode",
9090
"format_title_line_l": " %server: %channel",
9191
"format_title_line_r": "%tabs",

endcord/discord.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ def get_reactions(self, channel_id, message_id, reaction):
442442
reaction.append({
443443
"id": user["id"],
444444
"username": user["username"],
445+
"global_name": user["global_name"],
445446
})
446447
return reaction
447448
logger.error(f"Failed to fetch reaction details: {reaction}. Response code: {response.status}")

endcord/formatter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,7 @@ def generate_status_line(my_user_data, my_status, unseen, typing, active_channel
14391439
%task # currently running long task
14401440
%tabs
14411441
%slowmode # 'slowmode {time}'
1442+
%afk # '[AFK]'
14421443
Possible options for format_rich:
14431444
%type
14441445
%name
@@ -1591,6 +1592,7 @@ def generate_status_line(my_user_data, my_status, unseen, typing, active_channel
15911592
.replace("%task", task)
15921593
.replace("%tabs", tabs)
15931594
.replace("%slowmode", slowmode)
1595+
.replace("%afk", "[AFK]" if my_status["afk"] else "")
15941596
)
15951597

15961598
status_line_format = []
@@ -2113,7 +2115,7 @@ def generate_extra_window_reactions(reaction, details, max_len):
21132115
title_line = f"Users who reacted {reaction["emoji"]}: "
21142116
body = []
21152117
for user in details:
2116-
body.append(user["username"][:max_len])
2118+
body.append(f"{user["global_name"]} ({user["username"]})"[:max_len])
21172119
return title_line[:max_len], body
21182120

21192121

endcord/parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,9 @@ def command_string(text):
847847
except (IndexError, ValueError):
848848
pass
849849

850+
# 65 - TOGGLE_AFK
851+
elif text_lower.startswith("toggle_afk"):
852+
cmd_type = 65
850853

851854
# 66 - 666
852855
elif text_lower == "666":

0 commit comments

Comments
 (0)