lineGo

package module
v0.0.0-...-8512c53 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

lineGo

Golang lib for line unofficial API

Important

Please be warned: lineGo is in a very early beta. You will encounter bugs when using it. In addition, due to the specification of the thrift library, go func cannot be used.

Installation

go get github.com/n4tsumi/lineGo

Quick start

package main

import (
	line "github.com/n4tsumi/lineGo"
	talk "github.com/n4tsumi/lineGo/talkservice"
	"time"
)

var cl = line.NewClient()

func main() {
	cl.Login(line.Token("Your Auth Token"))
	cl.AddOpInterrupt(talk.Af_RECEIVE_MESSAGE, chatBot)

	cl.Run()
}


func chatBot(op *talk.Operation) {
	msg := op.Message

	switch {
	case msg.Text == "hello":
		cl.SendText(msg.To, "Hello!")

	case msg.Text == "time":
		cl.SendText(msg.To, time.Now().Format("2006/01/02 15:04:05"))
	}
}

Documentation

Index

Constants

View Source
const (
	LineHost = "https://legy-jp-addr.line.naver.jp"
	Register = "/api/v4/TalkService.do"
	Normal   = LineHost + "/S4"
	Polling  = LineHost + "/P4"

	SystemName = "lineGo"

	UserAgent = "Line/5.24.1"
	LineApp   = "DESKTOPMAC\t5.24.1\tOS X\t10.15.1"
)

Variables

View Source
var QrCode = QrCodeLogin{}

Functions

This section is empty.

Types

type AuthTokenLogin

type AuthTokenLogin string

func Token

func Token(authToken string) AuthTokenLogin

func (AuthTokenLogin) Type

func (a AuthTokenLogin) Type() LoginType

func (AuthTokenLogin) Value

func (a AuthTokenLogin) Value() string

type Client

type Client struct {
	Talk *talk.TalkServiceClient
	Poll *talk.TalkServiceClient

	Profile *talk.Profile

	Revision    int64
	OpInterrupt map[talk.Af]func(*talk.Operation)
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) AcceptChatInvitation

func (c *Client) AcceptChatInvitation(groupId string) (e error)

func (*Client) AcceptChatInvitationByTicket

func (c *Client) AcceptChatInvitationByTicket(groupId, ticketId string) (e error)

func (*Client) AcquireEncryptedAccessToken

func (c *Client) AcquireEncryptedAccessToken(featureType talk.Nc) (string, error)

User

func (*Client) AddOpInterrupt

func (c *Client) AddOpInterrupt(optype talk.Af, fn func(*talk.Operation))

func (*Client) BlockContact

func (c *Client) BlockContact(mid string) error

func (*Client) BlockRecommendation

func (c *Client) BlockRecommendation(mid string) error

func (*Client) CancelChatInvitation

func (c *Client) CancelChatInvitation(groupId, mid string) (e error)

func (*Client) CreateChatRoomAnnouncement

func (c *Client) CreateChatRoomAnnouncement(reqSeq int32, chatRoomMid string, typeA1 talk.Y9, contents *talk.ChatRoomAnnouncementContents) (r *talk.ChatRoomAnnouncement, err error)

func (*Client) FindAndAddContactsByMid

func (c *Client) FindAndAddContactsByMid(mid string) (map[string]*talk.Contact, error)

func (*Client) FindChatByTicket

func (c *Client) FindChatByTicket(ticketId string) (*talk.Chat, error)

func (*Client) GetAllChatIds

func (c *Client) GetAllChatIds() ([]string, []string, error)

func (*Client) GetAllContactIds

func (c *Client) GetAllContactIds() ([]string, error)

func (*Client) GetBlockedContactIds

func (c *Client) GetBlockedContactIds() ([]string, error)

func (*Client) GetChat

func (c *Client) GetChat(groupId string) (*talk.Chat, error)

func (*Client) GetChatRoomAnnouncements

func (c *Client) GetChatRoomAnnouncements(groupId string) ([]*talk.ChatRoomAnnouncement, error)

Chat

func (*Client) GetChats

func (c *Client) GetChats(groupIds []string) ([]*talk.Chat, error)

func (*Client) GetContact

func (c *Client) GetContact(mid string) (*talk.Contact, error)

Contact

func (*Client) GetContacts

func (c *Client) GetContacts(midlist []string) ([]*talk.Contact, error)

func (*Client) GetProfile

func (c *Client) GetProfile() (*talk.Profile, error)

func (*Client) GetSettings

func (c *Client) GetSettings() (*talk.Settings, error)

func (*Client) InviteIntoChat

func (c *Client) InviteIntoChat(groupId string, midlist []string) (e error)

func (*Client) KickoutFromChat

func (c *Client) KickoutFromChat(groupId, mid string) (e error)

func (*Client) LeaveChat

func (c *Client) LeaveChat(groupId string) (e error)

func (*Client) Login

func (c *Client) Login(l LineLogin, options ...LoginOption) error

Login

func (*Client) ReissueChatTicket

func (c *Client) ReissueChatTicket(groupMid string) (string, error)

func (*Client) RejectChatInvitation

func (c *Client) RejectChatInvitation(groupId string) (e error)

func (*Client) Run

func (c *Client) Run()

func (*Client) SendChatChecked

func (c *Client) SendChatChecked(to, lastMessageId string, sessionId int8) error

func (*Client) SendMessage

func (c *Client) SendMessage(msg *talk.Message) (*talk.Message, error)

Message

func (*Client) SendText

func (c *Client) SendText(to, text string) (*talk.Message, error)

func (*Client) SetOpInterrupt

func (c *Client) SetOpInterrupt(opInterrupt map[talk.Af]func(*talk.Operation))

Op Interrupt

func (*Client) UnblockContact

func (c *Client) UnblockContact(mid string) error

func (*Client) UnblockRecommendation

func (c *Client) UnblockRecommendation(mid string) error

func (*Client) UpdateChat

func (c *Client) UpdateChat(chat *talk.Chat, updateType talk.P9) (e error)

type LineLogin

type LineLogin interface {
	Type() LoginType
	Value() string
}

type LoginOption

type LoginOption interface {
	Type() OptionType
	Value() string
}

type LoginType

type LoginType int

type OptionType

type OptionType int

type OptionWithMid

type OptionWithMid string

func WithMid

func WithMid(mid string) OptionWithMid

func (OptionWithMid) Type

func (o OptionWithMid) Type() OptionType

func (OptionWithMid) Value

func (o OptionWithMid) Value() string

type QrCodeLogin

type QrCodeLogin struct{}

func (QrCodeLogin) Type

func (a QrCodeLogin) Type() LoginType

func (QrCodeLogin) Value

func (a QrCodeLogin) Value() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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