mirror of
https://github.com/zhigang1992/mtcute.git
synced 2026-04-29 04:35:08 +08:00
chore: deprecated .run method
This commit is contained in:
@@ -39,9 +39,8 @@ dp.onNewMessage(filters.chat('private'), async (msg) => {
|
||||
await msg.replyText('hiiii from mtcute! 🌸')
|
||||
})
|
||||
|
||||
tg.run({ /* optional params */ }, async (self) => {
|
||||
console.log(`✨ logged in as ${self.displayName}`)
|
||||
})
|
||||
const self = await tg.start({ /* optional params */ }
|
||||
console.log(`✨ logged in as ${self.displayName}`)
|
||||
```
|
||||
|
||||
mtcute is a modern, performant and *✨ cute ✨* [mtproto](https://mtcute.dev/guide/intro/mtproto-vs-bot-api.html) library and bot framework,
|
||||
|
||||
@@ -19,7 +19,6 @@ const tg = new TelegramClient({
|
||||
storage: 'my-account'
|
||||
})
|
||||
|
||||
tg.run(async (user) => {
|
||||
console.log(`✨ logged in as ${user.displayName}`)
|
||||
})
|
||||
const self = await tg.start()
|
||||
console.log(`✨ logged in as ${self.displayName}`)
|
||||
```
|
||||
|
||||
@@ -76,10 +76,10 @@ export class TelegramClient extends TelegramClientBase {
|
||||
|
||||
/**
|
||||
* Tiny wrapper over Node `readline` package
|
||||
* for simpler user input for `.run()` method.
|
||||
* for simpler user input for `.start()` method.
|
||||
*
|
||||
* Associated `readline` interface is closed
|
||||
* after `run()` returns, or with the client.
|
||||
* after `start()` returns, or with the client.
|
||||
*
|
||||
* @param text Text of the question
|
||||
*/
|
||||
|
||||
@@ -39,11 +39,10 @@ const tg = new TelegramClient({
|
||||
// ... same options as above
|
||||
})
|
||||
|
||||
tg.run({
|
||||
const self = await tg.start({
|
||||
phone: '+1234567890',
|
||||
code: () => prompt('Enter the code:'),
|
||||
password: 'my-password',
|
||||
}, async (user) => {
|
||||
console.log(`✨ logged in as ${user.displayName}`)
|
||||
})
|
||||
console.log(`✨ logged in as ${self.displayName}`)
|
||||
```
|
||||
@@ -672,6 +672,7 @@ export interface TelegramClient extends ITelegramClient {
|
||||
*
|
||||
* @param params Parameters to be passed to {@link start}
|
||||
* @param then Function to be called after {@link start} returns
|
||||
* @deprecated This method provides no real value over {@link start}, please use it instead
|
||||
*/
|
||||
run(params: Parameters<typeof start>[1], then?: (user: User) => void | Promise<void>): void
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@ import { start } from './start.js'
|
||||
*
|
||||
* @param params Parameters to be passed to {@link start}
|
||||
* @param then Function to be called after {@link start} returns
|
||||
* @deprecated This method provides no real value over {@link start}, please use it instead
|
||||
*/
|
||||
export function run(
|
||||
client: ITelegramClient,
|
||||
|
||||
@@ -19,7 +19,6 @@ const tg = new TelegramClient({
|
||||
storage: 'my-account'
|
||||
})
|
||||
|
||||
tg.run(async (user) => {
|
||||
console.log(`✨ logged in as ${user.displayName}`)
|
||||
})
|
||||
const self = await tg.start()
|
||||
console.log(`✨ logged in as ${self.displayName}`)
|
||||
```
|
||||
|
||||
@@ -21,7 +21,6 @@ const tg = new TelegramClient({
|
||||
storage: 'my-account'
|
||||
})
|
||||
|
||||
tg.run(async (user) => {
|
||||
console.log(`✨ logged in as ${user.displayName}`)
|
||||
})
|
||||
const self = await tg.start()
|
||||
console.log(`✨ logged in as ${self.displayName}`)
|
||||
```
|
||||
|
||||
@@ -90,10 +90,10 @@ export class TelegramClient extends TelegramClientBase {
|
||||
|
||||
/**
|
||||
* Tiny wrapper over Node `readline` package
|
||||
* for simpler user input for `.run()` method.
|
||||
* for simpler user input for `.start()` method.
|
||||
*
|
||||
* Associated `readline` interface is closed
|
||||
* after `run()` returns, or with the client.
|
||||
* after `start()` returns, or with the client.
|
||||
*
|
||||
* @param text Text of the question
|
||||
*/
|
||||
|
||||
@@ -19,9 +19,8 @@ const tg = new TelegramClient({
|
||||
storage: 'my-account'
|
||||
})
|
||||
|
||||
tg.run(async (user) => {
|
||||
console.log(`✨ logged in as ${user.displayName}`)
|
||||
})
|
||||
const self = await tg.start()
|
||||
console.log(`✨ logged in as ${self.displayName}`)
|
||||
```
|
||||
|
||||
## Usage with workers
|
||||
@@ -47,7 +46,6 @@ const worker = new Worker(new URL('./worker.ts', import.meta.url), { type: 'modu
|
||||
const port = new TelegramWorkerPort({ worker })
|
||||
const tg = new TelegramClient({ client: port })
|
||||
|
||||
tg.run({}, async (user) => {
|
||||
console.log(`✨ logged in as ${user.displayName}`)
|
||||
})
|
||||
const self = await tg.start()
|
||||
console.log(`✨ logged in as ${user.displayName}`)
|
||||
```
|
||||
Reference in New Issue
Block a user