Skip to content

Instantly share code, notes, and snippets.

@richard1122
Last active November 20, 2016 07:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save richard1122/1eb54cd4e422aeb707718ab307decd34 to your computer and use it in GitHub Desktop.
Save richard1122/1eb54cd4e422aeb707718ab307decd34 to your computer and use it in GitHub Desktop.
telegram typings
// A typings definition of some telegram data structure
// author: Richard He<richard9372@gmail.com>
// https://gist.github.com/richard1122/1eb54cd4e422aeb707718ab307decd34
// see more detail: https://core.telegram.org/bots/api
declare namespace TL {
export interface IResponse<T> {
ok:boolean
result:T
}
export interface IMessage {
message_id:number
from:IUser
date:number
chat:IChat
forward_from?:IUser
forward_from_chat?:IChat
forward_date?:number
reply_to_message?:IMessage
edit_date?:number
text?:string
entities?:Array<IMessageEntity>
audio?:IAudio
document?:IDocument
photo?:Array<IPhotoSize>
sticker?:ISticker
video?:IVideo
voice?:IVoice
caption?:string
contack?:IContact
location?:ILocation
venue?:IVenue
new_chat_member?:IUser
left_chat_member?:IUser
new_chat_title?:string
new_chat_photo?:Array<IPhotoSize>
delete_chat_photo?:boolean
group_chat_created?:boolean
supergroup_chat_created?:boolean
channel_chat_created?:boolean
migrate_to_chat_id?:number
migrate_from_chat_id?:number
pinned_message:IMessage
}
export interface IMessageUpdate {
update_id:number
message:IMessage
}
export interface IUser {
id:number
first_name:string
last_name?:string
username?:string
}
export type ChatType = 'private' | 'group' | 'supergroup' | 'channel'
export interface IChat {
id:number
type:ChatType
title?:string
username?:string
first_name?:string
last_name?:string
}
export type MessageEntityType = 'mention' | 'hashtag' | 'bot_command' | 'url' | 'email' | 'bold' | 'italic' | 'code' | 'pre' | 'text_link' | 'text_mention'
export interface IMessageEntity {
type:MessageEntityType
offset:number
length:number
url?:string
user?:IUser
}
export interface IFile {
file_id:string
file_size?:number
file_path?:string
}
export interface IPhotoSize extends IFile {
width:number
height:number
}
export interface IAudio extends IFile {
duration:number
performer?:string
title?:string
mime_type?:string
}
export interface IDocument extends IFile {
thumb?:IPhotoSize
file_name?:string
mime_type?:string
}
export interface ISticker extends IFile {
width:number
height:number
thumb?:IPhotoSize
emoji?:string
}
export interface IVideo extends IFile {
width:number
height:number
duration:number
thumb?:IPhotoSize
mime_type?:string
}
export interface IVoice extends IFile {
duration:number
mime_type?:string
}
export interface IContact {
phone_number:string
first_name:string
last_name?:string
user_id?:number
}
export interface ILocation {
longitude:number
latitude:number
}
export interface IVenue {
location:ILocation
title:string
address:string
foursquare_id?:string
}
export interface IUserProfilePhotos {
total_count:number
photos:Array<IPhotoSize>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment