Stats

Stats

Stats stores and prints statistics.

The bot logs statistics each ~10s (if they changed):

  stat info [12y 34d 12h 34m 56s] rx:32 tx:16 | allow/deny:5/0 typing:3 new:7(start:2 action:1) edit:1 | reply:16 | no_match:0 err:0

General statistics

Statistics Description
[...] Process uptime
rx Amount of received events from Callback API
tx Amount of sent messages

Callback API event statistics

Statistics Description
new message_new events
allow message_allow events
deny message_deny events
edit message_edit events
reply message_reply events
typing message_typing_state events

Other event statistics

Statistics Description
start start events
action service_action events
no_match no_match events
err handler_error events

Constructor

new Stats() → {Stats}

Source:
Returns:
Type:
Stats

Members

(private, static) this._eventCounters :Object

Count of various events

Source:
Type:
  • Object

(private, static) this._previous :string

Previous stats log message, without time

Source:
Type:
  • string

(private, static) this._rx :number

Count of requests from the Callback API

Source:
Type:
  • number

(private, static) this._tx :number

Count of messages sent

Source:
Type:
  • number

Methods

event(name)

This is used to tell Stats that an event was emitted

Source:
Parameters:
Name Type Description
name string

the event name

getEventCount(name) → {string}

How much events of this type were emitted?

Source:
Parameters:
Name Type Description
name string

the name of the event you're curious about

Returns:
Type:
string

the count

print()

Prints the statistics if they changed

Source:

sent()

This is used to tell Stats that a message was sent

Source: