new(whatsapp.gblib): Auto-create WhatsApp templates from articles in .docx.
This commit is contained in:
		
							parent
							
								
									fe8b797454
								
							
						
					
					
						commit
						51cfa56f85
					
				
					 2 changed files with 10 additions and 8 deletions
				
			
		| 
						 | 
					@ -126,7 +126,12 @@ export class WhatsappDirectLine extends GBService {
 | 
				
			||||||
        req.headers['Authorization'] = `Bearer ${this.min.instance.webchatKey}`;
 | 
					        req.headers['Authorization'] = `Bearer ${this.min.instance.webchatKey}`;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    this.directLineClient = client;
 | 
					    this.directLineClient = client;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    // Warms up MSBF.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    await client.apis.Conversations.Conversations_StartConversation();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let url: string;
 | 
					    let url: string;
 | 
				
			||||||
    let options: any;
 | 
					    let options: any;
 | 
				
			||||||
| 
						 | 
					@ -617,7 +622,7 @@ export class WhatsappDirectLine extends GBService {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public pollMessages(client, conversationId, from, fromName) {
 | 
					  public pollMessages(client, conversationId, from, fromName) {
 | 
				
			||||||
    GBLogEx.info(this.min, `GBWhatsapp: Starting message polling(${from}, ${conversationId}).`);
 | 
					    GBLogEx.info(this.min, `GBWhatsapp: Starting timer of message polling(${from}, ${conversationId}).`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let watermark: any;
 | 
					    let watermark: any;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -630,7 +635,7 @@ export class WhatsappDirectLine extends GBService {
 | 
				
			||||||
        watermark = response.obj.watermark;
 | 
					        watermark = response.obj.watermark;
 | 
				
			||||||
        await this.printMessages(response.obj.activities, conversationId, from, fromName);
 | 
					        await this.printMessages(response.obj.activities, conversationId, from, fromName);
 | 
				
			||||||
      } catch (error) {
 | 
					      } catch (error) {
 | 
				
			||||||
        GBLog.error(`Error calling printMessages on Whatsapp channel ${GBUtil.toYAML(error)}`);
 | 
					        GBLog.error(`Error pooling messages from Whatsapp channel ${GBUtil.toYAML(error)}`);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    setInterval(worker, this.pollInterval);
 | 
					    setInterval(worker, this.pollInterval);
 | 
				
			||||||
| 
						 | 
					@ -1199,7 +1204,7 @@ export class WhatsappDirectLine extends GBService {
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          let t;
 | 
					          let t;
 | 
				
			||||||
          activeMin = GBServer.globals.minInstances.filter(p => p.instance.instanceId === user.instanceId)[0];
 | 
					          activeMin = GBServer.globals.minInstances.filter(p => p.instance.instanceId === user.instanceId)[0];
 | 
				
			||||||
          if (activeMin === undefined) {
 | 
					          if (activeMin === undefined) {      
 | 
				
			||||||
            activeMin = GBServer.globals.minBoot;
 | 
					            activeMin = GBServer.globals.minBoot;
 | 
				
			||||||
            t = (activeMin as any).whatsAppDirectLine;
 | 
					            t = (activeMin as any).whatsAppDirectLine;
 | 
				
			||||||
            await t.sendToDevice(
 | 
					            await t.sendToDevice(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -117,7 +117,7 @@ export class GBServer {
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    process.on('uncaughtException', (err, p) => {
 | 
					    process.on('uncaughtException', (err, p) => {
 | 
				
			||||||
      GBLogEx.error(0, `GBEXCEPTION: ${GBUtil.toYAML(err)}`);
 | 
					      GBLogEx.error(0, `GBEXCEPTION: ${GBUtil.toYAML(err)} ${GBUtil.toYAML(p)}`);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    process.on('unhandledRejection', (err, p) => {
 | 
					    process.on('unhandledRejection', (err, p) => {
 | 
				
			||||||
| 
						 | 
					@ -131,15 +131,12 @@ export class GBServer {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if(!bypass){
 | 
					      if(!bypass){
 | 
				
			||||||
        GBLogEx.error(0,`GBREJECTION: ${GBUtil.toYAML(err)}`);
 | 
					        GBLogEx.error(0,`GBREJECTION: ${GBUtil.toYAML(err)} ${GBUtil.toYAML(p)}`);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Creates working directory.
 | 
					    // Creates working directory.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    process.env.PWD = process.cwd();
 | 
					    process.env.PWD = process.cwd();
 | 
				
			||||||
    const workDir = Path.join(process.env.PWD, 'work');
 | 
					    const workDir = Path.join(process.env.PWD, 'work');
 | 
				
			||||||
    if (!fs.existsSync(workDir)) {
 | 
					    if (!fs.existsSync(workDir)) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue