# Airgram for `tdweb`
Use [`tdweb`](https://github.com/tdlib/td/tree/master/example/web/tdweb) on steroids.
## Features
- Strictly typed;
- Documentation out of the box;
- Supports models;
- Built on middleware;
All TDLib classes and methods are described and have suitable wrappers in Airgram. There are only two differences:
- All parameter names are represent in "camelCase".
- Parameter `@type` renamed to `_`.
## Documentation
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Api reference](#api-reference)
---
Check out `airgram` documentation:
- [Middleware](https://github.com/airgram/airgram#middleware)
- [Getting updates](https://github.com/airgram/airgram#getting-updates)
---
TDLib API reference:
- [TDLib methods](https://github.com/airgram/airgram-api/tree/master/docs/td-methods.md)
- [TDLib input types](https://github.com/airgram/airgram-api/tree/master/docs/td-inputs.md)
- [TDLib output types](https://github.com/airgram/airgram-api/tree/master/docs/td-outputs.md)
## Installation
```bash
npm install tdweb-airgram
```
## Usage
- [Webpack example](https://github.com/airgram/tdweb-airgram/tree/master/examples/webpack-config)
- [Rollup example](https://github.com/airgram/tdweb-airgram/tree/master/examples/rollup-example)
## Configuration
This section describes the options you can pass to `Airgram` constructor:
```typescript
import { Airgram } from 'tdweb-airgram'
const airgram = new Airgram({
// options
})
```
### TDLib options
| Key | Type | Note |
| ------------------ | ------------------------ | ----------------------------------------------------------- |
| `useTestDc` | `boolean` | If set to true, the Telegram test environment will be used instead of the production environment |
| `databaseDirectory` | `string` | The path to the directory for the persistent database |
| `filesDirectory` | `string` | The path to the directory for storing files |
| `useFileDatabase` | `boolean` | If set to true, information about downloaded and uploaded files will be saved between application restarts |
| `useChatInfoDatabase` | `boolean` | If set to true, the library will maintain a cache of users, basic groups, supergroups, channels and secret chats. Implies `useFileDatabase` |
| `useMessageDatabase` | `boolean` | If set to true, the library will maintain a cache of chats and messages. Implies `useChatInfoDatabase` |
| `useSecretChats` | `boolean` | If set to true, support for secret chats will be enabled |
| `apiId` | `number` | Application identifier for Telegram API access, which can be obtained at https://my.telegram.org |
| `apiHash` | `string` | Application identifier hash for Telegram API access, which can be obtained at https://my.telegram.org |
| `systemLanguageCode` | `string` | IETF language tag of the user's operating system language |
| `deviceModel` | `string` | Model of the device the application is being run on |
| `systemVersion` | `string` | Version of the operating system the application is being run on |
| `applicationVersion` | `string` | Application version |
| `enableStorageOptimizer` | `boolean` | If set to true, old files will automatically be deleted |
| `ignoreFileNames` | `boolean` | If set to true, original file names will be ignored. Otherwise, downloaded files will be saved under names as close as possible to the original name |
| `databaseEncryptionKey` | `string` | Encryption key |
### `tdweb` options:
| Key | Type | Note |
| ------------------ | ------------------------ | ----------------------------------------------------------- |
| `instanceName` | `string` | Name of the TDLib instance. Currently only one instance of TdClient with a given name is allowed. All but one instances with the same name will be automatically closed. Usually, the newest non-background instance is kept alive. Files will be stored in an IndexedDb table with the same name. |
| `isBackground` | `boolean` | Pass true, if the instance is opened from the background. Default: `false` |
| `jsLogVerbosityLevel` | `string` | The initial verbosity level of the JavaScript part of the code (one of 'error', 'warning', 'info', 'log', 'debug'). Default: `info` |
| `logVerbosityLevel` | `number` | The initial verbosity level for the TDLib internal logging (0-1023). Default: 2 |
| `useDatabase` | `boolean` | Pass false to use TDLib without database and secret chats. It will significantly improve loading time, but some functionality will be unavailable. Default: `true` |
| `readOnly` | `boolean` | For debug only. Pass true to open TDLib database in read-only mode. Default: `false` |
| `mode` | `string` | For debug only. The type of the TDLib build to use. 'asmjs' for asm.js and 'wasm' for WebAssembly. If mode == 'auto' WebAbassembly will be used if supported by browser, asm.js otherwise. Default: `auto` |
### Other options
| Key | Type | Note |
| ------------------ | ------------------------ | ----------------------------------------------------------- |
| `models` | Function | Contains function, which converts plain JSON objects to models. [Details](https://github.com/airgram/airgram-use-models). |
| `contextFactory` | Function | Function that returns custom middleware context. [Details](#ctx). |
## API reference
This section describes public API of an `Airgram` instance:
| Key | Type | Note |
| ------------------ | ------------------------ | ----------------------------------------------------------- |
| `api` | Object | Contains wrappers for all [TDLib methods](https://github.com/airgram/airgram-api/blob/master/docs/td-methods.md). |
| `config` | Object | Airgram configuration. Readonly. |
| `catch` | `(handler) => void` | Overrides default error handler. Argument `handler` takes a function: `(error: Error, ctx?: Record<string, any>) => void` |
## License
The source code is licensed under GPL v3. License is available [here](/LICENSE).
没有合适的资源?快使用搜索试试~ 我知道了~
使用 Typescript/JavaScript 创建 Telegram 应用程序的严格类型库(基于 TDLib 1.8)
共2000个文件
ts:2091个
json:29个
md:17个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 46 浏览量
2022-07-02
00:57:45
上传
评论
收藏 1.29MB ZIP 举报
温馨提示
_TypeScript_代码_下载 这是一个用 TypeScript 编写的Telegram 数据库库的包装器。 代码风格。TDLib 遵循与 TypeScript 或 JavaScript 中的最佳实践不同的编码约定。Airgram 修复了它。 方法。每个 API 方法都有方便的包装器,带有描述和 JSDoc 文档。 类型检查。Airgram 是一个真正的 TypeScript 库。一切都有严格的类型,所以要充分利用类型检查和代码完成。 灵活性。Airgram 依赖于中间件。这提供了高度的自由度。您可以修改请求、保存响应、执行数据流中的任何操作。 数据模型。您可以扩展标准 TDLib 对象并添加一些计算属性或任何您想要的。 到处使用。Airgram 是一个与环境无关的库。它可以在浏览器和 Node.js 中工作。您可以编写 Telegram 客户端或将其用于 Telegram bot 后端。 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
使用 Typescript/JavaScript 创建 Telegram 应用程序的严格类型库(基于 TDLib 1.8)
(2000个子文件)
.babelrc 255B
.editorconfig 214B
.eslintignore 65B
.gitignore 2KB
.gitignore 4B
index.html 457B
webpack.config.js 3KB
.eslintrc.js 1KB
jest.config.js 224B
jest.config.js 46B
jest.config.js 46B
jest.config.js 46B
package-lock.json 87KB
package.json 2KB
package.json 2KB
package.json 873B
package.json 675B
package.json 670B
package.json 666B
package.json 626B
package.json 618B
package.json 562B
package.json 554B
package.json 536B
lerna.json 535B
tsconfig.json 494B
nodemon.json 445B
nodemon.json 270B
nodemon.json 270B
nodemon.json 270B
nodemon.json 270B
tsconfig.json 251B
tsconfig.json 238B
tsconfig.json 214B
tsconfig.json 190B
tsconfig.json 188B
tsconfig.json 161B
tsconfig.json 141B
tsconfig.json 118B
tsconfig.json 118B
tsconfig.json 118B
localhost.key 2KB
LICENSE 34KB
yarn.lock 544KB
CHANGELOG.md 8KB
CHANGELOG.md 8KB
CHANGELOG.md 8KB
CHANGELOG.md 8KB
README.md 6KB
README.md 3KB
CHANGELOG.md 2KB
ISSUE_TEMPLATE.md 467B
README.md 447B
README.md 441B
README.md 422B
README.md 402B
README.md 362B
README.md 330B
README.md 90B
README.md 85B
README.md 78B
rootCAKey.pem 2KB
rootCACert.pem 977B
readme-banner.svg 3KB
api-middleware.ts 115KB
Update.ts 37KB
index.ts 33KB
methods.ts 26KB
api-methods.ts 24KB
index.ts 18KB
MessageContent.ts 15KB
InputInlineQueryResult.ts 12KB
index.ts 10KB
InputMessageContent.ts 10KB
InputMessageContent.ts 10KB
InternalLinkType.ts 10KB
ChatEventAction.ts 10KB
index.ts 10KB
Auth.ts 9KB
PushMessageContent.ts 8KB
AirgramCore.ts 8KB
TdJsonClient.ts 7KB
PageBlock.ts 7KB
FakeJsonClient.ts 6KB
Update.ts 5KB
Message.ts 5KB
ChatMemberStatus.ts 5KB
Message.ts 5KB
gulpfile.ts 5KB
ChatMemberStatus.ts 5KB
Composer.ts 5KB
airgram.ts 4KB
InputPassportElement.ts 4KB
InlineQueryResult.ts 4KB
Chat.ts 4KB
ChatStatistics.ts 4KB
DeviceToken.ts 4KB
Chat.ts 4KB
TextEntityType.ts 4KB
AuthorizationState.ts 4KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- 油菜花地养金鱼2022-12-19感谢大佬分享的资源,对我启发很大,给了我新的灵感。
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 农村信用社联合社计算机信息系统投产与变更管理办.docx
- 农村信用社联合社计算机信息系统数据管理办法.docx
- 利用SPSS作临床效度分析线上计算网站介绍-医学研究部统计谘.(医学PPT课件).ppt
- 利用Zabbix监控mysqldump定时备份数据库状态.docx
- 利用计算机解决问题的基本过程.doc
- 化工铁路通信工程总结.doc
- 北京大学网络教育软件工程作业.docx
- 医药公司(连锁店)计算机操作规程未新系统的自行按照旧制修改-新系统过制的编号加修模版.doc
- 医药公司(连锁店)计算机系统操作规程模版.doc
- 医药连锁门店计算机系统的操作和管理程序未新系统的自行按照旧制修改-新系统过制的编号加修模版.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功