MCPcopy Create free account
hub / github.com/Botloader/botloader / onTask

Method onTask

components/runtime/src/ts/script.ts:201–216  ·  view source on GitHub ↗

* Register a scheduled task handler for the provided namespace. * * See Tasks for more info about scheduled tasks and how to schedule a new one. * * @param namespace The task namespace to handle tasks from * @param cb The callback function to run, with the type of

(namespace: string, cb: (task: Tasks.Task<T>) => any)

Source from the content-addressed store, hash-verified

199 * ```
200 */
201 async onTask<T>(namespace: string, cb: (task: Tasks.Task<T>) => any) {
202 this.taskHandlers.push({
203 name: namespace,
204 pluginId: null,
205 });
206
207 this.events.on("BOTLOADER_SCHEDULED_TASK_FIRED", async (evt) => {
208 if (evt.namespace === namespace && evt.pluginId == null) {
209 await cb({
210 ...evt,
211 pluginId: evt.pluginId,
212 data: evt.data as T,
213 });
214 }
215 })
216 }
217
218 createTaskBucket<T = undefined>(
219 options: {

Callers 4

pins.tsFile · 0.80
tasks_simple_1m.tsFile · 0.80
bad_requests.tsFile · 0.80
tasks_simple.tsFile · 0.80

Calls 1

onMethod · 0.45

Tested by

no test coverage detected