sender

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2022 License: Unlicense Imports: 20 Imported by: 0

README

VK Audiomessage Sender

This tiny script helps you send audio message to person at VK.

Attention! Your application have to have direct authorization ability!

Setup

You should set up this Auth fields in call:

  1. ClientID — your application has client ID
  2. ClientSecret — your application has client secret key; you have to have direct authorization ability!
  3. Username — your username: phone or email
  4. Password — your password in plain text 🤷‍♂️
  5. Filename — your .ogg filename (you should use mono,16KHz,16Kb/s audio) without path
  6. Recipient — recipient user ID

You can set up this Setup fields in call:

  1. SaveOauth — should the application save VK token to file
  2. OauthFile — custom filename for token; otherwise file has name vk-token (see defaultOauthFile)

Usage

This script was tested on Go 1.14. You have to use application with enabled direct authorizaion.

Example (w/o token saving)

package main

import sender "github.com/dimon4ezzz/vk-audiomessage-sender"

func main() {
    auth := sender.Auth{
        ClientID: 111222,
        ClientSecret: "Z6jB1ka2uinYsHhHbZxr",
        Username: "[email protected]",
        Password: "dolphins42",
        Filename: "audiomessage.ogg",
        Recipient: 11235813
    }
    sender.Send(auth, Setup{})
}

If needed (2fa activated): wait for 2fa code prompt and type this code.

At the end of this script you will see link to your message at full VK Web version.

Token is saved with AES, encrypted with your password.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(auth Auth, setup Setup)

Send is a main function to send audio message

Types

type Auth

type Auth struct {
	ClientID     int    // VK Application Client ID
	ClientSecret string // VK Application Client secret
	Username     string // Sender username, e.g. email
	Password     string // Sender password in plain text
	Filename     string // File to send; must be .ogg (mono)
	Recipient    int    // Recipient VK ID
}

Auth is data for send message

type Document

type Document struct {
	Owner int
	ID    int
}

func (Document) String

func (doc Document) String() string

type DocumentResponse

type DocumentResponse struct {
	Response struct {
		Message struct {
			ID    int `json:"id,omitempty"`
			Owner int `json:"owner_id,omitempty"`
		} `json:"audio_message,omitempty"`
	} `json:"response,omitempty"`
}

type FileResponse

type FileResponse struct {
	File string `json:"file,omitempty"`
}

type Message

type Message struct {
	User int
	ID   int
}

func (Message) String

func (mes Message) String() string

type MessageResponse

type MessageResponse struct {
	Response int `json:"response,omitempty"`
}

type OauthResponse

type OauthResponse struct {
	URI   string `json:"redirect_uri,omitempty"`
	Token string `json:"access_token,omitempty"`
}

type Setup

type Setup struct {
	SaveOauth bool   // Should the application save oauth
	OauthFile string // Custom oauth store file; can be empty (see DefaultOauthFile)
}

Setup is data for application running. Can be empty.

type UploadURLResponse

type UploadURLResponse struct {
	Response struct {
		URI string `json:"upload_url,omitempty"`
	} `json:"response,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL