@@ -19,13 +19,13 @@ Instantiation
1919
2020You can instantiate a ` Bot ` instance by calling the ` createBot() ` function:
2121
22- ~~~~ typescript
23- import { createBot } from " @fedify/bot " ;
22+ ~~~~ typescript twoslash
23+ import { createBot } from " @fedify/botkit " ;
2424import { MemoryKvStore } from " @fedify/fedify" ;
2525
2626const bot = createBot <void >({
2727 username: " my_bot" ,
28- kv: new MemoryKvStore (kv ),
28+ kv: new MemoryKvStore (),
2929});
3030~~~~
3131
@@ -155,7 +155,8 @@ about the bot like the website URL, the source code repository URL, etc. here.
155155Note that the property names should be human-readable and property values are of
156156the ` Text ` type (see also the [ * Text* chapter] ( ./text.md ) ):
157157
158- ~~~~ typescript
158+ ~~~~ typescript twoslash
159+ // @noErrors: 2345
159160import { createBot , link , mention } from " @fedify/botkit" ;
160161
161162const bot = createBot <void >({
@@ -239,7 +240,8 @@ It consists of the following properties:
239240: The version of the bot software. It should be a ` SemVer ` object.
240241 You can create a ` SemVer ` object using the ` parseSemVer() ` function:
241242
242- ~~~~ typescript
243+ ~~~~ typescript twoslash
244+ // @noErrors: 2345
243245 import { createBot, parseSemVer } from "@fedify/botkit";
244246
245247 const bot = createBot<void>({
@@ -332,8 +334,9 @@ or [srvx] on Node.js.
332334For example, if you have a ` Bot ` object named ` bot ` , and ` export ` it as
333335a default export:
334336
335- ~~~~ typescript [bot.ts]
336- import { createBot } from " @fedify/bot" ;
337+ ~~~~ typescript [bot.ts] twoslash
338+ // @noErrors: 2345
339+ import { createBot } from " @fedify/botkit" ;
337340
338341const bot = createBot <void >({
339342 // Omitted other options for brevity
@@ -386,14 +389,18 @@ yarn add srvx
386389
387390Then, import [ ` serve() ` ] function from ` srvx ` module:
388391
389- ~~~~ typescript [bot.ts]
392+ ~~~~ typescript [bot.ts] twoslash
390393import { serve } from " srvx" ;
391394~~~~
392395
393396Finally, you can run the bot using the [ ` serve() ` ] function at the end of
394397the * bot.ts* file:
395398
396- ~~~~ typescript [bot.ts]
399+ ~~~~ typescript [bot.ts] twoslash
400+ import type { Bot } from " @fedify/botkit" ;
401+ import { serve } from " srvx" ;
402+ const bot = {} as unknown as Bot <void >;
403+ // ---cut-before---
397404const server = serve ({
398405 ... bot ,
399406 port: 8000 ,
@@ -426,8 +433,11 @@ It is recommended to have an environment variable to control
426433the [ ` behindProxy ` ] ( #createbotoptions-behindproxy ) option so that you can
427434easily switch between local development and production:
428435
429- ~~~~ typescript [bot.ts] {3-4,8}
430- import { createBot } from " @fedify/bot" ;
436+ ::: code-group
437+
438+ ~~~~ typescript [Deno] {3-4,8} twoslash
439+ // @noErrors: 2345
440+ import { createBot } from " @fedify/botkit" ;
431441
432442const BEHIND_PROXY =
433443 Deno .env .get (" BEHIND_PROXY" )?.trim ()?.toLowerCase () === " true" ;
@@ -438,6 +448,21 @@ const bot = createBot<void>({
438448});
439449~~~~
440450
451+ ~~~~ typescript [Node.js] {3-4,8} twoslash
452+ // @noErrors: 2345
453+ import { createBot } from " @fedify/botkit" ;
454+
455+ const BEHIND_PROXY =
456+ process .env .BEHIND_PROXY ?.trim ()?.toLowerCase () === " true" ;
457+
458+ const bot = createBot <void >({
459+ // Omitted other options for brevity
460+ behindProxy: BEHIND_PROXY ,
461+ });
462+ ~~~~
463+
464+ :::
465+
441466Then, you can use the following command to run the bot with the ` BEHIND_PROXY `
442467environment variable set to ` true ` :
443468
0 commit comments