You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何读取Discord通知以触发本地电脑操作?

Reading Discord Notifications to Trigger Local Actions

Hey there, let's walk through practical solutions to your problem since you've already hit roadblocks with Windows Action Center and Wireshark. Here are your most viable options:

1. Use Discord's Official Bot/API (Most Reliable Approach)

Since Windows Action Center lacks a public API for cross-app notification access, going straight to Discord's native tools is the cleanest fix. You can build a simple Discord bot that listens for events like @mentions, direct messages, or channel alerts, then triggers local actions when those events fire.

For example, with Python's discord.py library:

import discord
import os

# Enable required intents in your Discord Developer Portal first
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)

@client.event
async def on_ready():
    print(f'Logged in as {client.user}')

@client.event
async def on_message(message):
    # Ignore messages sent by the bot itself
    if message.author == client.user:
        return
    
    # Trigger local action if you're mentioned
    if client.user in message.mentions:
        # Replace with your desired local action (e.g., open a program, run a script)
        os.system('notepad.exe')
        await message.channel.send("Local action triggered!")

client.run('YOUR_BOT_TOKEN')

Note: You'll need to create a Discord Developer account, register a bot, invite it to your server, and enable necessary intents (like message content intent) in the Discord Developer Portal.

2. Capture Notifications via Windows UI Automation

If you can't use Discord's API, you can scrape Windows' notification popups directly using UI automation tools. Libraries like pywinauto (for Python) let you locate and read Discord's notification windows.

Here's a quick implementation:

from pywinauto import Desktop
import time
import os

def check_discord_notifications():
    desktop = Desktop(backend='uia')
    # Locate windows matching Discord's notification title pattern
    discord_notifs = desktop.windows(title_re="Discord.*Notification", control_type="Window")
    
    for notif in discord_notifs:
        # Extract the full notification text
        notif_text = notif.text()
        print(f"Detected Discord notification: {notif_text}")
        # Trigger your local action here
        # os.system('your_local_script.bat')

# Run in a loop to check for new notifications periodically
while True:
    check_discord_notifications()
    time.sleep(5)

This targets the visual elements of Discord's popups, so it's a bit fragile if Discord updates their notification UI, but it's a solid workaround when APIs aren't an option.

3. Decrypt Discord Traffic (Advanced, Proceed with Caution)

You mentioned Wireshark couldn't read encrypted traffic—you can decrypt it by capturing Discord's SSL keys:

  • Set the Windows environment variable SSLKEYLOGFILE to a path like C:\ssl_keys.log
  • Restart Discord (it will write TLS session keys to this file)
  • In Wireshark, go to Edit > Preferences > Protocols > TLS, set the "(Pre)-Master-Secret log filename" to your ssl_keys.log file
  • Wireshark will now decrypt Discord's HTTPS traffic

Important: This method may violate Discord's Terms of Service, so use it only for personal, non-commercial purposes and at your own risk.


内容的提问来源于stack exchange,提问作者Notbad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:22:18