瀏覽代碼

- README.md updated with build section

Parad0x 5 年之前
父節點
當前提交
c9a92388fc
共有 3 個文件被更改,包括 22 次插入5 次删除
  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. 
 
+## Build
+
+```
+npm install
+npm run build
+```
+
+## Start
+
+```
+npm start
+```
+
 ## Protocol Operations
 
 ### 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}`);
       }
       await app.update({
-        activated: true
+        isActivated: true
       })
       ctx.editMessageText(`[${app.name}] Activated`, await getPAppsKeyboard());
     } catch (e) {
@@ -115,6 +115,10 @@ function app() {
         throw new Error("There is no state attribute");
       }
       const args: string = await ctx.state.command.args;
+      if (args.length <= 0) {
+        ctx.reply("You need to spiecifie name");
+        return;
+      }
       if (args.length > 25) {
         ctx.reply("Name to long!");
         return;
@@ -122,7 +126,7 @@ function app() {
       const appName = args;
       const instance = await db.App.create({
         name: appName,
-        activated: true
+        isActivated: true
       });
       ctx.reply(`App registered\n` +
         `Name: ${instance.name}\n` +

+ 3 - 3
src/bot/auth.ts

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