我有以下示例来说明我想要得到的内容。
const v1: { type: "S"; payload: string } = { type: "S", payload: "test" };
const v2: { type: "N"; payload: number } = { type: "N", payload: 123 };
type Actions = typeof v1 | typeof v2;
const findByType = <A extends Actions>(type: A["type"]) => (
action: Actions
): action is A => action.type === type;
const filterWithBothNameAndType = [v1, v2].filter(findByType<typeof v1>("S"));
console.log(filterWithBothNameAndType[0].payload.trim());
const findByTypeDoesntWork = <A extends Actions, T extends A["type"]>(type: T) => (
action: Actions
): …Run Code Online (Sandbox Code Playgroud) 我正在使用以下设置进行测试:我有一个禁用隐私模式的机器人,因此它会侦听频道中的所有消息。我在 Bot Framework 中设置了一个 webhook,用于打印所有传入的消息。我首先在 Telegram 网络上注意到了这个问题,后来发现它也会影响 Android,只有当您手动输入提及时,您才不会收到通知——如果您从下拉列表中选择一个提及,则会发送通知。
这是我发送消息的频道的屏幕截图:
这是我从 webhook 得到的消息:
new message: this message sent from web will be relayed even if it contains the mention @jlarky
new message: @JLarkyTestBot you can mention the bot though
new message: ^^ last message from web
new message: Now message from Android
new message: Yarosla mentions work
new message: Yarosla it has to be from mention dropdown, otherwise it's not sent either
Run Code Online (Sandbox Code Playgroud)
如您所见,其中只有一部分已交付。
trapexit.org上的非阻塞TCP服务器解释了如何基于tcp_gen构建服务器,但我想修改此示例并使其与ssl一起使用.现在我完全不知道如何更换
{ok, Ref} = prim_inet:async_accept(Listen_socket, -1)