Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "tgb", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "The best choice for your Telegram Bots", | ||
@@ -5,0 +5,0 @@ "homepage": "https://666.io", |
@@ -24,2 +24,3 @@ [![Codacy][cod_b]][cod_l] | ||
* [CLI](#refCLI): + | ||
* Entities: + | ||
* Redirect: + | ||
@@ -51,3 +52,3 @@ * HashTable, Array and [Map][10] as a data source: + | ||
const bot = tgb(process.env.TELEGRAM_BOT_TOKEN); | ||
const {polling} = tgb; | ||
const {polling, entities} = tgb; | ||
@@ -59,3 +60,3 @@ //----------------------------------------------------- | ||
function({message}) { | ||
bot.sendMessage([message.from.id, `Hi: ${message.text}`]); | ||
bot.sendMessage([message.from.id, entities(message)]); | ||
}) | ||
@@ -72,2 +73,4 @@ .catch(function(error) { | ||
}); | ||
// > send: tg @gamebot /start x http://db.gg | ||
``` | ||
@@ -179,2 +182,5 @@ | ||
> tgb-cli --method getMe --token 0:XXXX --proxy "127.0.0.1:1337" | ||
> tgb-cli --method sendMessage --data "{\"chat_id\":0,\"text\":\"Hi yo\"}" | ||
> tgb-cli --method sendMessage --d.chat_id 1 --data "{\"chat_id\":0,\"text\":\"Hi yo\"}" | ||
``` | ||
@@ -211,2 +217,7 @@ | ||
tgb.buffer(proxy, token, method, data, callback(error, buf, res)) | ||
tgb.json(proxy, token, method, data, callback(error, buf, res)) | ||
- | ||
tgb.polling(token, onMessage(data)); | ||
@@ -213,0 +224,0 @@ tgb.polling(token, options{limit, timeout, interval}, onMessage(data)); |
@@ -109,10 +109,9 @@ //----------------------------------------------------- | ||
updateMpBoundary(); | ||
request.setHeader("Content-Type", mpHeaderContentType); | ||
const limit = dataIsArray ? Math.min(dataLen, schema.length) : schema.length; | ||
let count = -1, | ||
written = false; | ||
//-------]> | ||
const limit = dataIsArray ? Math.min(dataLen, schema.length) : schema.length; | ||
let count = -1; | ||
(function nextField() { | ||
@@ -122,4 +121,7 @@ ++count; | ||
if(count >= limit) { | ||
request.write(mpCRLFBoundaryEnd); | ||
uncork(request); | ||
if(written) { | ||
request.write(mpCRLFBoundaryEnd); | ||
uncork(request); | ||
} | ||
request.end(); | ||
@@ -137,2 +139,9 @@ } | ||
else { | ||
if(!written) { | ||
updateMpBoundary(); | ||
request.setHeader("Content-Type", mpHeaderContentType); | ||
written = true; | ||
} | ||
cork(request); | ||
@@ -422,3 +431,3 @@ request.write(makeFieldStr(field)); | ||
switch(type) { | ||
case "boolean": return data === true || data === 1 || data === "1" || data === "yes" || data === "ok" ? "1" : "0"; | ||
case "boolean": return data === true || data === 1 || data === "1" || data === "true" || data === "yes" || data === "ok" ? "1" : "0"; | ||
case "string": return typeof(data) === "string" || Buffer.isBuffer(data) ? data : (data + ""); | ||
@@ -425,0 +434,0 @@ case "json": return typeof(data) === "string" || Buffer.isBuffer(data) ? data : (JSON.stringify(data) || ""); |
@@ -14,5 +14,4 @@ //----------------------------------------------------- | ||
const cmdOptions = { | ||
"data": {} | ||
}; | ||
const cmdData = {}; | ||
const cmdOptions = {}; | ||
@@ -54,3 +53,3 @@ //----------------------------------------------------- | ||
if(t.length === 2) { | ||
cmdOptions.data[t.pop()] = v; | ||
cmdData[t.pop()] = v; | ||
} | ||
@@ -65,6 +64,13 @@ else { | ||
if(cmdOptions.data) { | ||
cmdOptions.data = JSON.parse(cmdOptions.data); | ||
} | ||
//----------------------------------------------------- | ||
const token = cmdOptions.token || envToken; | ||
const data = Array.isArray(cmdOptions.data) ? cmdOptions.data : Object.assign(cmdOptions.data || {}, cmdData); | ||
const { | ||
method, data, proxy | ||
method, proxy | ||
} = cmdOptions; | ||
@@ -74,2 +80,4 @@ | ||
console.log(cmdOptions); | ||
//----------------------------------------------------- | ||
@@ -76,0 +84,0 @@ |
@@ -12,2 +12,3 @@ //----------------------------------------------------- | ||
const download = require("./download"); | ||
const entities = require("./entities"); | ||
@@ -18,2 +19,3 @@ //----------------------------------------------------- | ||
client.download = download; | ||
client.entities = entities; | ||
@@ -20,0 +22,0 @@ //----------------------------------------------------- |
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
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
59163
17
1567
289
5