UNPKG

node-vk-api-bot

Version:

A library that helps you to create chat-bot for group or user

1,308 lines 97.1 kB
import { GroupUpdates } from './group-updates.js'; import { Objects } from './types/objects.js'; import { AppendArrayT, atLeastOne, date_DD_MM_YYYY, date_YYYY, date_YYYY_MM, date_YYYY_MM_DD, flag, get, LongPollConnectionData, name_case, Range, T_or_Array_of_T, xor } from './types/utils.js'; declare type s = string; declare type n = number; declare namespace Methods { export type UserMethods = Account | Ads | Exclude<Messages, Messages.sendMessageEventAnswer | Messages.getIntentUsers> | Exclude<Groups, Groups.getTokenPermissions> | Utils.getServerTime | Utils.resolveScreenName | Users; export type GroupMethods = Groups.addAddress | Groups.addCallbackServer | Groups.getLongPollServer | Groups.deleteAddress | Groups.deleteCallbackServer | Groups.disableOnline | Groups.edit | Groups.editAddress | Groups.editCallbackServer | Groups.enableOnline | Groups.getBanned | Groups.getCallbackConfirmationCode | Groups.getCallbackServers | Groups.getCallbackSettings | Groups.getLongPollServer | Groups.getLongPollSettings | Groups.getMembers | Groups.getOnlineStatus | Groups.getTagList | Groups.getTokenPermissions | Groups.isMember | Groups.setCallbackSettings | Groups.setLongPollSettings | Groups.setSettings | Groups.setUserNote | Groups.tagAdd | Groups.tagBind | Groups.tagDelete | Messages.createChat | Messages.delete | Messages.deleteChatPhoto | Messages.deleteConversation | Messages.edit | Messages.editChat | Messages.getByConversationMessageId | Messages.getById | Messages.getConversationMembers | Messages.getConversations | Messages.getConversationsById | Messages.getHistory | Messages.getHistoryAttachments | Messages.getImportantMessages | Messages.getIntentUsers | Messages.getInviteLink | Messages.getLongPollHistory | Messages.getLongPollServer | Messages.isMessagesFromGroupAllowed | Messages.markAsAnsweredConversation | Messages.markAsImportantConversation | Messages.markAsRead | Messages.pin | Messages.removeChatUser | Messages.restore | Messages.search | Messages.searchConversations | Messages.send | Messages.sendMessageEventAnswer | Messages.setActivity | Messages.setChatPhoto | Utils.getServerTime | Utils.resolveScreenName | Users.get; export enum Account { ban = "account.ban", changePassword = "account.changePassword", getActiveOffers = "account.getActiveOffers", getAppPermissions = "account.getAppPermissions", getBanned = "account.getBanned", getInfo = "account.getInfo", getProfileInfo = "account.getProfileInfo", lookupContacts = "account.lookupContacts", registerDevice = "account.registerDevice", saveProfileInfo = "account.saveProfileInfo", saveInfo = "account.saveInfo", setOffline = "account.setOffline", setOnline = "account.setOnline", setPushSettings = "account.setPushSettings", setSilenceMode = "account.setSilenceMode", unban = "account.unban", unregisterDevice = "account.unregisterDevice" } export enum Ads { addOfficeUsers = "ads.addOfficeUsers", checkLink = "ads.checkLink", createAds = "ads.createAds", createCampaigns = "ads.createCampaigns", createClients = "ads.createClients", createLookalikeRequest = "ads.createLookalikeRequest", createTargetGroup = "ads.createTargetGroup", createTargetPixel = "ads.createTargetPixel", deleteAds = "ads.deleteAds", deleteCampaigns = "ads.deleteCampaigns", deleteClients = "ads.deleteClients", deleteTargetGroup = "ads.deleteTargetGroup", deleteTargetPixel = "ads.deleteTargetPixel", getAccounts = "ads.getAccounts", getAds = "ads.getAds", getAdsLayout = "ads.getAdsLayout", getAdsTargeting = "ads.getAdsTargeting", getBudget = "ads.getBudget", getCampaigns = "ads.getCampaigns", getCategories = "ads.getCategories", getClients = "ads.getClients", getDemographics = "ads.getDemographics", getFloodStats = "ads.getFloodStats", getLookalikeRequests = "ads.getLookalikeRequests", getMusicians = "ads.getMusicians", getMusiciansByIds = "ads.getMusiciansByIds", getOfficeUsers = "ads.getOfficeUsers", getPostsReach = "ads.getPostsReach", getRejectionReason = "ads.getRejectionReason", getStatistics = "ads.getStatistics", getSuggestions = "ads.getSuggestions", getTargetGroups = "ads.getTargetGroups", getTargetPixels = "ads.getTargetPixels", getTargetingStats = "ads.getTargetingStats", getUploadURL = "ads.getUploadURL", getVideoUploadURL = "ads.getVideoUploadURL", importTargetContacts = "ads.importTargetContacts", removeOfficeUsers = "ads.removeOfficeUsers", removeTargetContacts = "ads.removeTargetContacts", saveLookalikeRequestResult = "ads.saveLookalikeRequestResult", shareTargetGroup = "ads.shareTargetGroup", updateAds = "ads.updateAds", updateCampaigns = "ads.updateCampaigns", updateClients = "ads.updateClients", updateOfficeUsers = "ads.updateOfficeUsers", updateTargetGroup = "ads.updateTargetGroup", updateTargetPixel = "ads.updateTargetPixel" } export enum Groups { addAddress = "groups.addAddress", addCallbackServer = "groups.addCallbackServer", addLink = "groups.addLink", approveRequest = "groups.approveRequest", ban = "groups.ban", create = "groups.create", deleteAddress = "groups.deleteAddress", deleteCallbackServer = "groups.deleteCallbackServer", deleteLink = "groups.deleteLink", disableOnline = "groups.disableOnline", edit = "groups.edit", editAddress = "groups.editAddress", editCallbackServer = "groups.editCallbackServer", editLink = "groups.editLink", editManager = "groups.editManager", enableOnline = "groups.enableOnline", get = "groups.get", getAddresses = "groups.getAddresses", getBanned = "groups.getBanned", getById = "groups.getById", getCallbackConfirmationCode = "groups.getCallbackConfirmationCode", getCallbackServers = "groups.getCallbackServers", getCallbackSettings = "groups.getCallbackSettings", getCatalog = "groups.getCatalog", getCatalogInfo = "groups.getCatalogInfo", getInvitedUsers = "groups.getInvitedUsers", getInvites = "groups.getInvites", getLongPollServer = "groups.getLongPollServer", getLongPollSettings = "groups.getLongPollSettings", getMembers = "groups.getMembers", getOnlineStatus = "groups.getOnlineStatus", getRequests = "groups.getRequests", getSettings = "groups.getSettings", getTagList = "groups.getTagList", getTokenPermissions = "groups.getTokenPermissions", invite = "groups.invite", isMember = "groups.isMember", join = "groups.join", leave = "groups.leave", removeUser = "groups.removeUser", reorderLink = "groups.reorderLink", search = "groups.search", setCallbackSettings = "groups.setCallbackSettings", setLongPollSettings = "groups.setLongPollSettings", setSettings = "groups.setSettings", setUserNote = "groups.setUserNote", tagAdd = "groups.tagAdd", tagBind = "groups.tagBind", tagDelete = "groups.tagDelete", tagUpdate = "groups.tagUpdate", toggleMarket = "groups.toggleMarket", unban = "groups.unban" } export enum Utils { getServerTime = "utils.getServerTime", resolveScreenName = "utils.resolveScreenName" } export enum Messages { addChatUser = "messages.addChatUser", allowMessagesFromGroup = "messages.allowMessagesFromGroup", createChat = "messages.createChat", delete = "messages.delete", deleteChatPhoto = "messages.deleteChatPhoto", deleteConversation = "messages.deleteConversation", denyMessagesFromGroup = "messages.denyMessagesFromGroup", edit = "messages.edit", editChat = "messages.editChat", forceCallFinish = "messages.forceCallFinish", getByConversationMessageId = "messages.getByConversationMessageId", getById = "messages.getById", getChat = "messages.getChat", getChatPreview = "messages.getChatPreview", getConversationMembers = "messages.getConversationMembers", getConversations = "messages.getConversations", getConversationsById = "messages.getConversationsById", getHistory = "messages.getHistory", getHistoryAttachments = "messages.getHistoryAttachments", getImportantMessages = "messages.getImportantMessages", getIntentUsers = "messages.getIntentUsers", getInviteLink = "messages.getInviteLink", getLastActivity = "messages.getLastActivity", getLongPollHistory = "messages.getLongPollHistory", getLongPollServer = "messages.getLongPollServer", isMessagesFromGroupAllowed = "messages.isMessagesFromGroupAllowed", joinChatByInviteLink = "messages.joinChatByInviteLink", markAsAnsweredConversation = "messages.markAsAnsweredConversation", markAsImportant = "messages.markAsImportant", markAsImportantConversation = "messages.markAsImportantConversation", markAsRead = "messages.markAsRead", pin = "messages.pin", removeChatUser = "messages.removeChatUser", restore = "messages.restore", search = "messages.search", searchConversations = "messages.searchConversations", send = "messages.send", sendMessageEventAnswer = "messages.sendMessageEventAnswer", setActivity = "messages.setActivity", setChatPhoto = "messages.setChatPhoto", startCall = "messages.startCall", unpin = "messages.unpin" } export enum Users { get = "users.get", getFollowers = "users.getFollowers", getSubscriptions = "users.getSubscriptions", report = "users.report", search = "users.search" } namespace RequestAndResponse { namespace Account { type ban__req = { owner_id: number; }; type ban__res = 1; type changePassword__req = { restore_sid?: string; change_password_hash?: string; old_password?: s; new_password: s; }; type changePassword__res = { token: s; }; type getActiveOffers__req = { count?: n; offset?: n; }; type getActiveOffers__res = { count: n; items: object[]; }; type getAppPermissions__req = { user_id: n; }; type getAppPermissions__res = n; type getBanned__req = { offset?: n; count?: n; }; type getBanned__res = { count: n; items: n[]; profiles: Objects.User[]; }; type getInfo__req = { fields: ('country' | 'https_required' | 'own_posts_default' | 'no_wall_replies' | 'intro' | 'lang')[] | s; }; type getInfo__res = Partial<{ country: s; https_required: flag; '2fa_required': flag; own_post_default: flag; no_wall_replies: flag; intro: flag; lang: n; }>; type getProfileInfo__req = null; type getProfileInfo__res = { first_name: s; last_name: s; screen_name?: s; relation: Range<0, 9>; relation_partner?: Objects.User; relation_pending?: 1; relation_requests?: Objects.User[]; bdate: s; bdate_visibility: flag | 2; home_town?: s; country: { id: n; title: s; }; city?: { id: n; title?: s; }; name_request: ({ status: 'declined' | 'response'; } | { status: 'processing'; id: n; } | { status: 'response_with_link'; link: s; }) & { first_name: s; last_name: s; }; status: s; phone: s; } & ({ sex: 0 | 2; } | { sex: 1; maiden_name: s; }); type lookupContacts__req = { contacts: s; service: 'email' | 'phone' | 'twitter' | 'facebook' | 'odnoklassniki' | 'instagram' | 'google'; mycontact?: s; return_all: flag; fields?: s[]; }; type lookupContacts__res = { found: (Objects.User & { contact?: s; request_sent?: unknown; common_count?: n; })[]; other: { contact: s; common_count?: n; }[]; }; type registerDevice__req = { token: s; device_model?: s; device_year?: n; device_id: s; system_version?: s; sandbox?: flag; }; type registerDevice__res = 1; type saveProfileInfo__req = Partial<{ first_name: s; last_name: s; maiden_name: s; screen_name: s; sex: 1 | 2; relation: Range<0, 9>; relation_partner_id: n; bdate: s; bdate_visibility: 0 | 1 | 2; home_town: s; country_id: n; city_id: n; status: s; }> | { cancel_request_id: n; }; type saveProfileInfo__res = { changed: 0 | 1; name_request?: ({ id: n; status: 'processing'; } | { status: 'success' | 'response | declined'; } | { status: 'was_accepted' | 'was_declined'; repeat_date: s; } | { status: 'response_with_link'; link: s; }) & { first_name: s; last_name: s; }; }; type saveInfo__req = { name: 'intro' | 'own_post_default' | 'no_wall_replies'; value: n; }; type saveInfo__res = 1; type setOffline__req = null; type setOffline__res = 1; type setOnline__req = { voip?: flag; }; type setOnline__res = 1; type setPushSettings__req = { device_id: n; key?: s; settings?: unknown; value?: s; }; type setPushSettings__res = 1; type setSilenceMode__req = { device_id: s; time?: n; peer_id?: n; sound?: flag; }; type setSilenceMode__res = 1; type unban__req = { owner_id: n; }; type unban__res = 1; type unregisterDevice__res = 1; type unregisterDevice__req = { device_id: s; sandbox?: flag; }; } namespace Ads { type create__req = { id: n; error_code?: n; error_desc?: s; }[]; export type addOfficeUsers__req = create; export type addOfficeUsers__res = boolean[]; export type checkLink__req = { account_id: s; link_type: 'community' | 'post' | 'application' | 'video' | 'site'; link_url: s; campaign_id: n; }; export type checkLink__res = { status: 'allowed' | 'in_progress'; redirect_url?: s; } | { status: 'disallowed'; description?: s; }; export type createAds__req = create; export type createAds__res = create__req; export type createClients__req = create; export type createClients__res = create__req; export type createCampaigns__req = create; export type createCampaigns__res = create__req; export type createLookalikeRequest__req = { account_id: s; client_id?: n; source_type: 'retargeting_group'; }; export type createLookalikeRequest__res = { request_id: n; }; export type createTargetGroup__req = { account_id: s; client_id?: n; name: s; lifetime?: n; target_pixel_id?: n; target_pixel_rules?: { [T in `${'url' | 'event'}_${'full' | 'substrings' | 'regex'}_match`]?: T extends `${s}_substrings_${s}` ? s[] : s; }[]; }; export type createTargetGroup__res = { id: n; }; export type createTargetPixel__req = { account_id: s; client_id?: n; name: s; domain?: s; category_id: s; }; export type createTargetPixel__res = { id: n; pixel: s; }; export type deleteAds__req = _delete; export type deleteAds__res = n[]; export type deleteClients__req = _delete; export type deleteClients__res = n[]; export type deleteCampaigns__req = _delete; export type deleteCampaigns__res = n[]; export type deleteTargetGroup__req = { account_id: s; client_id?: n; target_group_id: s; }; export type deleteTargetGroup__res = 1; export type deleteTargetPixel__req = { account_id: s; client_id?: n; target_pixel_id: s; }; export type deleteTargetPixel__res = 1; export type getAccounts__req = null; type _ads = { account_id: s; client_id?: n; include_deleted?: flag; only_deleted?: flag; campaign_ids?: null | s; as_ids?: null | s; limit?: n; offset?: n; }; export type getAccounts__res = { account_id: n; account_type: 'general' | 'agency'; account_name: s; account_status: flag; access_role: 'admin' | 'manager' | 'manager'; }[]; export type getAds__req = _ads; export type getAds__res = (({ id: n; campaign_id: n; goal_type: n; impressions_limit?: n; impression_limited?: 1; add_platform_no_wall?: 1; all_limit: n; autobidding: flag; autobidding_max_cost: n; category1_id: n; category2_id: n; status: 0 | 1 | 2; name: s; approved: Range<0, 4>; video?: 1; disclaimer_medical?: 1; disclaimer_specialist?: 1; disclaimer_supplements?: 1; weekly_schedule_hours: AppendArrayT<AppendArrayT<flag, [], 24>, [], 7>; weekly_schedule_use_holidays: flag; }) & ({ ad_format: 1; ad_platform: 0 | 1; } | { ad_format: 9 | 11; ad_platform: 'all' | 'mobile' | 'desktop'; publisher_platforms: 'all' | 'vk' | 'social'; events_retargeting_groups: { [x: s | n]: (Range<1, 7> | Range<10, 16> | 20 | 21)[]; }[]; } | { ad_format: Range<2, 7> | 12; }) & ({ cost_type: 0; cpc: n; } | { cost_type: 1; cpm: n; } | { cost_type: 3; ocpm: n; }))[]; export type getAdsLayout__req = _ads; export type getAdsLayout__res = ({ id: n; campaign_id: n; ad_format: Range<0, 12>; cost_type: 0 | 1 | 3; goal_type: n; video?: 1; repeat_video: flag; title: s; description: s; link_url: s; link_domain: s; link_title: s; link_button: s; preview_link: s; } & { [T in `${'icon' | 'image'}_src${'_2x' | ''}`]: s; })[]; export type getAdsTargeting__req = _ads; export type getAdsTargeting__res = { id: n; campaign_id: n; country: s; cities: s; cities_not: s; count: n; statuses: s; }[]; export type getBudget__req = { account_id: n; }; export type getBudget__res = n; export type getCampaigns__req = { account_id: s; client_id?: n; include_deleted?: flag; campaign_ids: null | s; fields: s | s[]; }; export type getCampaigns__res = { id: s; type: 'normal' | 'vk_apps_managed' | 'mobile_apps' | 'promoted_posts' | 'adaptive_ads'; name: s; status: 0 | 1 | 2; day_limit: n; all_limit: n; start_time: n; stop_time: n; }[]; export type getCategories__req = { lang: s; }; export type getCategories__res = { [T in `v${1 | 2}`]: { id: n; name: s; subcategories: { name: s; id: n; }[]; }[]; }[]; export type getClients__req = { account_id: s; }; type __date_limits = `date_${'from' | 'to'}`; type __date_period<P extends s, T extends string | number = date_YYYY_MM_DD> = { period: P; } & { [_ in __date_limits]: T | 0; }; type __date_periods<T extends [period: s, type: s | n][]> = T['length'] extends 1 ? __date_period<T[0][0], T[0][1]> : T extends [infer f extends [s, s | n], ...infer r extends [s, s | n][]] ? __date_period<f[0], f[1]> | __date_periods<r> : never; export type getClients__res = { id: n; name: s; day_limit: n; all_limit: n; }[]; type sex = 'f' | 'm'; type age = '12-18' | '18-21' | '21-24' | '24-27' | '27-30' | '30-35' | '35-45' | '45-100'; type sex_age = `${sex};${age}`; type __demographic<T> = { impressions_rate: n; clicks_rate: n; value: T extends 'sex' ? sex : T extends 'age' ? age : T extends 'sex_age' ? sex_age : T extends 'cities' ? n | 'other' : never; }; export type getDemographics__req = { account_id: s; ids_type: 'ad' | 'campaign'; ids: s | s[]; } & __date_periods<[ [ 'day', date_YYYY_MM_DD | 0 ], [ 'month', date_YYYY_MM | 0 ], [ 'overall', 0 ] ]>; export type getDemographics__res = { id: n; type: 'ad' | 'campaign'; stats: (({ day: date_YYYY_MM_DD; } | { month: date_YYYY_MM; } | { overall: 1; }) & { [T in 'sex' | 'age' | 'sex_age' | 'cities']: T extends 'cities' ? { name: s; } & __demographic<T> : __demographic<T>; })[]; }; export type getFloodStats__req = { account_id: s; }; export type getFloodStats__res = { left: n; refresh: n; }; export type getLookalikeRequests__req = { account_id: s; client_id?: n; request_id?: s | s[]; offset?: n; limit?: n; sort_by?: 'id' | 'update_time'; }; export type getLookalikeRequests__res = { count: 0; } | { count: n; items: { id: n; create_time: n; update_time: n; status: `${'search' | 'save'}_${'in_progress' | 'done' | 'failed'}`; scheduled_delete_time: n; source_retargeting_group_id?: s | n; source_name?: s; audience_count: n; save_audience_levels?: { level: unknown; audience_count: n; }; }[]; }; export type getMusicians__req = { artist_name: s; }; export type getMusicians__res = { name: s; avatar: s; }[]; export type getMusiciansByIds__req = { ids: s | s[]; }; export type getMusiciansByIds__res = { id: n; name: s; avatar: s; }[]; export type getOfficeUsers__req = { account_id: s; }; export type getOfficeUsers__res = ({ client_id: n; role: 'reports' | 'manager'; } | { role: 'admin'; })[]; export type getPostsReach__req = { account_id: s; ids_type: 'ad' | 'campaign'; ids: s | n | s[] | n[]; }; export type getPostsReach__res = ({ id: n; reach_subscribers: n; reach_total: n; links: n; to_group: n; join_group: n; report: n; hide: n; unsubscribe: n; } & { [T in `video_views_${'start' | '3s' | `${Range<25, 100, 25, true>}p`}`]?: n; })[]; export type getRejectionReason__req = { account_id: s; ad_id: s; }; export type getRejectionReason__res = atLeastOne<[ 'comment', 'rules' ], [ string, { title: s; paragraphs: s; }[] ]>; export type getStatistics__req = { account_id: s; ids_type: 'ad' | 'campaign' | 'client' | 'office'; ids: s | s[] | n | s[]; stats_fields?: 'views_times'; } & __date_periods<[ [ 'day', date_YYYY_MM_DD | 0 ], [ 'week', date_YYYY_MM_DD | 0 ], [ 'month', date_YYYY_MM | 0 ], [ 'year', date_YYYY | 0 ], [ 'overall', 0 ] ]>; export type getStatistics__res = { id: s | n; type: 'ad' | 'campaign' | 'client' | 'office'; stats: (({ day: date_YYYY_MM_DD; } | { month: date_YYYY_MM; } | { overall: 1; }) & { spent: n; impressions: n; clicks: n; reach: n; join_rate: n; uniq_views_count: n; links_external_clicks: n; ctr: unknown; } & Record<`effective_${`cost_per_${'click' | 'mille'}` | 'cpf'}`, n> & Partial<{ effective_cost_per_message: n; message_sends: n; } & Record<`video_plays_unique_${'started' | '3_seconds' | `${Range<25, 100, 25, true>}_percents`}`, n> & Record<`conversion_${'count' | 'sum' | 'roas' | 'cr'}`, n> & Record<`mobile_app_${`custom_${Range<1, 11>}` | 'install' | 'conversion' | 'purchase' | 'add_to_cart' | 'initiate_checkout' | 'add_payment_info' | 'subscribe' | 'complete_registration' | 'contact' | 'lead' | 'view_content' | 'search' | 'add_to_wishlist' | 'customize_product' | 'donate' | 'find_location' | 'page_view' | 'schedule' | 'start_trial' | 'submit_application' | 'achieved_level' | 'completed_tutorial' | 'rated' | 'unlocked_achievement' | 'spent_credits'}_${'amount' | 'value' | 'cr' | 'ecpa' | 'er' | 'romi'}_${`by_${'interaction' | 'postback'}_time`}_${'postclick' | 'post_view' | 'total'}`, n>>)[]; }; export type getSuggestions__req = (({ section: 'countries'; q?: 1; } | { section: 'regions'; q: s; } | { section: 'cities'; q?: s; country: n; } | { section: 'districts'; cities: s | s[]; } | { section: 'streets'; cities: s | s[]; q: s; } | { section: 'schools'; cities: s | s[]; q: s; } | { section: `interest_categories${'' | '_v2'}` | 'positions' | 'religions' | `user_${'devices' | 'os' | 'browsers'}`; }) & { q?: s; cities?: s | s[]; country?: n; } | { ids: s | s[] | n | n[]; section: 'countries' | 'regions' | 'cities' | 'districts' | 'streets' | 'schools' | `interest_categories${'' | '_v2'}` | 'positions' | 'religions' | `user_${'devices' | 'os' | 'browsers'}`; }) & { lang?: 'ru' | 'ua' | 'en'; }; export type getSuggestions__res = ({ id: n; name: s; } & ({} | { type?: s; } | { parent: s; } | { parent: s; desc: s; type: 'school' | 'university' | 'faculty' | 'chair'; }))[] | s[]; export type getTargetGroups__req = { account_id: s; client_id?: n; extended?: flag; }; export type getTargetGroups__res = { id: n; name: s; last_updated?: n; is_audience?: 1; is_shared?: 1; audience_count: n; lifetime: n; file_source?: 1; api_source?: 1; lookalike_source?: 1; pixel?: s; domain: s; }[]; export type getTargetPixels__req = { account_id: s; client_id?: n; }; export type getTargetPixels__res = { target_pixel_id: n; name: s; last_updated: n; domain: s; category_id: n; pixel: s; }[]; export type getTargetingStats__req = atLeastOne<[ 'criteria', 'ad_id' ], [ s, n ]> & { account_id: s; client_id?: n; link_url: s; link_domain?: s; need_precise?: flag; impressions_limit_period?: n; } & ({ ad_format: 1; ad_platform: flag; } | { ad_format: 9 | 11; ad_platform: 'all' | 'desktop' | 'mobile'; } & Partial<Record<`ad_platform_no_${'wall' | 'ad_network'}`, flag>> | { ad_format: 2 | 3 | 4 | 7 | 8 | 10; }); export type getTargetingStats__res = { audience_count: n; } & Record<`recommended_c${`${'pc' | 'pm'}_${50 | 70 | 90}`}`, n> & Partial<Record<`recommended_c${'pc' | 'pm'}_precise`, n>>; export type getVideoUploadURL__req = null; export type getVideoUploadURL__res = s; export type getUploadURL__req = { ad_format: Range<1, 7>; } | { ad_format: 11; icon?: 1; }; export type getUploadURL__res = s; export type importTargetContacts__req = { account_id: s; client_id?: n; target_group_id: s; contacts: s | s[] | n | n[] | (s | n)[]; }; export type importTargetContacts__res = n; export type removeOfficeUsers__req = { account_id: s; ids: s; }; export type removeOfficeUsers__res = boolean[]; export type removeTargetContacts__req = { account_id: s; client_id?: n; target_group_id: s; contacts: s | s[] | n | n[] | (s | n)[]; }; export type removeTargetContacts__res = 1; export type saveLookalikeRequestResult__req = { account_id: s; client_id?: n; request_id: s; level: unknown; }; export type saveLookalikeRequestResult__res = { retargeting_group_id: s; audience_count: n; }; export type shareTargetGroup__req = { account_id: s; client_id?: n; target_group_id: s; share_with_client_id: n; }; type update__res = create; export type shareTargetGroup__res = { id: n | s; }; type update__req = create__req; export type updateAds__req = update__res; export type updateAds__res = update__req; export type updateCampaigns__req = update__res; export type updateCampaigns__res = update__req; export type updateClients__req = update__res; export type updateClients__res = update__req; export type updateOfficeUsers__req = update__res; export type updateOfficeUsers__res = ({ user_id: n; } & ({ is_success: true; } | { is_success: false; error: { error_code: n; error_msg: s; }; }))[]; export type updateTargetGroup__req = { account_id: s; client_id?: n; target_group_id: s; name: s; domain?: s; lifetime?: n; target_pixel_id?: s; target_pixel_rules?: s; }; export type updateTargetGroup__res = 1; export type updateTargetPixel__res = 1; type create = { account_id: s; data: s; }; type _delete = { account_id: s; ids: s; }; export type updateTargetPixel__req = { account_id: s; client_id?: n; target_pixel_id: s; name: s; domain?: s; category_id: s; }; export {}; } namespace Messages { export type addChatUser__req = { chat_id: n; user_id: n; visible_messages_count?: n; }; export type addChatUser__res = 1; export type allowMessagesFromGroup__req = { group_id: n; key?: s; }; export type allowMessagesFromGroup__res = 1; export type createChat__req = { user_ids: s | s[] | n | n[]; title: s; group_id?: n; }; export type createChat__res = n; export type m_delete__req = { message_ids?: s | s[] | n | n[]; spam?: flag; group_id?: n; delete_for_all?: 1; cmids?: s | s[] | n | n[]; peer_id?: n; }; export type m_delete__res = { [x: s]: flag; }; export type deleteChatPhoto__req = { chat_id: n; group_id?: n; }; export type deleteChatPhoto__res = { message_id: n; chat: Objects.Chat; }; export type deleteConversation__req = xor<{ user_id: n; }, { peer_id: n; }> & { group_id?: n; }; export type deleteConversation__res = { last_deleted_id: n; }; export type denyMessagesFromGroup__req = { group_id: n; }; export type denyMessagesFromGroup__res = 1; export type edit__req = { lat?: n; long?: n; keep_forward_messages?: flag; keep_snippets?: flag; group_id?: n; dont_parse_links?: flag; disable_mentions?: flag; template?: s; keyboard?: s; } & atLeastOne<[ 'attachment', 'message' ], [ T_or_Array_of_T<`${'photo' | 'video' | 'audio' | 'doc' | 'wall' | 'market'}${n}_${n}${'' | `_${s}`}`>, s ]> & xor<{ message_id: n; }, { peer_id: n; conversation_message_id: n; }>; export type edit__res = 1; export type editChat__req = { title: s; chat_id?: n; }; export type editChat__res = 1; export type forceCallFinish__req = { call_id: n; }; export type forceCallFinish__res = 1; export type getByConversationMessageId__req = { peer_id: n; conversation_message_id: n | n[] | s | s[]; extended?: flag; fields?: s | s[]; group_id?: n; }; export type getByConversationMessageId__res = get<Objects.Message>; export type getById__req = { message_ids: s | n | s[] | n[] | (s | n)[]; preview_length?: n; extended?: flag; group_id?: n; fields?: s | s[]; }; export type getById__res = get<Objects.Message>; export type getChat__req = xor<{ chat_id: n | s; }, { chat_ids: n[] | s[] | s; }> & { fields?: s | s[]; name_case?: name_case; }; export type getChat__res = T_or_Array_of_T<Omit<Objects.Chat, 'users'> & { users: n[] | (Objects.User & { invited_by: n; })[]; }>; type __get_o = { profiles: Objects.User[]; groups: Objects.Group[]; }; export type getChatPreview__req = { peer_id: n; link: s; fields?: s | s[]; }; export type getChatPreview__res = { preview: { admin_id: n; members: n[]; title: s; photo: Record<`photo_${50 | 100 | 200}`, s>; local_id: n; }; emails: { id: n; address: s; }[]; } & __get_o; export type getConversationMembers__req = { peer_id: n; offset?: n; count?: n; extended?: flag; fields?: s | s[]; group_id?: n; }; export type getConversationMembers__res = get<{ member_id: n; invited_by: n; join_date: n; is_admin: boolean; can_kick?: boolean; }> & __get_o; export type getConversations__req = { offset?: n; count?: n; filter?: 'all' | 'important' | 'unanswered' | 'unread'; extended?: flag; start_message_id?: n; fields?: s | s[]; group_id?: n; }; export type getConversations__res = get<{ conversation: Objects.Conversation; lat_message: Objects.Message; }> & __get_o & { unread_count: n; }; export type getConversationsById__req = { peer_ids: n | n[] | s | s[]; extended?: flag; fields?: s | s[]; group_id?: n; }; export type getConversationsById__res = get<Objects.Conversation>; export type getHistory__req = { offset?: n; count?: n; start_message_id?: n; rev?: flag; extended?: flag; fields?: s | s[]; group_id?: n; } & xor<{ user_id: n; }, { peer_id: n; }>; type __attachment_type = 'photo' | 'video' | 'audio' | 'doc' | 'link' | 'market' | 'wall' | 'share'; export type getHistory__res = get<Objects.Message> & { skipped?: n; }; type __attachment<T> = T extends [type: s, a: unknown] ? { type: T[0]; } & Record<T[0], T[1]> : never; type __attachments = __attachment<['audio', Objects.Audio] | ['video', Objects.Video] | ['photo', Objects.Photo] | ['doc', Objects.Doc] | ['link', Objects.Link] | ['market', Objects.MarketItem] | ['wall', Objects.Wall]>; export type getHistoryAttachments__req = { peer_id: n; media_id: __attachment_type; start_from?: n; count?: n; photo_sizes?: flag; fields?: s | s[]; group_id?: n; preserve_order?: flag; max_forward_level?: n; }; export type getHistoryAttachments__res = { items: { message_id: n; attachment: __attachments; }[]; next_from: n; }; export type getImportantMessages__req = { count?: n; offset?: n; start_message_id?: n; previwe_length?: n; fields?: s | s[]; extended?: flag; group_id?: n; }; export type getImportantMessages__res = { messages: get<Objects.Message>; profiles?: Objects.User[]; conversations?: Objects.Conversation[]; }; export type getIntentUsers__req = { intent: `${'' | 'non_'}promo_newsletter` | 'confirmed_notifications'; subscribe_id?: n; offset?: n; count?: n; extended?: flag; name_case?: name_case; fields?: s | s[]; }; export type getIntentUsers__res = get<n> & { profiles?: Objects.User[]; }; export type getInviteLink__req = { peer_id: n; reset: flag; group_id?: n; }; export type getInviteLink__res = { link: s; }; export type getLastActivity__req = { user_id: n; }; export type getLastActivity__res = { online: flag; time: n; }; export type getLongPollHistory__req = { ts: n; pts?: n; preview_length?: n; onlines?: flag; fields?: s | s[]; events_limit?: n; msgs_limit?: n; max_msg_limit?: n; group_id?: n; lp_version?: n; last_n?: n; credentials?: flag; extended?: flag; }; export type getLongPollHistory__res = { history: [n, n, ...unknown[]][]; messages: Objects.Message[]; profiles: Objects.User[]; groups: Objects.Group[]; conversations?: Objects.Conversation[]; new_pts?: n; from_pts?: n; }; export type getLongPollServer__req = { need_pts: flag; group_id?: number; lp_version?: number; }; export type getLongPollServer__res = LongPollConnectionData; export type isMessagesFromGroupAllowed__req = { group_id: n; user_id: n; }; export type isMessagesFromGroupAllowed__res = { is_allowed: flag; }; export type joinChatByInviteLink__req = { link: s; }; export type joinChatByInviteLink__res = { chat_id: n; }; export type markAsAnsweredConversation__req = { peer_id: n; answered: flag; group_id?: n; }; export type markAsAnsweredConversation__res = 1; export type markAsImportant__req = { message_ids: s | s[] | n | n[] | (s | n)[]; important: flag; }; export type markAsImportant__res = n[]; export type markAsImportantConversation__req = { peer_id: n; important: flag; group_id?: n; }; export type markAsImportantConversation__res = 1; export type markAsRead__req = { message_ids: s | s[] | n | n[] | (s | n); peer_id: n; start_message_id?: n; group_id?: n; mark_conversation_as_read?: flag; }; export type markAsRead__res = 1; export type pin__req = { peer_id: n; conversation_message_id: n; message_id?: n; }; export type pin__res = Objects.Message; export type removeChatUser__req = { chat_id: n; } & ({ member_id: n; } | { user_id: n; }); export type removeChatUser__res = 1; export type restore__req = { message_id: n; group_id?: n; }; export type restore__res = 1; export type search__req = { q?: s; p