Skip to content

Commit

Permalink
Add new commands to Discord (talonhub#937)
Browse files Browse the repository at this point in the history
This adds some new commands to discord, and additionally fixes an
existing command.

I have only implemented these commands currently on Windows, as that is
the OS that I use.

This is my first contribution to this repository, so do tell me if I'm
doing anything wrong.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: David Vo <[email protected]>
  • Loading branch information
3 people authored Oct 16, 2022
1 parent fc16824 commit 9c9e640
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
25 changes: 24 additions & 1 deletion apps/discord/discord.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from talon import Module
from talon import Context, Module

mod = Module()
apps = mod.apps
Expand All @@ -9,6 +9,20 @@
browser.host: discord.com
"""

mod.list("discord_destination", desc="discord destination")

ctx = Context()
ctx.matches = r"""
app: discord
"""

ctx.lists["user.discord_destination"] = {
"user": "@",
"channel": "#",
"voice": "!",
"server": "*",
}


@mod.action_class
class discord_actions:
Expand Down Expand Up @@ -50,3 +64,12 @@ def discord_answer_call():

def discord_decline_call():
"""Decline incoming call"""

def discord_quick_switcher(dest_type: str, dest_search: str):
"""Open up the quick switcher, optionally specifying a type of destination"""

def discord_go_current_call():
"""Go to current call"""

def discord_toggle_dms():
"""Toggle between dms and your most recent server"""
8 changes: 8 additions & 0 deletions apps/discord/discord.talon
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ tag(): user.emoji
[channel] mentions last: user.discord_mentions_last()
[channel] mentions next: user.discord_mentions_next()
oldest unread: user.discord_oldest_unread()
{user.discord_destination} [<user.text>]:
user.discord_quick_switcher(user.discord_destination, user.text or "")
switcher: user.discord_quick_switcher("", "")
current call: user.discord_go_current_call()
toggle (dee ems | dims): user.discord_toggle_dms()

# UI
toggle pins: user.discord_toggle_pins()
Expand All @@ -18,6 +23,9 @@ pick (jif | gif | gift): user.discord_gif_picker()
# Misc
mark inbox channel read: user.discord_mark_inbox_read()
[toggle] (mute | unmute): user.discord_mute()
(mute | unmute) and sleep:
user.discord_mute()
speech.disable()
[toggle] (deafen | undeafen): user.discord_deafen()
answer call: user.discord_answer_call()
decline call: user.discord_decline_call()
14 changes: 13 additions & 1 deletion apps/discord/discord_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def discord_mentions_next():
actions.key("ctrl-alt-shift-down")

def discord_oldest_unread():
actions.key("shift-paegup")
actions.key("shift-pageup")

# UI
def discord_toggle_pins():
Expand Down Expand Up @@ -82,3 +82,15 @@ def discord_answer_call():

def discord_decline_call():
actions.key("esc")

def discord_go_current_call():
actions.key("ctrl-shift-alt-v")

def discord_toggle_dms():
actions.key("ctrl-alt-right")

def discord_quick_switcher(dest_type: str, dest_search: str):
actions.key("ctrl-k")
actions.insert(dest_type)
if dest_search:
actions.insert(dest_search)

0 comments on commit 9c9e640

Please sign in to comment.