libgosay

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 4 Imported by: 0

README

Lib Go Say (v1.0.1)

Cowsay reimplementation in Go lib !

Go Report Card shield.io-coverage

One day, i noticed that there no lib to easy use CowSay with Go. So i made it :D

Gopher Say with libgosay

GopherSay

How to using it

First, use Create() to instance and init a Pimp struct
Now you can config you gosay instance like you whant
When your configuration are done, you can use Say() to build a string formated like Cowsay

Simple exemple

package main

inport (
    "fmt"

    "git.iglou.eu/Production/libgosay"
)

func main() {
    // Instance and init gosay Pimp struc
    gosay := libgosay.Create()

    // Catch say result
    say, err := gosay.Say("Heya, it's me Imoen")
    if err != nil {
        // do some thing ...
    }

    fmt.Println(say)
}

Cool Features

Some features are the same of Cowsay, but with little more.

  • Max Char by line
  • Show body only without any bubble
  • Can pimp your Bubble
  • Can pimp Tail Eyes Tongue
  • Load custom Body (with Pimp.Body = body string)

Compatible body are avaiable (Converted from Cowsay and Ponysay): Official repo https://git.iglou.eu/Production/libgosay_template Github repo https://github.com/IGLOU-EU/libgosay_template

Ex:

gosay := libgosay.Create()

// Pimp your gosay
gosay.Eyes = "0o"
gosay.Tongue = "VV"
gosay.Tail = "o"

Give us:

 _____________________ 
< Heya, it's me Imoen >
 --------------------- 
    o   ˏ⋒___⋒ˎ
     o  ▏ 0__O ▕
        ▏  VV  ▕
        ▏U    U▕
        ▏      ▕
        ˋ-U---U-ˊ

Pimp your bubble

By default, the traditionnal 'say' bubble are used

 ________
< A word >
 --------

 _____________________
/ Multiple line       \
| message exemple     |
\ for my BFF Imoen... /
 ---------------------

But you can using some other presconfigured Bubble

  • Speak()
  • Think()
  • ThinkUTF8()
  • Whisper()
  • WhisperUTF8()
  • Narrative()
  • BigBoxUTF8()
  • AsianBoxUTF8()

like this:

gosay := libgosay.Create()

// Change default bubble
gosay.Bubble.Whisper()

And, you can also setting it manually

OneLine config is used instead of FirstLine, Lines and LastLine
Only if the string you want to say, is not bigger then one line.

  • Each config line use 3 Rune
  • First rune are for the Left side
  • Second rune is repeated X.time (string len)
  • Third rune are for the Right side
gosay := libgosay.Create()

// Eatch 
gosay.Bubble.Before = [3]rune{'', '', ''}
gosay.Bubble.OneLine = [3]rune{'', '', ''}
gosay.Bubble.FirstLine = [3]rune{'', '', ''}
gosay.Bubble.Lines = [3]rune{'', '', ''}
gosay.Bubble.LastLine = [3]rune{'', '', ''}
gosay.Bubble.After = [3]rune{'', '', ''}
gosay.Bubble.Tail = ''

Todo

  • Open a ticket !

License

 ____________________________________________________________ 
/ This project is licensed under the MIT license.            \
\ The licence file is available on repo LICENSE file         /
 ------------------------------------------------------------ 
        \   ˏ⋒___⋒ˎ
         \  ▏ @__@ ▕
            ▏  UU  ▕
            ▏U    U▕
            ▏      ▕
            ˋ-U---U-ˊ

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BubbleDef

type BubbleDef struct {
	Before    [3]rune
	OneLine   [3]rune
	FirstLine [3]rune
	Lines     [3]rune
	LastLine  [3]rune
	After     [3]rune
	Tail      rune
}

BubbleDef is for defined the bubble structure That cane be done manually or using a pre configured structure

func (*BubbleDef) AsianBoxUTF8 added in v1.0.1

func (b *BubbleDef) AsianBoxUTF8()

AsianBoxUTF8 define a narrative text structure with asian style

func (*BubbleDef) BigBoxUTF8 added in v1.0.1

func (b *BubbleDef) BigBoxUTF8()

BigBoxUTF8 define a narrative text structure with a big box

func (*BubbleDef) Narrative

func (b *BubbleDef) Narrative()

Narrative define a narrative text structure

func (*BubbleDef) Speak

func (b *BubbleDef) Speak()

Speak define a speaking bubble structure

func (*BubbleDef) Think

func (b *BubbleDef) Think()

Think define a thinking bubble structure

func (*BubbleDef) ThinkUTF8 added in v1.0.1

func (b *BubbleDef) ThinkUTF8()

ThinkUTF8 define a thinking bubble structure but in UTF-8

func (*BubbleDef) Whisper

func (b *BubbleDef) Whisper()

Whisper define a whisp bubble structure

func (*BubbleDef) WhisperUTF8 added in v1.0.1

func (b *BubbleDef) WhisperUTF8()

WhisperUTF8 define a whisp bubble structure but in UTF-8

type Pimp

type Pimp struct {
	Column int
	Said   string

	Body   string
	Tongue string
	Tail   string

	Eyes string
	EyeL string
	EyeR string

	Bubble BubbleDef
}

Pimp is the main part of this lib You need to instance a Pimp struct for using it

func Create

func Create() Pimp

Create make a Pimp struct, init default values and return it

func (Pimp) Say

func (p Pimp) Say(s string) (string, error)

Say is for say some thing with the lib

Jump to

Keyboard shortcuts

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