Skip to content

Commit

Permalink
Merge branch 'release/3.30.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dotcypress committed May 31, 2019
2 parents 1460c31 + 93c6657 commit 4f00a52
Show file tree
Hide file tree
Showing 9 changed files with 391 additions and 347 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: [dotcypress]
open_collective: telegraf
6 changes: 4 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ Users can interact with bots by sending them command messages in private or grou
These accounts serve as an interface for code running somewhere on your server.

![Telegraf](header.png)
[![Bot API Version](https://img.shields.io/badge/Bot%20API-v4.2-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api)
[![Bot API Version](https://img.shields.io/badge/Bot%20API-v4.3-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api)
[![NPM Version](https://img.shields.io/npm/v/telegraf.svg?style=flat-square)](https://www.npmjs.com/package/telegraf)
[![node](https://img.shields.io/node/v/telegraf.svg?style=flat-square)](https://www.npmjs.com/package/telegraf)
[![Build Status](https://img.shields.io/travis/telegraf/telegraf.svg?branch=master&style=flat-square)](https://travis-ci.org/telegraf/telegraf)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com/)

#### Features

- Full [Telegram Bot API 4.2](https://core.telegram.org/bots/api) support
- Full [Telegram Bot API 4.3](https://core.telegram.org/bots/api) support
- [Telegram Payment Platform](https://telegram.org/blog/payments)
- [HTML5 Games](https://core.telegram.org/bots/api#games)
- [Inline mode](https://core.telegram.org/bots/api#inline-mode)
Expand Down Expand Up @@ -65,6 +65,7 @@ For additional bot examples see [`examples`](https://github.com/telegraf/telegra

**Community bots:**

* [RandomPassBot: generate a password](https://github.com/Khuzha/randompassbot)
* [Referal system: channels promoter](https://github.com/Khuzha/refbot)
* [SimpleRegBot](https://github.com/Khuzha/simpleRegBot)
* [yt-search-bot](https://github.com/Finalgalaxy/yt-search-bot)
Expand Down Expand Up @@ -92,6 +93,7 @@ For additional bot examples see [`examples`](https://github.com/telegraf/telegra
* [Voicy](https://github.com/backmeupplz/voicy)
* [Watchy](https://github.com/backmeupplz/watchy)
* [Memcoin](https://github.com/backmeupplz/memcoin)
* [BooksAndBot](https://github.com/dmtrbrl/BooksAndBot)
* Send PR to add link to your bot

## Introduction
Expand Down
17 changes: 17 additions & 0 deletions docs/examples/login-bot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const Telegraf = require('telegraf')
const Extra = require('telegraf/extra')
const Markup = require('telegraf/markup')

const keyboard = Markup.inlineKeyboard([
Markup.loginButton('Login', 'https://domain.tld/hash', {
bot_username: 'my_bot',
request_write_access: 'true'
}),
Markup.urlButton('❤️', 'https://telegraf.js.org'),
Markup.callbackButton('Delete', 'delete')
])

const bot = new Telegraf(process.env.BOT_TOKEN)
bot.start((ctx) => ctx.reply('Hello', Extra.markup(keyboard)))
bot.action('delete', ({ deleteMessage }) => deleteMessage())
bot.launch()
4 changes: 2 additions & 2 deletions docs/examples/poll-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const { Composer } = Telegraf

const bot = new Telegraf(process.env.BOT_TOKEN)

bot.on('poll', (ctx) => ctx.reply('Poll update'))
bot.on('poll', (ctx) => console.log('Poll update', ctx.poll))

bot.start((ctx) => ctx.telegram.sendPoll('-100500100500100', '2b|!2b', ['True', 'False']))
bot.start((ctx) => ctx.telegram.sendPoll('group id', '2b|!2b', ['True', 'False']))

bot.command('poll', Composer.groupChat(
(ctx) => ctx.replyWithPoll('2b|!2b', ['True', 'False'])
Expand Down
15 changes: 15 additions & 0 deletions markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class Markup {
return Markup.payButton(text, hide)
}

loginButton (text, url, opts, hide) {
return Markup.loginButton(text, url, opts, hide)
}

static removeKeyboard (value) {
return new Markup().removeKeyboard(value)
}
Expand Down Expand Up @@ -145,6 +149,17 @@ class Markup {
static payButton (text, hide = false) {
return { text: text, pay: true, hide: hide }
}

static loginButton (text, url, opts = {}, hide = false) {
return {
text: text,
login_url: {
url: url,
...opts
},
hide: hide
}
}
}

function buildKeyboard (buttons, options) {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telegraf",
"version": "3.29.0",
"version": "3.30.0",
"description": "📡 Modern Telegram Bot Framework",
"license": "MIT",
"author": "Vitaly Domnikov <[email protected]>",
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"types": "./typings/index.d.ts",
"dependencies": {
"@types/node": "^11.12.1",
"@types/node": "^12.0.4",
"debug": "^4.0.1",
"node-fetch": "^2.2.0",
"sandwich-stream": "^2.0.1",
Expand All @@ -42,10 +42,10 @@
"eslint-config-standard": "^12.0.0",
"eslint-plugin-ava": "^6.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-standard": "^4.0.0",
"husky": "^1.1.1",
"husky": "^2.3.0",
"typescript": "^3.0.1"
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ Users can interact with bots by sending them command messages in private or grou
These accounts serve as an interface for code running somewhere on your server.

![Telegraf](docs/header.png)
[![Bot API Version](https://img.shields.io/badge/Bot%20API-v4.2-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api)
[![Bot API Version](https://img.shields.io/badge/Bot%20API-v4.3-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api)
[![NPM Version](https://img.shields.io/npm/v/telegraf.svg?style=flat-square)](https://www.npmjs.com/package/telegraf)
[![node](https://img.shields.io/node/v/telegraf.svg?style=flat-square)](https://www.npmjs.com/package/telegraf)
[![Build Status](https://img.shields.io/travis/telegraf/telegraf.svg?branch=master&style=flat-square)](https://travis-ci.org/telegraf/telegraf)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com/)

### Features

- Full [Telegram Bot API 4.2](https://core.telegram.org/bots/api) support
- Full [Telegram Bot API 4.3](https://core.telegram.org/bots/api) support
- [Telegram Payment Platform](https://telegram.org/blog/payments)
- [HTML5 Games](https://core.telegram.org/bots/api#games)
- [Inline mode](https://core.telegram.org/bots/api#inline-mode)
Expand Down
63 changes: 43 additions & 20 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,25 +693,41 @@ export interface Telegram {
* @returns True on success
*/
setWebhook(url: string, cert?: tt.InputFile, maxConnections?: number, allowedUpdates?: string[]): Promise<boolean>;

/**
* Use this method to delete webhook
* @returns True on success
*/
deleteWebhook (): Promise<boolean>;
*/
deleteWebhook(): Promise<boolean>;

/**
* Use this method to get information about set webhook
* @returns a WebhookInfo on success
*/
getWebhookInfo (): Promise<tt.WebhookInfo>;
*/
getWebhookInfo(): Promise<tt.WebhookInfo>;

/**
* Use this method to get link to a file by file id
* @param fileId Id of file to get link to
* @returns a String with an url to the file
*/
getFileLink (fileId: string): Promise<string>;
*/
getFileLink(fileId: string): Promise<string>;

/**
* Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
* @param userId Unique identifier of the target user
* @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
* @returns True on success
*/
kickChatMember(chatId: number | string, userId: number, untilDate?: number): Promise<boolean>;

/**
* Use this method to get updates from Telegram server. Bot should be in `polling` mode
* @returns Array of updates
*/
getUpdates(): Promise<any[]>;

}

export interface TelegramConstructor {
Expand Down Expand Up @@ -787,9 +803,9 @@ export interface Composer<TContext extends ContextMessageUpdate> {

export interface ComposerConstructor {

new<TContext extends ContextMessageUpdate>(): Composer<TContext>;
new <TContext extends ContextMessageUpdate>(): Composer<TContext>;

new<TContext extends ContextMessageUpdate>(...middlewares: Array<Middleware<TContext>>): Composer<TContext>;
new <TContext extends ContextMessageUpdate>(...middlewares: Array<Middleware<TContext>>): Composer<TContext>;

/**
* Compose middlewares returning a fully valid middleware comprised of all those which are passed.
Expand All @@ -803,23 +819,23 @@ export interface ComposerConstructor {
* @param middleware Middleware function
*/
mount<TContext extends ContextMessageUpdate, UContext extends ContextMessageUpdate>
(updateTypes: tt.UpdateType | tt.UpdateType[], middleware: Middleware<TContext>): Middleware<UContext>
(updateTypes: tt.UpdateType | tt.UpdateType[], middleware: Middleware<TContext>): Middleware<UContext>

/**
* Generates middleware for handling text messages with regular expressions.
* @param triggers Triggers
* @param handler Handler
*/
hears<TContext extends ContextMessageUpdate, UContext extends ContextMessageUpdate>
(triggers: HearsTriggers, handler: Middleware<TContext>): Middleware<UContext>
(triggers: HearsTriggers, handler: Middleware<TContext>): Middleware<UContext>

/**
* Generates middleware for handling callbackQuery data with regular expressions.
* @param triggers Triggers
* @param handler Handler
*/
action<TContext extends ContextMessageUpdate, UContext extends ContextMessageUpdate>
(triggers: HearsTriggers, handler: Middleware<TContext>): Middleware<UContext>
(triggers: HearsTriggers, handler: Middleware<TContext>): Middleware<UContext>

/**
* Generates pass thru middleware.
Expand All @@ -837,14 +853,14 @@ export interface ComposerConstructor {
* @param middleware Middleware function
*/
optional<TContext extends ContextMessageUpdate, UContext extends ContextMessageUpdate>
(test: boolean | ((ctx: TContext) => boolean), middleware: Middleware<TContext>): Middleware<UContext>
(test: boolean | ((ctx: TContext) => boolean), middleware: Middleware<TContext>): Middleware<UContext>

/**
* Generates filter middleware.
* @param test Value or predicate (ctx) => bool
*/
filter<TContext extends ContextMessageUpdate>
(test: boolean | ((ctx: TContext) => boolean)): Middleware<TContext>
(test: boolean | ((ctx: TContext) => boolean)): Middleware<TContext>

/**
* Generates branch middleware.
Expand All @@ -853,7 +869,7 @@ export interface ComposerConstructor {
* @param falseMiddleware false action middleware
*/
branch<TContext extends ContextMessageUpdate, UContext extends ContextMessageUpdate, VContext extends ContextMessageUpdate, WContext extends ContextMessageUpdate>
(test: boolean | ((ctx: TContext) => boolean), trueMiddleware: Middleware<UContext>, falseMiddleware: Middleware<VContext>): Middleware<WContext>
(test: boolean | ((ctx: TContext) => boolean), trueMiddleware: Middleware<UContext>, falseMiddleware: Middleware<VContext>): Middleware<WContext>

reply<TContext extends ContextMessageUpdate>(text: string, extra?: tt.ExtraReplyMessage): Middleware<TContext>

Expand Down Expand Up @@ -898,7 +914,12 @@ export interface Telegraf<TContext extends ContextMessageUpdate> extends Compose
*
* @param options [See reference to get more]{@link https://telegraf.js.org/#/?id=launch}
*/
launch(options?: Object): Promise<any>
launch(
options?: {
polling?: { timeout?: number, limit?: number, allowedUpdates?: tt.UpdateType[] },
webhook?: { webhookPath: string, tlsOptions: TlsOptions | null, port: number, host?: string }
}
): Promise<void>

/**
* Start poll updates.
Expand Down Expand Up @@ -1019,7 +1040,7 @@ export class Markup {

oneTime(value?: boolean): Markup;

inlineKeyboard(buttons: CallbackButton[] | CallbackButton[][] | UrlButton[] | UrlButton[][], options: object): tt.InlineKeyboardMarkup;
inlineKeyboard(buttons: Buttons[] | Buttons[][], options: object): tt.InlineKeyboardMarkup;

button(text: string, hide: boolean): Button;

Expand Down Expand Up @@ -1113,10 +1134,12 @@ export interface TelegrafConstructor {
* new Telegraf(token, options)
*/
new <TContext extends ContextMessageUpdate>(token: string, options?: TelegrafOptions): Telegraf<TContext>;

log(logFn?: Function): Middleware<ContextMessageUpdate>;
}

export interface TOptions {

/**
* Telegram options
*/
Expand Down
Loading

0 comments on commit 4f00a52

Please sign in to comment.