bot

package
v0.0.0-...-cf50bff Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: MPL-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	// contains filtered or unexported fields
}

func NewBot

func NewBot(token string) *Bot

func (*Bot) AddNode

func (p *Bot) AddNode(sender *User, message *tb.Message, body string)

func (*Bot) DefaultHandle

func (p *Bot) DefaultHandle()

func (*Bot) GetSubUrl

func (p *Bot) GetSubUrl(nodeList string, typ string) string

func (*Bot) Handle

func (p *Bot) Handle()

func (*Bot) HandleSub

func (p *Bot) HandleSub()

func (*Bot) Init

func (p *Bot) Init() error

func (*Bot) ProxyCheck

func (p *Bot) ProxyCheck(sender *User, message *tb.Message, body string)

func (*Bot) Scheduler

func (p *Bot) Scheduler(scheduler *tasks.Scheduler) error

func (*Bot) SetDb

func (p *Bot) SetDb(dsn string) error

func (*Bot) SetEnputiHost

func (p *Bot) SetEnputiHost(host string) error

func (*Bot) SetMiniEnputiHost

func (p *Bot) SetMiniEnputiHost(host string) error

func (*Bot) SetProxy

func (p *Bot) SetProxy(proxy string) error

func (*Bot) Short

func (p *Bot) Short(u string) (string, error)

func (*Bot) Start

func (p *Bot) Start() error

func (*Bot) TbUser2User

func (p *Bot) TbUser2User(tbUser *tb.User) *User

type ProxyCheck

type ProxyCheck struct {
	NodeName string
	Speed    float64
	Delay    time.Duration
	Proxy    proxy.Proxy
	Usable   bool
}

func NewProxyCheck

func NewProxyCheck(p proxy.Proxy) *ProxyCheck

func (*ProxyCheck) Check

func (p *ProxyCheck) Check() error

func (ProxyCheck) Info

func (p ProxyCheck) Info() string

func (*ProxyCheck) Init

func (p *ProxyCheck) Init()

type ProxyCheckInfo

type ProxyCheckInfo struct {
	Text    string
	Sender  *User
	Message *tb.Message
}

type ProxyCheckList

type ProxyCheckList []*ProxyCheck

func (ProxyCheckList) All

func (p ProxyCheckList) All(fn func(value *ProxyCheck) bool) bool

All will return true if all callbacks return true. It follows the same logic as the all() function in Python.

If the list is empty then true is always returned.

func (ProxyCheckList) Any

func (p ProxyCheckList) Any(fn func(value *ProxyCheck) bool) bool

Any will return true if any callbacks return true. It follows the same logic as the any() function in Python.

If the list is empty then false is always returned.

func (ProxyCheckList) Append

func (p ProxyCheckList) Append(elements ...*ProxyCheck) ProxyCheckList

Append will return a new slice with the elements appended to the end.

It is acceptable to provide zero arguments.

func (ProxyCheckList) Bottom

func (p ProxyCheckList) Bottom(n int) (top ProxyCheckList)

Bottom will return n elements from bottom

that means that elements is taken from the end of the slice for this [1,2,3] slice with n == 2 will be returned [3,2] if the slice has less elements then n that'll return all elements if n < 0 it'll return empty slice.

func (ProxyCheckList) Contains

func (p ProxyCheckList) Contains(lookingFor *ProxyCheck) bool

Contains returns true if the element exists in the slice.

When using slices of pointers it will only compare by address, not value.

func (ProxyCheckList) Diff

func (p ProxyCheckList) Diff(against ProxyCheckList) (added, removed ProxyCheckList)

Diff returns the elements that needs to be added or removed from the first slice to have the same elements in the second slice.

The order of elements is not taken into consideration, so the slices are treated sets that allow duplicate items.

The added and removed returned may be blank respectively, or contain upto as many elements that exists in the largest slice.

func (ProxyCheckList) DropTop

func (p ProxyCheckList) DropTop(n int) (drop ProxyCheckList)

DropTop will return the rest slice after dropping the top n elements if the slice has less elements then n that'll return empty slice if n < 0 it'll return empty slice.

func (ProxyCheckList) Each

func (p ProxyCheckList) Each(fn func(*ProxyCheck)) ProxyCheckList

Each is more condensed version of Transform that allows an action to happen on each elements and pass the original slice on.

cars.Each(func (car *Car) {
    fmt.Printf("Car color is: %s\n", car.Color)
})

Pie will not ensure immutability on items passed in so they can be manipulated, if you choose to do it this way, for example:

// Set all car colors to Red.
cars.Each(func (car *Car) {
    car.Color = "Red"
})

func (ProxyCheckList) Equals

func (p ProxyCheckList) Equals(rhs ProxyCheckList) bool

Equals compare elements from the start to the end,

if they are the same is considered the slices are equal if all elements are the same is considered the slices are equal if each slice == nil is considered that they're equal

if element realizes Equals interface it uses that method, in other way uses default compare

func (ProxyCheckList) Extend

func (p ProxyCheckList) Extend(slices ...ProxyCheckList) (ss2 ProxyCheckList)

Extend will return a new slice with the slices of elements appended to the end.

It is acceptable to provide zero arguments.

func (ProxyCheckList) Filter

func (p ProxyCheckList) Filter(condition func(*ProxyCheck) bool) (ss2 ProxyCheckList)

Filter will return a new slice containing only the elements that return true from the condition. The returned slice may contain zero elements (nil).

FilterNot works in the opposite way of Filter.

func (ProxyCheckList) FilterNot

func (p ProxyCheckList) FilterNot(condition func(*ProxyCheck) bool) (ss2 ProxyCheckList)

FilterNot works the same as Filter, with a negated condition. That is, it will return a new slice only containing the elements that returned false from the condition. The returned slice may contain zero elements (nil).

func (ProxyCheckList) FindFirstUsing

func (p ProxyCheckList) FindFirstUsing(fn func(value *ProxyCheck) bool) int

FindFirstUsing will return the index of the first element when the callback returns true or -1 if no element is found. It follows the same logic as the findIndex() function in Javascript.

If the list is empty then -1 is always returned.

func (ProxyCheckList) First

func (p ProxyCheckList) First() *ProxyCheck

First returns the first element, or zero. Also see FirstOr().

func (ProxyCheckList) FirstOr

func (p ProxyCheckList) FirstOr(defaultValue *ProxyCheck) *ProxyCheck

FirstOr returns the first element or a default value if there are no elements.

func (ProxyCheckList) Float64s

func (p ProxyCheckList) Float64s() pie.Float64s

Float64s transforms each element to a float64.

func (ProxyCheckList) Insert

func (p ProxyCheckList) Insert(index int, values ...*ProxyCheck) ProxyCheckList

Insert a value at an index

func (ProxyCheckList) Ints

func (p ProxyCheckList) Ints() pie.Ints

Ints transforms each element to an integer.

func (ProxyCheckList) JSONBytes

func (p ProxyCheckList) JSONBytes() []byte

JSONBytes returns the JSON encoded array as bytes.

One important thing to note is that it will treat a nil slice as an empty slice to ensure that the JSON value return is always an array.

func (ProxyCheckList) JSONBytesIndent

func (p ProxyCheckList) JSONBytesIndent(prefix, indent string) []byte

JSONBytesIndent returns the JSON encoded array as bytes with indent applied.

One important thing to note is that it will treat a nil slice as an empty slice to ensure that the JSON value return is always an array. See json.MarshalIndent for details.

func (ProxyCheckList) JSONString

func (p ProxyCheckList) JSONString() string

JSONString returns the JSON encoded array as a string.

One important thing to note is that it will treat a nil slice as an empty slice to ensure that the JSON value return is always an array.

func (ProxyCheckList) JSONStringIndent

func (p ProxyCheckList) JSONStringIndent(prefix, indent string) string

JSONStringIndent returns the JSON encoded array as a string with indent applied.

One important thing to note is that it will treat a nil slice as an empty slice to ensure that the JSON value return is always an array. See json.MarshalIndent for details.

func (ProxyCheckList) Join

func (p ProxyCheckList) Join(glue string) (s string)

Join returns a string from joining each of the elements.

func (ProxyCheckList) Last

func (p ProxyCheckList) Last() *ProxyCheck

Last returns the last element, or zero. Also see LastOr().

func (ProxyCheckList) LastOr

func (p ProxyCheckList) LastOr(defaultValue *ProxyCheck) *ProxyCheck

LastOr returns the last element or a default value if there are no elements.

func (ProxyCheckList) Len

func (p ProxyCheckList) Len() int

Len returns the number of elements.

func (ProxyCheckList) Map

func (p ProxyCheckList) Map(fn func(*ProxyCheck) *ProxyCheck) (ss2 ProxyCheckList)

Map will return a new slice where each element has been mapped (transformed). The number of elements returned will always be the same as the input.

Be careful when using this with slices of pointers. If you modify the input value it will affect the original slice. Be sure to return a new allocated object or deep copy the existing one.

func (ProxyCheckList) Mode

func (p ProxyCheckList) Mode() ProxyCheckList

Mode returns a new slice containing the most frequently occuring values.

The number of items returned may be the same as the input or less. It will never return zero items unless the input slice has zero items.

func (*ProxyCheckList) Pop

func (p *ProxyCheckList) Pop() (popped **ProxyCheck)

Pop the first element of the slice

Usage Example:

type knownGreetings []string
greetings := knownGreetings{"ciao", "hello", "hola"}
for greeting := greetings.Pop(); greeting != nil; greeting = greetings.Pop() {
    fmt.Println(*greeting)
}

func (ProxyCheckList) Random

func (p ProxyCheckList) Random(source rand.Source) *ProxyCheck

Random returns a random element by your rand.Source, or zero

func (ProxyCheckList) Reverse

func (p ProxyCheckList) Reverse() ProxyCheckList

Reverse returns a new copy of the slice with the elements ordered in reverse. This is useful when combined with Sort to get a descending sort order:

ss.Sort().Reverse()

func (ProxyCheckList) Send

func (p ProxyCheckList) Send(ctx context.Context, ch chan<- *ProxyCheck) ProxyCheckList

Send sends elements to channel in normal act it sends all elements but if func canceled it can be less

it locks execution of gorutine it doesn't close channel after work returns sended elements if len(this) != len(old) considered func was canceled

func (ProxyCheckList) SequenceUsing

func (p ProxyCheckList) SequenceUsing(creator func(int) *ProxyCheck, params ...int) ProxyCheckList

SequenceUsing generates slice in range using creator function

There are 3 variations to generate:

  1. [0, n).
  2. [min, max).
  3. [min, max) with step.

if len(params) == 1 considered that will be returned slice between 0 and n, where n is the first param, [0, n). if len(params) == 2 considered that will be returned slice between min and max, where min is the first param, max is the second, [min, max). if len(params) > 2 considered that will be returned slice between min and max with step, where min is the first param, max is the second, step is the third one, [min, max) with step, others params will be ignored

func (ProxyCheckList) Shift

Shift will return two values: the shifted value and the rest slice.

func (ProxyCheckList) Shuffle

func (p ProxyCheckList) Shuffle(source rand.Source) ProxyCheckList

Shuffle returns shuffled slice by your rand.Source

func (ProxyCheckList) SortStableUsing

func (p ProxyCheckList) SortStableUsing(less func(a, b *ProxyCheck) bool) ProxyCheckList

SortStableUsing works similar to sort.SliceStable. However, unlike sort.SliceStable the slice returned will be reallocated as to not modify the input slice.

func (ProxyCheckList) SortUsing

func (p ProxyCheckList) SortUsing(less func(a, b *ProxyCheck) bool) ProxyCheckList

SortUsing works similar to sort.Slice. However, unlike sort.Slice the slice returned will be reallocated as to not modify the input slice.

func (ProxyCheckList) Strings

func (p ProxyCheckList) Strings() pie.Strings

Strings transforms each element to a string.

If the element type implements fmt.Stringer it will be used. Otherwise it will fallback to the result of:

fmt.Sprintf("%v")

func (ProxyCheckList) StringsUsing

func (p ProxyCheckList) StringsUsing(transform func(*ProxyCheck) string) pie.Strings

StringsUsing transforms each element to a string.

func (ProxyCheckList) SubSlice

func (p ProxyCheckList) SubSlice(start int, end int) (subSlice ProxyCheckList)

SubSlice will return the subSlice from start to end(excluded)

Condition 1: If start < 0 or end < 0, nil is returned. Condition 2: If start >= end, nil is returned. Condition 3: Return all elements that exist in the range provided, if start or end is out of bounds, zero items will be placed.

func (ProxyCheckList) Top

func (p ProxyCheckList) Top(n int) (top ProxyCheckList)

Top will return n elements from head of the slice if the slice has less elements then n that'll return all elements if n < 0 it'll return empty slice.

func (ProxyCheckList) Unshift

func (p ProxyCheckList) Unshift(elements ...*ProxyCheck) (unshift ProxyCheckList)

Unshift adds one or more elements to the beginning of the slice and returns the new slice.

func (ProxyCheckList) UsableCount

func (p ProxyCheckList) UsableCount() uint32

func (*ProxyCheckList) UsableList

func (p *ProxyCheckList) UsableList() pie.Strings

func (*ProxyCheckList) UsableNodeList

func (p *ProxyCheckList) UsableNodeList() ProxyCheckList

type User

type User struct {
	tb.User

	ID        int64  `json:"id" gorm:"primaryKey"`
	CreatedAt uint32 `json:"created_at,omitempty" gorm:"autoCreateTime:autoCreateTime"`
	UpdatedAt uint32 `json:"updated_at,omitempty" gorm:"autoUpdateTime:autoUpdateTime"`
}

func (*User) ToTb

func (p *User) ToTb() *tb.User

Jump to

Keyboard shortcuts

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