问题描述
const result = await bot.api.views.open({
trigger_id: message.trigger_id,view: {
"type": "modal","submit": {
"type": "plain_text","text": "Submit","emoji": true
},"title": {
"type": "plain_text","text": "Request","blocks": [
{
"type": "input","block_id" : "accblock","element": {
"type": "plain_text_input","action_id": "account_name","multiline": false
},"label": {
"type": "plain_text","text": "Account Name","emoji": true
}
}
]
}
});
如果在view_submission
上输入了某个值,我需要向块添加错误。我了解我应该使用以下JSON发送响应:
{
response_action: 'errors',errors: {
"ticket-desc": 'I will never accept a value,you are doomed!'
}
}
但是,我该如何发送?我尝试使用bot.httpBody()
。是否需要将此JSON作为视图对象包括在内?任何帮助表示赞赏。
解决方法
import time
import torch
for i in range(100):
a = torch.rand(50000,256).cuda()
b = torch.rand(50000,256).cuda()
t1 = time.time()
val = torch.diag(a @ b.t())
t2 = time.time()
val2 = torch.einsum('ij,ij->i',a,b)
t3 = time.time()
print(t2-t1,t3-t2,torch.allclose(val,val2))
是您需要的方法。
确保bot.httpBody()
字典的关键字与您要为其提供错误消息的元素的errors
匹配。
在您的情况下,它将起作用:
block_id
您不需要bot.httpBody({
response_action: 'errors',errors: {
accblock: 'Your account name is invalid or in use.'
}
})
响应消息,并且确实可以完成该过程。