简体   繁体   English

时间驱动触发器:是否可以每分钟为部署脚本应用程序/gmail 附加组件设置一个触发器?

[英]Time-driven Trigger : Possibility to set a trigger up every minute for a deploy script app / gmail add-on?

I'm developing a google script app in order to deploy a gmail add-on.我正在开发一个谷歌脚本应用程序以部署一个 gmail 插件。

I try to set a trigger up every minute, which executes a function, with the following code :我尝试每分钟设置一个触发器,它执行一个函数,代码如下:

ScriptApp.newTrigger(FUNCTION_TRIGGERED)
              .timeBased()
              .everyMinutes(1)
              .create(); 

The problem is, when I'm running the function in the google developer hub, it works, the time trigger is created.问题是,当我在谷歌开发者中心运行该功能时,它可以工作,时间触发器被创建。

But when I deploy the script as a gmail add-on from the manifest file and I want to create the trigger on a button click, an error appears telling me that the trigger range between two occurrences must be at least every hour.但是,当我将脚本作为清单文件中的 gmail 附加组件部署并且我想在单击按钮时创建触发器时,会出现一个错误,告诉我两次事件之间的触发器范围必须至少为每小时一次。

And the weirdest thing is when I set the trigger up every hour, I can change it to every minute in the trigger options, in the g suite developer hub.最奇怪的是,当我每小时设置一次触发器时,我可以在 g Suite 开发人员中心的触发器选项中将其更改为每分钟一次。 Why would I could do that ?为什么我可以这样做?

I wish to know if it's possible to create a trigger within a gmail add-on which triggered the same function every minute.我想知道是否可以在每分钟触发相同功能的 gmail 附加组件中创建触发器。 Or, is it definitely impossible ?或者,这绝对不可能吗?

Setting a time-driven trigger programmatically to run every minute through an add-on is impossible以编程方式设置时间驱动触发器以通过附加组件每分钟运行一次是不可能的

From https://developers.google.com/apps-script/guides/triggers/installable#time-driven_triggers来自https://developers.google.com/apps-script/guides/triggers/installable#time-driven_triggers

(Note that an add-on can use a time-driven trigger once per hour at most.) (请注意,附加组件最多可以每小时使用一次时间驱动触发器。)

While only Google could say why this is this way, we could assume that as an add-on could be installed by many users (potentially millions of users) setting this limitation is a way to prevent over loading the Internet and to prevent abuses.虽然只有 Google 可以说明为什么会这样,但我们可以假设许多用户(可能有数百万用户)可以安装附加组件,设置此限制是一种防止互联网过载和滥用的方法。

I never tried to edit the trigger settings from a trigger created by add-on from another developer, so I can't tell you for sure if you was able to edit the trigger settings only because you are the Apps Script project owner or if this something that could be done by any add-on user.我从未尝试从由其他开发人员的附加组件创建的触发器中编辑触发器设置,因此我无法确定您是否仅因为您是 Apps 脚本项目所有者而能够编辑触发器设置,或者任何附加用户都可以完成的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM