Socket
Socket
Sign inDemoInstall

nestgram

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestgram - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

dist/classes/Keyboard/KeyboardStore.d.ts

1

dist/classes/index.d.ts

@@ -7,1 +7,2 @@ export * from './Context/Answer';

export * from './Api';
export * from './Mongo/NestSchema';

@@ -23,2 +23,3 @@ "use strict";

__exportStar(require("./Api"), exports);
__exportStar(require("./Mongo/NestSchema"), exports);
//# sourceMappingURL=index.js.map

4

dist/classes/Keyboard/Keyboard.d.ts
import { KeyboardTypes, IButton } from '../..';
export declare class Keyboard {
export declare class Keyboard<T = any> {
readonly keyboardType: KeyboardTypes;

@@ -18,2 +18,4 @@ readonly placeholder?: string;

row(btnsPerLine?: number | null, hidden?: boolean): Keyboard;
save(layoutName: string): this;
use(layoutName: string): this;
}

@@ -5,2 +5,3 @@ "use strict";

const __1 = require("../..");
const KeyboardStore_1 = require("./KeyboardStore");
const logger_1 = require("../../logger");

@@ -94,4 +95,24 @@ class Keyboard {

}
save(layoutName) {
this.row();
KeyboardStore_1.keyboardStore.layouts.push({ name: layoutName, rows: this.rows, type: this.keyboardType });
return this;
}
use(layoutName) {
const layout = KeyboardStore_1.keyboardStore.layouts.find((layout) => layout.name === layoutName);
if (!layout) {
(0, logger_1.warn)(`Can't find layout with name`, layoutName.grey);
return this;
}
else if (layout.type !== this.keyboardType) {
(0, logger_1.warn)(`Can't use layout with name`, layoutName.grey, `because it has a different keyboard type`);
return this;
}
layout.rows.forEach((row) => {
this.unresolvedButtons.push(...row);
});
return this;
}
}
exports.Keyboard = Keyboard;
//# sourceMappingURL=Keyboard.js.map

@@ -18,3 +18,3 @@ "use strict";

if (this.logging)
(0, logger_1.log)('blue', 'Calling next middleware', `(${update.update_id})`.grey);
(0, logger_1.info)('Calling next middleware', `(${update.update_id})`.grey);
return (nextFunction || handler)(update, answer, params, this.getNextFunction(update, answer, params, middlewares, middlewareIndex, handlerIndex, handler, failFunction.bind(null, middlewareIndex, handlerIndex)), failFunction.bind(null, middlewareIndex, handlerIndex));

@@ -31,3 +31,3 @@ };

if (this.logging)
(0, logger_1.log)('blue', 'Calling handler for update', `(${update.update_id})`.grey);
(0, logger_1.info)('Calling handler for update', `(${update.update_id})`.grey);
const message = Filter_1.Filter.getMessage(update);

@@ -73,3 +73,3 @@ const commandParams = Filter_1.Filter.getCommandParams(update);

if (this.logging)
(0, logger_1.log)('blue', 'Middleware called fail function', `(${update.update_id})`.grey);
(0, logger_1.info)('Middleware called fail function', `(${update.update_id})`.grey);
if (handler.middlewares[middlewareIndex]) {

@@ -81,3 +81,3 @@ return this.handleMiddleware(handlerIndex, update, answer, middlewareIndex);

if (this.logging)
(0, logger_1.log)('blue', 'Calling first middleware/handler', `(${update.update_id})`.grey);
(0, logger_1.info)('Calling first middleware/handler', `(${update.update_id})`.grey);
handler.middlewares[middlewareIndex](update, answer, params, this.getNextFunction(update, answer, params, handler.middlewares, middlewareIndex, index, baseNextFunction, failNextFunction) || baseNextFunction, failNextFunction.bind(null, middlewareIndex + 1, index));

@@ -91,3 +91,3 @@ const isContinue = Reflect.getMetadata('continue', handler.controller[handler.methodKey]);

if (this.logging)
(0, logger_1.log)('blue', 'Got new update!', `(${update.update_id})`.grey);
(0, logger_1.info)('Got new update!', `(${update.update_id})`.grey);
const answer = new Answer_1.Answer(this.token, update);

@@ -94,0 +94,0 @@ const handler = this.handlers[0];

@@ -9,2 +9,4 @@ import 'reflect-metadata';

export * from './updates/continue.decorator';
export * from './properties/api.decorator';
export * from './mongo/schema.decorator';
export * from './mongo/prop.decorator';
export * from './api/api.decorator';

@@ -25,3 +25,5 @@ "use strict";

__exportStar(require("./updates/continue.decorator"), exports);
__exportStar(require("./properties/api.decorator"), exports);
__exportStar(require("./mongo/schema.decorator"), exports);
__exportStar(require("./mongo/prop.decorator"), exports);
__exportStar(require("./api/api.decorator"), exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { IModule } from '../../types';
export declare function Module(options?: IModule): Function;
import { ModuleClass } from '../../types';
export declare function Module(options?: ModuleClass): Function;

@@ -14,2 +14,4 @@ "use strict";

Reflect.defineMetadata('imports', options.imports, target);
if (options.modules)
Reflect.defineMetadata('modules', options.modules, target);
return target;

@@ -16,0 +18,0 @@ };

import 'colors';
export declare function log(typeColor: string, ...texts: string[]): void;
export declare function log(typeColor: string, ...contents: any[]): void;
export declare function info(...contents: any[]): void;
export declare function warn(...contents: any[]): void;
export declare function success(...contents: any[]): void;
export declare function error(...texts: string[]): Error;
export declare function clear(): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.clear = exports.error = exports.log = void 0;
exports.clear = exports.error = exports.success = exports.warn = exports.info = exports.log = void 0;
require("colors");
function log(typeColor, ...texts) {
console.log('[NestGram]'[typeColor], ...texts);
function log(typeColor, ...contents) {
console.log('[NestGram]'[typeColor], ...contents);
}
exports.log = log;
function info(...contents) {
log('blue', ...contents);
}
exports.info = info;
function warn(...contents) {
log('yellow', ...contents);
}
exports.warn = warn;
function success(...contents) {
log('green', ...contents);
}
exports.success = success;
function error(...texts) {

@@ -10,0 +22,0 @@ return new Error('[NestGram]'.bgRed + ' ' + texts.map((text) => text.red).join(' '));

@@ -18,3 +18,3 @@ "use strict";

if (runConfig.logging)
(0, logger_1.log)('blue', 'Bot initialized');
(0, logger_1.info)('Bot initialized');
if (!runConfig.port)

@@ -29,6 +29,30 @@ runConfig.port = 80;

}
setupImports(Module) {
async setupImports(Module) {
const controllers = Reflect.getMetadata('controllers', Module);
const modules = Reflect.getMetadata('modules', Module) || [];
const compiledModules = [];
for (const module of modules) {
let result;
let err;
try {
result = await module();
}
catch (e) {
result = module();
err = e;
console.log(1, err);
}
if (result) {
try {
compiledModules.push(...result);
}
catch (e) {
throw new Error(err);
}
}
}
let services = Reflect.getMetadata('services', Module);
services = services.map((Service) => new Service());
services = services.map((Service) => {
return new Service(...compiledModules);
});
controllers.forEach((Controller) => {

@@ -50,3 +74,3 @@ const controller = new Controller(...services);

if (needApi)
controller.api = this.api;
controller['api'] = this.api;
});

@@ -63,7 +87,7 @@ }

if (this.runConfig.logging)
(0, logger_1.log)('blue', 'Entry module configured');
(0, logger_1.info)('Entry module configured');
}
async start() {
if (this.runConfig.logging)
(0, logger_1.log)('blue', 'Starting bot...');
(0, logger_1.info)('Starting bot...');
if (!this.token)

@@ -82,3 +106,3 @@ throw (0, logger_1.error)(`You can't run bot without token`);

}
(0, logger_1.log)('green', 'Bot started on', `@${this.info.username}`.gray);
(0, logger_1.success)('Bot started on', `@${this.info.username}`.gray);
return this.info.username;

@@ -85,0 +109,0 @@ }

import { MiddlewareFunction } from './middleware.types';
export declare type DecoratorMethod = (target: any, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
export interface IModule {
middlewares?: MiddlewareFunction[];
controllers?: ControllerClass[];
services?: ServiceClass[];
imports?: any[];
}
export declare type ModuleFunction = () => Promise<any[] | void> | any[] | void;
export declare class ControllerClass {

@@ -13,7 +8,10 @@ constructor(...services: ServiceClass[]);

export declare class ServiceClass {
constructor(...args: any[]);
}
export declare class ModuleClass implements IModule {
export declare class ModuleClass {
middlewares?: MiddlewareFunction[];
controllers?: ControllerClass[];
modules?: ModuleFunction[];
services?: ServiceClass[];
imports?: IModule[];
imports?: any[];
}

@@ -0,1 +1,2 @@

import { KeyboardTypes } from '../enums';
export interface IWebAppButton {

@@ -14,1 +15,6 @@ url?: string;

}
export interface IKeyboardLayout {
name: string;
rows: IButton[][];
type: KeyboardTypes;
}
{
"name": "nestgram",
"description": "Framework for working with Telegram Bot API on TypeScript like Nest.js",
"version": "1.2.2",
"version": "1.3.0",
"main": "dist/index.js",

@@ -44,4 +44,5 @@ "types": "dist/index.d.ts",

"form-data": "^4.0.0",
"mongoose": "^6.3.5",
"reflect-metadata": "^0.1.13"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc