World Conquest Chronicles

World Conquest Chronicles

Romani Gate, v1.4

Web service for an interaction with the Instagram* Direct API.

Split and simplify endpoints of the web service API.

 

* Запрещена в России / Banned in Russia.

Change Log

  • Add a separate command for a getting:
    • of an user info;
    • of a thread info.
  • Simplify the command for a getting of a thread history:
    • require specify a thread ID instead get it implicitly;
    • remove:
      • getting of an user info;
      • pagination support.

Features

  • log in a bot account;
  • working mode:
    • run as a web service;
    • control via the JSON-RPC like API;
  • commands:
    • send a text message to a specified user;
    • send a link message to a specified user:
      • automatic extract links from a message body;
    • send a photo message to a specified user:
      • automatic upload a specified photo to the Instagram* Direct:
        • by an absolute path;
        • by a path relative to a current working directory;
    • read an info of a specified user;
    • read an info of a thread with a specified user;
    • read a history of a specified thread:
      • automatic extract a text from a link message.

 

* Запрещена в России / Banned in Russia.

Commands

General Command

General command format in the JSON Schema format:

{
  "type": "object",
  "required": ["name", "parameters"],
  "additionalProperties": false,
  "properties": {
    "name": {
      "type": "string",
      "enum": [
        "send_message",
        "send_photo",
        "get_user",
        "get_thread",
        "get_thread_history"
      ]
    },
    "parameters": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {".+": {}}
    }
  }
}

Get User Command

Get user command format in the JSON Schema format:

{
  "type": "object",
  "required": ["name", "parameters"],
  "additionalProperties": false,
  "properties": {
    "name": {"type": "string", "enum": ["get_user"]},
    "parameters": {
      "type": "object",
      "required": ["user_id"],
      "additionalProperties": false,
      "properties": {"user_id": {"type": "string", "pattern": "^\\d+$"}}
    }
  }
}

Example:

{"name": "get_user", "parameters": {"user_id": "1599620166"}}

Get Thread Command

Get thread command format in the JSON Schema format:

{
  "type": "object",
  "required": ["name", "parameters"],
  "additionalProperties": false,
  "properties": {
    "name": {"type": "string", "enum": ["get_thread"]},
    "parameters": {
      "type": "object",
      "required": ["user_id"],
      "additionalProperties": false,
      "properties": {"user_id": {"type": "string", "pattern": "^\\d+$"}}
    }
  }
}

Example:

{"name": "get_thread", "parameters": {"user_id": "1599620166"}}

Get Thread History Command

Get thread history command format in the JSON Schema format:

{
  "type": "object",
  "required": ["name", "parameters"],
  "additionalProperties": false,
  "properties": {
    "name": {"type": "string", "enum": ["get_thread_history"]},
    "parameters": {
      "type": "object",
      "required": ["thread_id", "maximal_cursor_id"],
      "additionalProperties": false,
      "properties": {
        "thread_id": {"$ref": "#/definitions/id"},
        "maximal_cursor_id": {"oneOf": [
          {"type": "null"},
          {"$ref": "#/definitions/id"}
        ]}
      }
    }
  },
  "definitions": {"id": {"type": "string", "pattern": "^\\d+$"}}
}

Example:

{
  "name": "get_thread_history",
  "parameters": {
    "thread_id": "340282366841710300949128141360573393375",
    "maximal_cursor_id": null
  }
}

API

API description in the Swagger format:

openapi: '3.0.0'
info:
  title: romani-gate
  version: 1.4.0
servers:
- url: http://localhost:{port}
  variables:
    port:
      default: '8080'
paths:
  /:
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/command'
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
                oneOf:
                - $ref: '#/components/schemas/message'
                - $ref: '#/components/schemas/user'
                - $ref: '#/components/schemas/thread'
                - $ref: '#/components/schemas/history'
        400:
          $ref: '#/components/responses/error'
        405:
          $ref: '#/components/responses/error'
        500:
          $ref: '#/components/responses/error'
components:
  schemas:
    nullable_integer:
      type: integer
      nullable: true
    nullable_number:
      type: number
      nullable: true
    nullable_string:
      type: string
      nullable: true
    numeric_string:
      type: string
      pattern: ^\\d+$
    alphabetical_string:
      type: string
      pattern: ^[a-z_]+$
    geo:
      type: object
      required:
      - latitude
      - longitude
      properties:
        latitude:
          $ref: '#/components/schemas/nullable_number'
        longitude:
          $ref: '#/components/schemas/nullable_number'
    address:
      type: object
      required:
      - street
      - city
      - zip
      - country_code
      properties:
        street:
          $ref: '#/components/schemas/nullable_string'
        city:
          $ref: '#/components/schemas/nullable_string'
        zip:
          $ref: '#/components/schemas/nullable_string'
        country_code:
          $ref: '#/components/schemas/nullable_integer'
    location:
      type: object
      required:
      - geo
      - address
      properties:
        geo:
          $ref: '#/components/schemas/geo'
        address:
          $ref: '#/components/schemas/address'
    command:
      type: object
      required:
      - name
      - parameters
      properties:
        name:
          $ref: '#/components/schemas/alphabetical_string'
        parameters:
          type: object
    message:
      type: object
      required:
      - id
      - timestamp
      properties:
        id:
          $ref: '#/components/schemas/numeric_string'
        type:
          $ref: '#/components/schemas/alphabetical_string'
        timestamp:
          $ref: '#/components/schemas/numeric_string'
        text:
          $ref: '#/components/schemas/nullable_string'
    user:
      type: object
      required:
      - id
      - category
      - username
      - full_name
      - gender
      - birthday
      - biography
      - location
      - counters
      - flags
      properties:
        id:
          $ref: '#/components/schemas/numeric_string'
        category:
          $ref: '#/components/schemas/nullable_string'
        username:
          type: string
        full_name:
          type: string
        gender:
          $ref: '#/components/schemas/nullable_integer'
        birthday:
          $ref: '#/components/schemas/nullable_string'
        biography:
          $ref: '#/components/schemas/nullable_string'
        location:
          $ref: '#/components/schemas/location'
        counters:
          type: object
          required:
          - media
          - followers
          - followings
          properties:
            media:
              $ref: '#/components/schemas/nullable_integer'
            followers:
              $ref: '#/components/schemas/nullable_integer'
            followings:
              $ref: '#/components/schemas/nullable_integer'
        flags:
          type: object
          required:
          - is_private
          - is_business
          - is_verified
          properties:
            is_private:
              type: boolean
            is_business:
              type: boolean
              nullable: true
            is_verified:
              type: boolean
    thread:
      type: object
      required:
      - id
      properties:
        id:
          $ref: '#/components/schemas/numeric_string'
    history:
      type: object
      required:
      - messages
      - minimal_cursor_id
      properties:
        messages:
          type: array
          items:
            $ref: '#/components/schemas/message'
        minimal_cursor_id:
          type: string
          pattern: ^\\d+$
          nullable: true
  responses:
    error:
      description: Some Error
      content:
        text/plain:
          schema:
            type: string

Screenshots

POST /