Explorar o código

- README.md updated with build section

Parad0x %!s(int64=6) %!d(string=hai) anos
pai
achega
c9a92388fc
Modificáronse 3 ficheiros con 22 adicións e 5 borrados
  1. 13 0
      README.md
  2. 6 2
      src/bot/app.ts
  3. 3 3
      src/bot/auth.ts

+ 13 - 0
README.md

@@ -2,6 +2,19 @@
 
 
 Simple communication bridge between clients and telegram. Using sockets is simple way for other clients to send notification. Current version support only one way communication (from client to telegram) but it should be possible to implement registering command. Protocol is based on queue where elements are separated with semicolons. 
 Simple communication bridge between clients and telegram. Using sockets is simple way for other clients to send notification. Current version support only one way communication (from client to telegram) but it should be possible to implement registering command. Protocol is based on queue where elements are separated with semicolons. 
 
 
+## Build
+
+```
+npm install
+npm run build
+```
+
+## Start
+
+```
+npm start
+```
+
 ## Protocol Operations
 ## Protocol Operations
 
 
 ### register (name)
 ### register (name)

+ 6 - 2
src/bot/app.ts

@@ -67,7 +67,7 @@ function app() {
         throw new Error(`There is no app with id equeal ${id}`);
         throw new Error(`There is no app with id equeal ${id}`);
       }
       }
       await app.update({
       await app.update({
-        activated: true
+        isActivated: true
       })
       })
       ctx.editMessageText(`[${app.name}] Activated`, await getPAppsKeyboard());
       ctx.editMessageText(`[${app.name}] Activated`, await getPAppsKeyboard());
     } catch (e) {
     } catch (e) {
@@ -115,6 +115,10 @@ function app() {
         throw new Error("There is no state attribute");
         throw new Error("There is no state attribute");
       }
       }
       const args: string = await ctx.state.command.args;
       const args: string = await ctx.state.command.args;
+      if (args.length <= 0) {
+        ctx.reply("You need to spiecifie name");
+        return;
+      }
       if (args.length > 25) {
       if (args.length > 25) {
         ctx.reply("Name to long!");
         ctx.reply("Name to long!");
         return;
         return;
@@ -122,7 +126,7 @@ function app() {
       const appName = args;
       const appName = args;
       const instance = await db.App.create({
       const instance = await db.App.create({
         name: appName,
         name: appName,
-        activated: true
+        isActivated: true
       });
       });
       ctx.reply(`App registered\n` +
       ctx.reply(`App registered\n` +
         `Name: ${instance.name}\n` +
         `Name: ${instance.name}\n` +

+ 3 - 3
src/bot/auth.ts

@@ -65,14 +65,14 @@ function auth(): void {
       if (args === actualAuthCode) {
       if (args === actualAuthCode) {
         if (ctx.user) {
         if (ctx.user) {
           await ctx.user.update({
           await ctx.user.update({
-            activated: true
+            isAuthenticated: true
           });
           });
         } else {
         } else {
           let user = await db.User.findOrCreate({
           let user = await db.User.findOrCreate({
             where: {
             where: {
               userTelegramId: ctx.from.id
               userTelegramId: ctx.from.id
             }, defaults: {
             }, defaults: {
-              activated: true
+              isAuthenticated: true
             }
             }
           });
           });
         }
         }
@@ -81,7 +81,7 @@ function auth(): void {
       } else {
       } else {
         let user = await db.User.create({
         let user = await db.User.create({
           userTelegramId: ctx.from.id,
           userTelegramId: ctx.from.id,
-          activated: false
+          isAuthenticated: false
         });
         });
         ctx.reply("Wrong authentication code. Will be banned for 24H")
         ctx.reply("Wrong authentication code. Will be banned for 24H")
       }
       }