create qr-codes by tg bot
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { TelegramWebhookDesignDocument, TgUpdateDocument } from "../types";
|
||||
export type { TelegramWebhookDesignDocument };
|
||||
type CouchRequest = {
|
||||
body: string;
|
||||
headers: Record<string, string>;
|
||||
method: string;
|
||||
query: Record<string, string>;
|
||||
userCtx: {
|
||||
name: string | null;
|
||||
roles: string[];
|
||||
};
|
||||
};
|
||||
type CouchResponse = [
|
||||
TgUpdateDocument | null,
|
||||
{
|
||||
code: number;
|
||||
body: string;
|
||||
} | string
|
||||
];
|
||||
type UpdateFunction = (doc: TgUpdateDocument | null, req: CouchRequest) => CouchResponse;
|
||||
export declare const saveUpdate: UpdateFunction;
|
||||
export declare const saveUpdateString: string;
|
||||
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.saveUpdateString = exports.saveUpdate = void 0;
|
||||
var saveUpdate = function (doc, req) {
|
||||
var token = req.headers["X-Telegram-Bot-Api-Secret-Token"];
|
||||
if (token !== this.constants.telegram_secret_token) {
|
||||
return [null, { code: 403, body: "Forbidden: Invalid token" }];
|
||||
}
|
||||
var data = JSON.parse(req.body);
|
||||
if (doc) {
|
||||
return [null, { code: 304, body: "Update already exists" }];
|
||||
}
|
||||
doc = {
|
||||
_id: "tg_update:" + data.update_id.toString(),
|
||||
type: "tg_update",
|
||||
data: data,
|
||||
created_at: new Date().toISOString(),
|
||||
};
|
||||
return [doc, "Message saved"];
|
||||
};
|
||||
exports.saveUpdate = saveUpdate;
|
||||
exports.saveUpdateString = exports.saveUpdate.toString();
|
||||
//# sourceMappingURL=saveUpdate.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"saveUpdate.js","sourceRoot":"","sources":["../../src/updates/saveUpdate.ts"],"names":[],"mappings":";;;AAyBO,IAAM,UAAU,GAAmB,UAExC,GAA4B,EAC5B,GAAiB;IAEjB,IAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;IAC7D,IAAI,KAAK,KAAK,IAAI,CAAC,SAAS,CAAC,qBAAqB,EAAE,CAAC;QACnD,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAElC,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,GAAG,GAAG;QACJ,GAAG,EAAE,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;QAC7C,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,IAAI;QACV,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACrC,CAAC;IAEF,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;AAChC,CAAC,CAAC;AAxBW,QAAA,UAAU,cAwBrB;AAEW,QAAA,gBAAgB,GAAG,kBAAU,CAAC,QAAQ,EAAE,CAAC"}
|
||||
Reference in New Issue
Block a user