@apidog/multibot-sdk-ts
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -11,4 +11,4 @@ /// <reference types="node" /> | ||
interface On { | ||
(event: MatchType.Message, listener: Listener<ArgumentMessage>): void; | ||
(event: MatchType.MessageEdited, listener: Listener<ArgumentMessage>): void; | ||
(event: MatchType.Message, listener: Listener<Message>): void; | ||
(event: MatchType.MessageEdited, listener: Listener<Message>): void; | ||
(event: MatchType.ChannelPost, listener: Listener<Message>): void; | ||
@@ -21,3 +21,5 @@ (event: MatchType.ChannelPostEdited, listener: Listener<Message>): void; | ||
(event: MatchType.ChosenInlineResult, listener: Listener<ChosenInlineResult>): void; | ||
(event: MatchType.Photo | MatchType.Video | MatchType.Audio | MatchType.Voice | MatchType.Animation | MatchType.Sticker, listener: Listener<ArgumentMessageWithFile>): void; | ||
(event: MatchType.Photo | MatchType.Video | MatchType.Audio | MatchType.Voice | MatchType.Animation | MatchType.Sticker, listener: Listener<Message & { | ||
getFileUrl: () => Promise<string>; | ||
}>): void; | ||
(event: MatchType.Location, listener: Listener<Location>): void; | ||
@@ -30,11 +32,5 @@ } | ||
message: Message; | ||
sender: User; | ||
from: User; | ||
chat: Chat; | ||
}; | ||
/** | ||
* Message argument with file | ||
*/ | ||
export interface ArgumentMessageWithFile extends ArgumentMessage { | ||
getFileUrl(): Promise<string>; | ||
} | ||
export declare type SendFile = string | Buffer; | ||
@@ -41,0 +37,0 @@ export declare class Bot extends AbstractBot<Config, Update> implements IBotPolling { |
@@ -35,15 +35,7 @@ "use strict"; | ||
exports.testMessage = testMessage; | ||
const handleMessage = ({ message }) => ({ | ||
message: message, | ||
chat: message.chat, | ||
from: message.from | ||
}); | ||
const handleMessage = ({ message }) => message; | ||
exports.handleMessage = handleMessage; | ||
const testMessageEdited = update => 'message_edited' in update; | ||
exports.testMessageEdited = testMessageEdited; | ||
const handleMessageEdited = ({ edited_message }) => ({ | ||
message: edited_message, | ||
chat: edited_message.chat, | ||
from: edited_message.from | ||
}); | ||
const handleMessageEdited = ({ edited_message }) => edited_message; | ||
exports.handleMessageEdited = handleMessageEdited; | ||
@@ -99,3 +91,7 @@ const testChannelPost = update => 'channel_post' in update; | ||
test: update => exports.testMessage(update) && field in update.message, | ||
handle: (update, bot) => (Object.assign(Object.assign({}, exports.handleMessage(update)), { getFileUrl: () => bot.request('getFile', { file_id: update.message.photo[0].file_id }) })), | ||
handle: (update, bot) => (Object.assign(Object.assign({}, exports.handleMessage(update)), { getFileUrl: () => bot.request('getFile', { | ||
file_id: ['photo', 'new_chat_photo'].includes(field) | ||
? update.message.photo[0].file_id | ||
: update.message[field].file_id, | ||
}) })), | ||
}); | ||
@@ -102,0 +98,0 @@ const mediaTypes = ['photo', 'video', 'audio', 'document', 'animation', 'voice', 'sticker', 'location', 'venue', 'contact', 'poll', 'game']; |
@@ -0,1 +1,2 @@ | ||
import { QuizType } from "./media"; | ||
export interface Markup { | ||
@@ -18,2 +19,3 @@ } | ||
request_location?: boolean; | ||
request_poll?: KeyboardButtonPollType; | ||
} | ||
@@ -24,2 +26,5 @@ export interface KeyboardRemoveMarkup extends Markup { | ||
} | ||
export declare type KeyboardButtonPollType = { | ||
type?: QuizType; | ||
}; | ||
/** | ||
@@ -26,0 +31,0 @@ * Inline keyboard |
@@ -66,2 +66,6 @@ import { MessageEntity, ParseMode } from '.'; | ||
latitude: number; | ||
horizontal_accuracy?: number; | ||
live_period?: number; | ||
heading?: number; | ||
proximity_alert_radius?: number; | ||
} | ||
@@ -74,2 +78,4 @@ export interface Venue { | ||
foursquare_type?: string; | ||
google_place_id?: string; | ||
google_place_type?: string; | ||
} | ||
@@ -102,2 +108,6 @@ export interface Contact { | ||
correct_option_id?: number; | ||
explanation?: string; | ||
explanation_entities?: MessageEntity[]; | ||
open_period?: number; | ||
close_date?: number; | ||
} | ||
@@ -152,1 +162,10 @@ export interface Game { | ||
export declare type QuizType = 'quiz' | 'regular'; | ||
export declare type Dice = { | ||
emoji: string; | ||
value: number; | ||
}; | ||
export declare type ProximityAlertTriggered = { | ||
traveler: User; | ||
watcher: User; | ||
distance: number; | ||
}; |
@@ -1,7 +0,7 @@ | ||
import { User, Chat, Markup, PhotoSize, Video, Audio, Document, Animation, Voice, Sticker, Location, Venue, Contact, Poll, Game } from '.'; | ||
import { User, Chat, Markup, PhotoSize, Video, Audio, Document, Animation, Voice, Sticker, Location, Venue, Contact, Poll, Game, Dice, ProximityAlertTriggered } from '.'; | ||
export interface Message { | ||
message_id: number; | ||
from?: User; | ||
sender_chat: Chat; | ||
date: number; | ||
edit_date?: number; | ||
chat: Chat; | ||
@@ -16,2 +16,4 @@ forward_from?: User; | ||
reply_markup?: Markup; | ||
via_bot?: User; | ||
edit_date?: number; | ||
media_group_id?: string; | ||
@@ -35,2 +37,4 @@ author_signature?: string; | ||
game?: Game; | ||
dice?: Dice; | ||
proximity_alert_triggered?: ProximityAlertTriggered; | ||
new_chat_members?: User[]; | ||
@@ -42,2 +46,3 @@ left_chat_member?: User; | ||
group_chat_created?: boolean; | ||
connected_website?: string; | ||
} | ||
@@ -44,0 +49,0 @@ export interface MessageEntity { |
import { PhotoSize, Message } from '.'; | ||
import { Location } from './media'; | ||
export interface User { | ||
@@ -21,2 +22,3 @@ id: number; | ||
photo?: ChatPhoto; | ||
bio?: string; | ||
description?: string; | ||
@@ -29,5 +31,7 @@ invite_link?: string; | ||
can_set_sticker_set?: boolean; | ||
linked_chat_id?: number; | ||
location?: ChatLocation; | ||
} | ||
export declare type ChatType = 'private' | 'group' | 'supergroup' | 'channel'; | ||
export interface ChatPhoto { | ||
export declare type ChatPhoto = { | ||
small_file_id: string; | ||
@@ -37,4 +41,4 @@ small_file_unique_id: string; | ||
big_file_unique_id: string; | ||
} | ||
export interface ChatPermissions { | ||
}; | ||
export declare type ChatPermissions = { | ||
can_send_messages?: boolean; | ||
@@ -48,4 +52,4 @@ can_send_media_messages?: boolean; | ||
can_pin_messages?: boolean; | ||
} | ||
export interface ChatMember { | ||
}; | ||
export declare type ChatMember = { | ||
user: User; | ||
@@ -70,7 +74,11 @@ status: ChatMemberStatus; | ||
can_add_web_page_previews?: boolean; | ||
} | ||
}; | ||
export declare type ChatMemberStatus = 'creator' | 'administrator' | 'member' | 'restricted' | 'left' | 'kicked'; | ||
export interface UserProfilePhotos { | ||
export declare type UserProfilePhotos = { | ||
total_count: number; | ||
photos: PhotoSize[][]; | ||
} | ||
}; | ||
export declare type ChatLocation = { | ||
location: Location; | ||
address: string; | ||
}; |
{ | ||
"name": "@apidog/multibot-sdk-ts", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Telegram and VK bot SDK for TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -19,6 +19,6 @@ # Multibot SDK | ||
bot.on('message', ({ message, sender, chat }) => { | ||
bot.on(Telegram.MatchType.Message, ({ message, from, chat }) => { | ||
bot.request('sendMessage', { | ||
chat_id: chat.id, | ||
text: `Hello, ${sender.first_name}!`, | ||
text: `Hello, ${from.first_name}!`, | ||
}); | ||
@@ -38,2 +38,4 @@ }); | ||
```typescript | ||
import { Telegram } from '@apidog/multibot-sdk-ts'; | ||
const kb = new Telegram.ReplyKeyboardBuilder(); | ||
@@ -40,0 +42,0 @@ const row = kb.addRow(); // add row |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
162427
2477
48