/// import Hero, { ISuperHTMLElement, LoadStatus } from "@ulixee/hero"; import { ITypeInteraction } from "@ulixee/hero/interfaces/IInteractions"; import Server from "@ulixee/server"; import { Post, PostIdentifer, PostInfo } from "./post"; import { Profile, ProfileGender } from "./profile"; import { Comment } from "./comment"; import { User } from "./user"; export interface PostOptions { caption?: string; location?: string; altText?: string; hideLikesAndViews?: boolean; disableComments?: boolean; } export default class IGBot { protected username: string; protected password: string; protected showChrome: boolean; protected baseInstagramUrl: import("url").URL; protected graphqlUrl: import("url").URL; protected feedApiUrl: import("url").URL; protected loginUrl: import("url").URL; protected logoutUrl: import("url").URL; protected onetapLoginUrl: import("url").URL; protected editAccountUrl: import("url").URL; protected changePasswordUrl: import("url").URL; protected privacySecurityUrl: import("url").URL; protected core: Server; protected hero: Hero; protected document: Hero["document"]; protected isInitialised: boolean; getIsInitialised(): boolean; protected isLoggedIn: boolean; getIsLoggedIn(): boolean; protected isBusy: boolean; getIsBusy(): boolean; getIsFree(): boolean; constructor(username: string, password: string, showChrome?: boolean); /** * Initializes the instagram client. */ init(): Promise; /** * Close the instagram client. * * The client will need to be reinitialized before it can be used again. */ close(): Promise; /** * Unsaves a post. * * @param post The post to unsave */ unsavePost(post: PostIdentifer): Promise; /** * Saves a post. * * @param post The post to save */ savePost(post: PostIdentifer): Promise; /** * Gets wether a post is saved by the currently logged in user. * * @param post The post to check if it is saved * @returns Whether the post is saved */ isPostSaved(post: PostIdentifer): Promise; /** * Shares a post. * * @param post The post to share * @param user The username of the user or users to share the post with */ sharePost(post: PostIdentifer, user: string | string[], message?: string): Promise; /** * Comments on a post. * * @param post The post to comment on. */ comment(post: PostIdentifer, comment: string): Promise; /** * Unlikes a post. * * @param post The post to unlike. */ unlikePost(post: PostIdentifer): Promise; /** * Likes a post. * * @param post The identifier of the post to like. */ likePost(post: PostIdentifer): Promise; /** * Gets whether a post is liked by the currently logged in user. * * @param post The identifier of the post. * @returns Whether the post is liked. */ isPostLiked(post: PostIdentifer): Promise; /** * Gets the comments of a post. * * TODO: Maybe add a way to get replies to comments. * * @param identifier The identifier of the post. * @param count The number of comments to get. * @param getReplies Wether to get the replies of the comments. @default false * @returns An array of comments. */ getComments(identifier: PostIdentifer, count: number): Promise; /** * Gets detailed information about a post. * * @param identifier The identifier of the post to get. */ getPost(identifier: PostIdentifer): Promise; /** * Gets the ids of posts from the logged in users main feed. * * @param count The number of posts to get. * @returns The IDs of the posts. */ getFeed(count: number): Promise; /** * Gets a user's pinned posts. * * @param username The username of the user to get posts from. * @param count The number of posts to get. @default Infinity * * @returns An array of {@link PostInfo} objects for each pinned post. */ getPinnedPosts(username: string, count?: number): Promise; /** * Gets a user's most recent post. * * This method does not include pinned posts in it's search. * * @param username * * @returns The user's most recent post, if it exists. */ getRecentPost(username: string): Promise; /** * Gets a user's posts. * * By default, this method does not include pinned posts in it's search. * * @param username The username of the user to get posts from. * @param count The maxium number of posts to get, `Infinity` will get all posts. * @param filterPinned Whether to filter out pinned posts. @default true * @param onlyPinned Whether to only get pinned posts. @default false * * @returns An array of {@link PostInfo} objects for each post. */ getPosts(username: string, count: number, filterPinned?: boolean, onlyPinned?: boolean): Promise; /** * Creates a post. * * @param content The content to post, an array of values will be posted as a slideshow * @param caption The caption to add to the post, default is no caption. */ post(content: string | string[], options?: PostOptions): Promise; /** * Logs in to Instagram using `this.username` and `this.password`. */ login(): Promise; logout(): Promise; /** * Gets the usernames of people who the given user is following. * * @param username The username of the user * @param count The maximum number of users to return, `Infinity` will get all users the user is following * * @returns An array of usernames */ getFollowing(username: string, count: number): Promise; /** * Gets the usernames of people who follow the user with the given `username`. * * @param username The username of the user * @param count The maximum number of followers to return, `Infinity` will get all followers * * @returns An array of usernames */ getFollowers(username: string, count: number): Promise; protected getFollowersOrFollowing(username: string, count: number, type: "followers" | "following"): Promise; /** * Unfollows a user. * * @param username The username of the user to unfollow. */ unfollowUser(username: string): Promise; /** * Follows a user. * * @param username The username of the user to follow. */ followUser(username: string): Promise; /** * Checks wether the currently logged in user is following a user. * * @param username the username of the user */ isFollowingUser(username: string): Promise; /** * Gets the details of a user. * * These details include the user's name, bio, followers, following, and posts count. * * @param username The username of the user */ getUser(username: string): Promise; /** * Opens the profile page for a user. * * Throws an error if the user does not exist. * * @param username The username of the user to navigate to. */ protected openUserPage(username: string, skipIfAlreadyOnUrl?: boolean, waitForStatus?: LoadStatus): Promise; setAccountPrivacy(isPrivate: boolean): Promise; /** * Gets wether the currently logged in user's account is private. * * @returns true if the account is private, false otherwise */ isAccountPrivate(): Promise; /** * Sets the currently logged in user's profile details. * * @param profile The profile details to set */ setProfile(profile: Partial & { customGender?: string; }): Promise; /** * Sets the currently logged in user's chaining value. * * @param chaining Whether to enable chaining */ setChaining(chaining: Profile["chaining"]): Promise; /** * Sets the currently logged in user's gender. * * @param gender The new gender */ setGender(gender: ProfileGender.MALE | ProfileGender.FEMALE | ProfileGender.PREFER_NOT_TO_SAY): Promise; /** * Sets the currently logged in user's gender. * * @param gender `ProfileGender.CUSTOM` * @param customGender The new gender */ setGender(gender: ProfileGender.CUSTOM, customGender: string): Promise; /** * Sets the currently logged in user's phone number. * * @param phoneNo The new phone number */ setPhoneNo(phoneNo: Profile["phoneNo"]): Promise; /** * Sets the currently logged in user's email. * * @param email The new email */ setEmail(email: Profile["email"]): Promise; /** * Sets the currently logged in user's bio. * * @param bio The new bio */ setBio(bio: Profile["bio"]): Promise; /** * Sets the currently logged in user's website. * * @param url A valid URL to be the new website */ setWebsite(url: Profile["website"]): Promise; /** * Sets the currently logged in user's name. * * This is the name that will be displayed on the profile, not the username. * * @param name The new name */ setName(name: Profile["name"]): Promise; /** * Sets the currently logged in user's username. * * Updates `this.username` when successful. * * Instagram usernames must follow these rules: * - Must be between 1 and 30 characters long, inclusive * - Must contain only letters, numbers, periods and underscores * * Usernames also cannot be changed too often. * * @param username The new username */ setUsername(username: Profile["username"]): Promise; /** * Sets the currently logged in user's password. * * Updates `this.password` when successful. * * @param password The new password */ setPassword(password: Profile["password"]): Promise; protected saveProfileChanges(errorMsg: string): Promise; /** * Gets the profile details of the currently logged in user. * * @returns The profile details of the logged in user */ getProfile(): Promise; /** * Gets wether the currently logged in user has chaining enabled. * * Chaining is a feature that allows your instagram account to be * recommended to other users as suggestions of accounts to follow. * * @returns Wether chaining is enabled */ getChaining(): Promise; /** * Gets the gender of the currently logged in user. * * @returns The gender of the currently logged in user */ getGender(): Promise; /** * Gets the phone number of the currently logged in user. * * @returns The phone number of the currently logged in userq */ getPhoneNo(): Promise; /** * Gets the email of the currently logged in user. * * @returns The email of the currently logged in user */ getEmail(): Promise; /** * Gets the bio of the currently logged in user. * * @returns The bio of the currently logged in user */ getBio(): Promise; /** * Gets the website of the currently logged in user. * * @returns The website of the currently logged in user */ getWebsite(): Promise; /** * Gets the name of the currently logged in user. * * This is the name that is displayed on the profile, not the username. * * @returns The name of the currently logged in user */ getName(): Promise; /** * Gets the username set on this {@link IGBot} instance. * * @returns `this.username` */ getUsername(): Profile["username"]; /** * Gets the password set on this {@link IGBot} instance. * * @returns `this.password` */ getPassword(): Profile["password"]; protected getChainingElement(): Promise<{ input: import("@ulixee/hero").ISuperElement; element: import("@ulixee/hero").ISuperElement; }>; protected getGenderElement(): Promise; protected getPhoneNoElement(): Promise; protected getEmailElement(): Promise; protected getBioElement(): Promise; protected getWebsiteElement(): Promise; protected getNameElement(): Promise; protected getUsernameElement(): Promise; protected declineOnetapLogin(): Promise; protected declineNotifications(): Promise; protected acceptCookieConsent(): Promise; protected getMessageToast(timeToWaitMs?: number): Promise; protected isPageNotFound(): Promise; protected repeatKey(key: ITypeInteraction, count: number): Promise; /** * Performs Ctrl+A, then Backspace. * * Make sure you have a focused element before calling this. */ protected clearInput(): Promise; protected waitForNoElementWithText(selector: string, text: string, timeout?: number, exactMatch?: boolean, caseSensitive?: boolean, checksIntervalMs?: number): Promise; protected waitForElementWithText(selector: string, text: string, timeout?: number, exactMatch?: boolean, caseSensitive?: boolean, checksIntervalMs?: number): Promise; protected findElementWithText(selector: string, text: string, exactMatch?: boolean, caseSensitive?: boolean): Promise; protected waitForNoElement(selector: string, timeout?: number, checksIntervalMs?: number): Promise; protected waitForElement(selector: string, timeout?: number, checksIntervalMs?: number): Promise; /** * Waits for a value to be truthy. * * NOTE: `this.document` and maybe other variables will not work inside a waitForValue call for some reason. * If you need to access the document, do so via another function call. * * @param waitForValue THe value to wait for to be truthy * @param timeout The time in ms before timing out, throws after timeout * @param checksIntervalMs The time in ms between value checks * @returns The last value returned from waitForValue */ protected waitFor(waitForValue: () => Promise, timeout?: number, checksIntervalMs?: number): Promise; protected querySelector(selector: string, silent?: boolean): Promise; protected goto(href: string, skipIfAlreadyOnUrl?: boolean, waitForStatus?: LoadStatus): Promise; /** * Calls waitForNavigation if `hero.url` includes `match`. * * @param match The string to match for in the url * @param trigger The waitForLocation trigger * @param status The waitForLoad status to wait for from the page */ protected waitForNavigationConditional(match: string, trigger?: "change" | "reload", status?: LoadStatus): Promise; /** * Calls hero's waitForLocation and then waitForLoad. * * @param trigger The waitForLocation trigger * @param status The waitForLoad status to wait for from the page */ protected waitForNavigation(trigger?: "change" | "reload", status?: LoadStatus): Promise; protected waitForLoad(status?: LoadStatus): Promise; protected getUrl(path: string): import("url").URL; protected getHref(path: string): string; }