Instapy-Tools
Note: this lib is pre v1 stage, expect thing breaking/buggy.
Want to build on top of Instapy? Then this is the toolset for you!
Batteries included:
- Ability to generate machine readable api in JSON format from python code
- Be able to controle the bot directly from js, using docker-compose
- TypeScript InstaPy api, generated from api.json (comming soon™)
Requirements:
- node > 10
- docker
- docker-compose
- linux, Note: Using windows/mac and it works somehow let me now :)
Usage
Api from generated api.json
import and extract api methods
jsonApiObj
(api.json)
getting the raw console.lograw // thats it...
setting up and using validateMethod
// setup //usage
setting up and using method
console.logmethodLine1 // 'session.like_by_tags(tags=['#cats', '#coolcats', 'aliencatsinspace'], amount=50)'console.logmethodLine1Bot // 'bot.like_by_tags(tags=['#cats', '#coolcats', 'aliencatsinspace'], amount=50)'
special case for the initializer
console.logmethodInit // session = InstaPy(username='userName', password='passWord')
Seting up and using create
console.logconfig/*from instapy import InstaPyfrom instapy.util import smart_run session = InstaPy(...)session.method(...)session.method(...)session.method(...)session.method(...)session.method(...)session.method(...)session.method(...)# a python comment in the codesession.method(...)session.method(...)session.end()*/ console.logsmartConfig/*from instapy import InstaPyfrom instapy.util import smart_run session = InstaPy(...)with smart_run(session): session.method(...) session.method(...) session.method(...) session.method(...) session.method(...) session.method(...) session.method(...) # a python comment in the code session.method(...) session.method(...) session.end()*/ create, true // will write the output to 'docker_quickstart.py'create, true, 'my-config.py' // will write the output to 'my-config.py'
Setup interface/ setup arg component
To "easily" generate an ui from api.json use these functions setupInterface
and setupArgComponent
// def: default value given to argComponent// argName: name given of argument // _constraints:// { _step: undefined | number// , _min: undefined | number// , _max: undefined | number// } // _subType: 'Number' | 'String' // Note: It is never 'Number' // _subTypes list of all the types in order // _options: list of Types, Numbers and Strings // args: { argName: buildArg } from raw.<methodName>.args// methodName: said name of method from raw.<methodName> interface.set_do_follow// set_do_follow// enabled, Type: Union, default: false// percentage, Type: Union, default: 0// times, Type: Number, default: 1
Control bot from TS/JS
Setup controls
controls .start .then // Bot started
start
// Starts bot using docker-compose// Uses "docker_quickstart.py" as configuration file taken from InstaPy Project pathcontrols .start .then // Bot started
stop
// Stops bot using docker-composecontrols .stop .then // Bot stopped
status
// Watch bot-status using docker-compose// returns: 'Not Initialised' | 'Done' | 'Running' | 'Stopped'// (status: string) => {}status .then // Done // Give a function to set that gets called everytime botStatus get changed.controls .status .set // Remove given functioncontrols .status .reset
logs
// Watch bot-logs using docker-compose// returns: a log line concurrently at InstaPy's output // Give a function to set that gets called everytime a new log is given// (logLine: string) => {}controls .logs .set // Attaching to instapy_web_1...// web_1_3e4... | --2018-12-19 ...// '' | Resolving... // Remove given functioncontrols .logs .reset
Generating api.json
Deprecated this kind of functionality will be moved to InstaPy soon, hopefully
Cloning InstaPy Project
npm run instapy:clone
Updating InstaPy
npm run instapy:update
Generate api.json
npm run gen-api
Develop api.json
npm run gen-api:dev
Updating and publishing the Project
npm version <major | minor | patch>
npm publish
To-Do
- generate api.json, 'including types'
- expose api generated from api.json
- add bot controls