Comparing version 1.1.7 to 1.1.8-rc.1
{ | ||
"name": "puregram", | ||
"version": "1.1.7", | ||
"version": "1.1.8-rc.1", | ||
"main": "src/index.js", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -35,3 +35,3 @@ import Params from '../../typings/params'; | ||
*/ | ||
public from: User; | ||
public from: Interfaces.IUser; | ||
@@ -132,2 +132,7 @@ /** | ||
/** | ||
* [Deep-linking](https://core.telegram.org/bots#deep-linking) payload | ||
*/ | ||
public startPayload?: string | number | object; | ||
/** | ||
* For text messages, special entities like usernames, | ||
@@ -134,0 +139,0 @@ * URLs, bot commands, etc. that appear in the text |
@@ -30,2 +30,12 @@ let { inspect } = require('util'); | ||
function isParseable(source) { | ||
try { | ||
JSON.parse(source); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
class MessageContext extends Context { | ||
@@ -136,2 +146,17 @@ constructor(telegram, update) { | ||
get startPayload() { | ||
if (!this.text.startsWith('/start')) return null; | ||
if (this.text === '/start') return null; | ||
let payload = this.text.split(' ')[1]; | ||
if (!Number.isNaN(+payload)) { | ||
payload = Number.parseInt(payload); | ||
} else if (isParseable(payload)) { | ||
payload = JSON.parse(payload); | ||
} | ||
return payload | ||
} | ||
get entities() { | ||
@@ -138,0 +163,0 @@ let { entities } = this.update; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
718331
21627
1