quitter

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2016 License: MIT Imports: 6 Imported by: 2

README

go-quitter

Command line GNU Social client and Go library

GoDoc


$ go-quitter help

##########	go-quitter v0.0.8	##############################

	  Copyright 2016 aerth@sdf.org

go-quitter config		Creates config file	**do this first**
go-quitter read			Reads 20 new posts
go-quitter read fast		Reads 20 new posts (no delay)
go-quitter home			Your home timeline.
go-quitter user username	Looks up "username" timeline
go-quitter post ____ 		Posts to your node.
go-quitter post 		Post mode.
go-quitter mentions		Mentions your @name
go-quitter search ___		Searches for ____
go-quitter search		Search mode.
go-quitter follow		Follow a user
go-quitter unfollow		Unfollow a user
go-quitter groups		List all groups on current node
go-quitter mygroups		List only groups you are member of
go-quitter join ___		Join a !group
go-quitter leave ___		Part a !group (can also use part)

Using environmental variables will override the config:

GNUSOCIALNODE
GNUSOCIALPASS
GNUSOCIALUSER
GNUSOCIALPATH

Set your environmental variable to change nodes, use a different config,
	or change user or password for a one-time session.

For example: "export GNUSOCIALNODE=gs.sdf.org" in your ~/.shrc or ~/.profile



################################################################################


Install binary for your OS (now for every OS)

Latest Binary Releases

Windows | Linux | FreeBSD | NetBSD | OS X | Other OS or Architecture

Install from Go source (sometimes newer)

If you have Go toolchain installed you can build it yourself with:

GOPATH=/tmp/go go get -v -u github.com/aerth/go-quitter/cmd/go-quitter
cd $GOPATH/src/github.com/aerth/go-quitter/cmd/go-quitter
make && sudo make install

Go Get-able

Or use go get:

go get -v -u github.com/aerth/go-quitter/cmd/go-quitter

Configure

To avoid storing the password in plaintext, go-quitter saves an encrypted config file at ~/.go-quitter, if it gets messed up just delete it and make a new one. You can switch config files on the fly using the environmental variable GNUSOCIALPATH.

go-quitter config
GNUSOCIALPATH=gnusocial.de go-quitter config
GNUSOCIALPATH=gnusocial.no go-quitter config
GNUSOCIALPATH=gnusocial.se go-quitter config

Next time you run it, it will ask for your config password. I like to keep it blank so I just hit ENTER.

Or.. Use in scripts

For automation, scripts, and cronjobs, you need to delete config file and use environmental variables instead. Something like…

// cat ~/.shrc || cat ~/.zshrc || cat ~/.bashrc || cat ~/.whatrc
export GNUSOCIALUSER=yourname
export GNUSOCIALPASS=yourpass
export GNUSOCIALNODE=gnusocial.de

// then run this command so you dont have to log out and back in.
. ~/.shrc


// make sure you chmod your shell rc file if shared machine.
chmod o-r ~/.shrc
chmod g-r ~/.shrc

## Usage

When running go-quitter with no arguments, a list of commands is printed.
For more information, run `go-quitter help`

```shell

$ go-quitter read // public timeline
$ go-quitter home // home timeline
$ go-quitter search // enters search mode
$ go-quitter post \!group \#hashtag \#EscapeSymbolsWithABackslash
#!/bin/sh                                                                       
unset GNUSOCIALNODE                                                          
GNUSOCIALNODE=gnusocial.de go-quitter read fast >> treet.log                         
GNUSOCIALNODE=quitter.es go-quitter read fast >> treet.log                           
GNUSOCIALNODE=shitposter.club go-quitter read fast >> treet.log                      
GNUSOCIALNODE=sealion.club go-quitter read fast >> treet.log   

Todo
  • Learn Go
  • Include user interface with up/down scrolling
  • Write tests
  • cat filename.txt | go-quitter // I may introduce this just because it would make uploading photos easy.
Contributing
  • Pull requests are welcome.

Documentation

Overview

Package quitter is a Go library to interact with GNU Social instances.

The MIT License (MIT)

Copyright (c) 2016 aerth

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Example
package main

import (
	"fmt"
	"os"

	quitter "github.com/aerth/go-quitter"
)

func main() {
	q := quitter.NewSocial()
	q.Username = "username"
	q.Password = "password"
	q.Node = "localhost"
	quips, err := q.GetHome()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	for _, quip := range quips {
		fmt.Printf("%s %s", quip.IdStr, quip.Text)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Badrequest

type Badrequest struct {
	Error   string `json:"error"`
	Request string `json:"request"`
}

Badrequest is an error. If the API doesn't respond how we like, it replies using this struct (in json)

type Group added in v0.0.5

type Group struct {
	Id          int64  `json:"id"`
	Url         string `json:"url"`
	Nickname    string `json:"nickname"`
	Fullname    string `json:"fullname"`
	Member      bool   `json:"member"`
	Membercount int64  `json:"member_count"`
	Description string `json:"description"`
}

Group is a GNU Social Group, gets returned by GS API.

type Quip added in v0.0.8

type Quip struct {
	Id                   int64    `json:"id"`
	IdStr                string   `json:"id_str"`
	InReplyToScreenName  string   `json:"in_reply_to_screen_name"`
	InReplyToStatusID    int64    `json:"in_reply_to_status_id"`
	InReplyToStatusIdStr string   `json:"in_reply_to_status_id_str"`
	InReplyToUserID      int64    `json:"in_reply_to_user_id"`
	InReplyToUserIdStr   string   `json:"in_reply_to_user_id_str"`
	Lang                 string   `json:"lang"`
	Place                string   `json:"place"`
	PossiblySensitive    bool     `json:"possibly_sensitive"`
	RetweetCount         int      `json:"retweet_count"`
	Retweeted            bool     `json:"retweeted"`
	RetweetedStatus      *Quip    `json:"retweeted_status"`
	Source               string   `json:"source"`
	Text                 string   `json:"text"`
	Truncated            bool     `json:"truncated"`
	User                 User     `json:"user"`
	WithheldCopyright    bool     `json:"withheld_copyright"`
	WithheldInCountries  []string `json:"withheld_in_countries"`
	WithheldScope        string   `json:"withheld_scope"`
}

Quip is a GNU Social Quip, gets returned by GS API.

type Social added in v0.0.9

type Social struct {
	Username string
	Password string
	Node     string
	Scheme   string
}

Social is credentials needed for logging in. Set it with NewSocial()

func NewSocial added in v0.0.9

func NewSocial() *Social

Sets the authentication method and choose node. Use like this:

q := qw.NewSocial()
q.Username = "john"
q.Password = "pass123"
q.Node = "gnusocial.de"
q.GetHome(false)
Example
package main

import (
	"fmt"
	"os"

	quitter "github.com/aerth/go-quitter"
)

func main() {
	q := quitter.NewSocial()
	q.Username = "username"
	q.Password = "password"
	q.Node = "localhost"
	quips, err := q.GetHome()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	for _, quip := range quips {
		fmt.Printf("%s %s", quip.IdStr, quip.Text)
	}
}
Output:

func (Social) DoFollow added in v0.0.9

func (a Social) DoFollow(followstr string) (user User, err error)

DoFollow sends a request to follow a user

func (Social) DoPublicSearch added in v0.0.9

func (a Social) DoPublicSearch(searchstr string) ([]Quip, error)

DoPublicSearch returns results for query searchstr. Does not send auth info.

func (Social) DoSearch added in v0.0.9

func (a Social) DoSearch(searchstr string) ([]Quip, error)

DoSearch returns results for query searchstr. Does send auth info.

func (Social) DoUnfollow added in v0.0.9

func (a Social) DoUnfollow(followstr string) (user User, err error)

DoUnfollow sends a request to unfollow a user

func (Social) FireGET added in v0.0.9

func (a Social) FireGET(path string) ([]byte, error)

func (Social) FirePOST added in v0.0.9

func (a Social) FirePOST(path string, v url.Values) ([]byte, error)

func (Social) GetHome added in v0.0.9

func (a Social) GetHome() ([]Quip, error)

GetHome shows 20 from home timeline.

func (Social) GetMentions added in v0.0.9

func (a Social) GetMentions() ([]Quip, error)

GetMentions shows 20 newest mentions of your username.

func (Social) GetPublic added in v0.0.9

func (a Social) GetPublic() ([]Quip, error)

GetPublic shows 20 new messages.

Example
package main

import (
	"fmt"
	"os"

	quitter "github.com/aerth/go-quitter"
)

func main() {
	q := quitter.NewSocial()
	q.Username = "username"
	q.Password = "password"
	q.Node = "localhost"
	quips, err := q.GetPublic()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	for _, quip := range quips {
		fmt.Printf("%s %s", quip.IdStr, quip.Text)
	}

}
Output:

func (Social) GetUserTimeline added in v0.0.9

func (a Social) GetUserTimeline(userlookup string) ([]Quip, error)

GetUserTimeline returns a userlookup's timeline

func (Social) JoinGroup added in v0.0.9

func (a Social) JoinGroup(grp string) (g Group, err error)

JoinGroup sends a request to join group grp.

func (Social) ListAllGroups added in v0.0.9

func (a Social) ListAllGroups() ([]Group, error)

ListAllGroups lists each group in a.Node Some nodes don't return anything.

func (Social) ListMyGroups added in v0.0.9

func (a Social) ListMyGroups() ([]Group, error)

ListMyGroups lists each group a a.Username is a member of

func (Social) PartGroup added in v0.0.9

func (a Social) PartGroup(grp string) (g Group, err error)

PartGroup sends a request to part group grp.

func (Social) PostNew added in v0.0.9

func (a Social) PostNew(content string) (q Quip, err error)

PostNew publishes content on a.Node, returns the new quip or an error.

Example
package main

import (
	"fmt"
	"os"

	quitter "github.com/aerth/go-quitter"
)

func main() {
	q := quitter.NewSocial()
	q.Username = "username"
	q.Password = "password"
	q.Node = "localhost"
	content := ` dang this is a " < new > ! quip about to be published>>><><><?><?><?><<?><?><?><?><?><?><?><?><"`
	quip, err := q.PostNew(content)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	fmt.Printf("%s %s", quip.IdStr, quip.Text)
}
Output:

type User

type User struct {
	Name       string `json:"name"`
	Screenname string `json:"screen_name"`
}

User is a GNU Social User, gets returned by GS API

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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