Class: TGRequest

nationscript/requests/misc~TGRequest()

Request subclass for building requests to the telegrams API.

Constructor

new TGRequest()

Additionally mandates the a, tgid, key, to, and clientarguments and sets theaandclient` arguments.

Members

(package) client :string

The TG client key to use when executing telegram requests.

Type:
  • string

recruitment :boolean

Declares whether the TG being sent via this request is a recruitment telegram.

Type:
  • boolean
Default Value:
  • false

Methods

(async) raw()

(async) send() → {Promise.<boolean>}

Calls the raw function and passes the returned response stream through the streamToString function.

Returns:

true if the TG was sent, otherwise false

Type
Promise.<boolean>

setIsRecruitment(is) → {this}

Adjust whether the telegram to be sent by this request is a recruitment telegram. By default, a non-recruitment telegram is assumed.

Parameters:
Name Type Description
is boolean

true to declare a recruitment telegram, false to declare a regular one

Returns:

The request, for chaining

Type
this

setRecipient(recipient) → {this}

Register the nation that should receive the telegram.

Parameters:
Name Type Description
recipient string

Nation to send the telegram to

Returns:

The request, for chaining

Type
this

setTelegram(id, secret)

Sets the details of the telegram that should be sent.

Parameters:
Name Type Description
id number

Telegram ID

secret string

Secret Key of the telegram