-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc4566e
commit f14179c
Showing
8 changed files
with
112 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# What is it ? | ||
|
||
it's library for easier chat-bot state managment/peristion | ||
|
||
currently only telegram API supported, further extension for discrod API possible | ||
|
||
## Adding new state | ||
|
||
|
||
Describe state using actions like `say`, `expect`, `switchState` and others | ||
|
||
```ts | ||
|
||
export async function mainState() { | ||
|
||
await say('Enter a') | ||
|
||
const a = Number(await expect_()) | ||
|
||
await say('Enter b') | ||
|
||
const b = Number(await expect_()) | ||
|
||
await say("Reuslt is " + (a + b)) | ||
|
||
await switchState('mainState') | ||
} | ||
``` | ||
|
||
And then add that state to AllStates to safe typing | ||
|
||
```ts | ||
declare module 'chat-toolkit' { | ||
interface AllStates { | ||
mainState: typeof mainState | ||
} | ||
} | ||
``` | ||
|
||
|
||
# Modifing actions | ||
|
||
# TODO | ||
|
||
### Adjusting global state | ||
|
||
|
||
# TODO | ||
|
||
```ts | ||
declare module 'chat-toolkit' { | ||
interface GlobalSharedAppContext { | ||
|
||
} | ||
} | ||
``` | ||
|
||
|
||
## TODO | ||
- [ ] Notifications | ||
- [ ] Custom expects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,27 @@ | ||
// import * as tctx from './telegram/context' | ||
import { Context } from './state/state' | ||
import { _disableRecording, _onRestoreDoRun, escape_, expect_, random, say, suggest, suggestIt, switchState } from './lib/implicit_state' | ||
import { AllStates, Context } from './state/state' | ||
import { createPrivateTelegramContext } from './telegram/context' | ||
import { createTelegramHandler } from './telegram/handler' | ||
|
||
|
||
|
||
export { Context } | ||
|
||
export interface Test { | ||
a: number | ||
export { | ||
createPrivateTelegramContext, | ||
createTelegramHandler | ||
} | ||
|
||
// export const createPrivateTelegramContext = tctx.createPrivateTelegramContext | ||
export { | ||
suggestIt, | ||
_disableRecording, | ||
_onRestoreDoRun, | ||
escape_, | ||
say, | ||
random, | ||
suggest, | ||
switchState, | ||
expect_ | ||
} | ||
|
||
export { createPrivateTelegramContext, createTelegramHandler } | ||
export { | ||
AllStates | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { defineConfig } from "tsup"; | ||
|
||
export default defineConfig({ | ||
entry: ["src/test/a.ts"], | ||
entry: ["src/index.ts"], | ||
format: ["cjs", "esm"], // Build for commonJS and ESmodules | ||
dts: true, // Generate declaration file (.d.ts) | ||
splitting: false, | ||
sourcemap: true, | ||
clean: true, | ||
target: 'es2022', | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters