Romani Gate, v1.0
Posted on

Web service for an interaction with the Instagram* Direct API.
Major release.
* Запрещена в России / Banned in Russia.
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;
- read a history of a thread with a specified user:
- automatic detect a thread ID;
- support a pagination of a history;
- filter a history by a specified user;
- restrict a history by a specified message ID;
- automatic extract a text from a link message.
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", "get_thread_history"]},
"parameters": {
"type": "object",
"additionalProperties": false,
"patternProperties": {".+": {}}
}
}
}
Send Message Command
Send message command format in the JSON Schema format:
{
"type": "object",
"required": ["name", "parameters"],
"additionalProperties": false,
"properties": {
"name": {"type": "string", "enum": ["send_message"]},
"parameters": {
"type": "object",
"required": ["user_id", "message"],
"additionalProperties": false,
"properties": {
"user_id": {"type": "string", "pattern": "^\\d+$"},
"message": {"type": "string", "minLength": 1}
}
}
}
}
Example:
{
"name": "send_message",
"parameters": {"user_id": "1599620166", "message": "test"}
}
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": ["user_id", "minimal_cursor_id"],
"additionalProperties": false,
"properties": {
"user_id": {"$ref": "#/definitions/id"},
"minimal_cursor_id": {"oneOf": [
{"type": "null"},
{"$ref": "#/definitions/id"}
]}
}
}
},
"definitions": {"id": {"type": "string", "pattern": "^\\d+$"}}
}
Example:
{
"name": "get_thread_history",
"parameters": {"user_id": "1599620166", "minimal_cursor_id": null}
}
API
API description in the Swagger format:
openapi: '3.0.0'
info:
title: romani-gate
version: 1.0.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/history'
400:
$ref: '#/components/responses/error'
405:
$ref: '#/components/responses/error'
500:
$ref: '#/components/responses/error'
components:
schemas:
numeric_string:
type: string
pattern: ^\\d+$
alphabetical_string:
type: string
pattern: ^[a-z_]+$
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:
type: string
nullable: true
history:
type: array
items:
$ref: '#/components/schemas/message'
responses:
error:
description: Some Error
content:
text/plain:
schema:
type: string
Screenshots
POST /
