Documentation
¶
Overview ¶
Package sessions implements types for working with telegram sessions.
Index ¶
Constants ¶
const ( InMenu state = iota InInputDialog )
Possible states of the user session.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActiveSessions ¶
type ActiveSessions struct {
// contains filtered or unexported fields
}
ActiveSessions represents list of all active telegram sessions.
func NewActiveSessions ¶
func NewActiveSessions(timeout time.Duration, frequency time.Duration, errorLog *log.Logger) *ActiveSessions
NewActiveSessions initializes new instance of ActiveSessions object. The argument 'timeout' specifies the maximum amount of time that a session can be inactive before it is terminated. The argument 'frequency' specifies how often the search for inactive sessions occurs. 'errorLog' argument is used to log error messages that may occur during session termination.
func (*ActiveSessions) Get ¶
func (as *ActiveSessions) Get(userID int64) (Session, bool)
Get returns session of user with specified ID. If the session doesn't exist, second parameter will be equal to false.
func (*ActiveSessions) Set ¶
func (as *ActiveSessions) Set(userID int64, s Session, isNew bool)
Set adds new or replaces existing session. The last boolean parameter specifies if it is a completely new session (with new image) or same session that just need to be updated. This is needed to avoid the memory leaks from the goroutines that may be waiting for the user input.