wuyi 2 лет назад
Родитель
Сommit
e4ee79cefa
2 измененных файлов с 10 добавлено и 6 удалено
  1. 3 0
      src/chat-role/entities/chat-role.entity.ts
  2. 7 6
      src/moments/moments.service.ts

+ 3 - 0
src/chat-role/entities/chat-role.entity.ts

@@ -14,6 +14,9 @@ export class ChatRole {
     @Column()
     describe: string
 
+    @Column()
+    condition: string
+
     @Column()
     pic: String
 

+ 7 - 6
src/moments/moments.service.ts

@@ -38,7 +38,7 @@ export class MomentsService {
     ) {
         setInterval(() => {
             this.automaticallySendMoments();
-        }, 60 * 60 * 1000);
+        }, 24 * 60 * 60 * 1000);
     }
 
     async findAll(req: PageRequest<Moments>, userId: number): Promise<Pagination<Moments>> {
@@ -105,13 +105,14 @@ export class MomentsService {
     }
 
     public async automaticallySendMoments() {
-        const message = "请你发一条此时此刻的动态"
-        const maskList = await this.maskRepository.createQueryBuilder().getMany()
-        maskList.forEach(async mask => {
-            const text = await this.chatService.sendMessage(mask.describe, message)
+        const message = "请你以类似于朋友圈的放肆发一条此时此刻的动态"
+        const chatRoleList = await this.chatRoleRepository.createQueryBuilder().getMany()
+
+        chatRoleList.forEach(async role => {
+            const text = await this.chatService.sendMessage(role.condition, message)
             const momentsDto = new MomentsDto
             momentsDto.content = text
-            momentsDto.userId = mask.id
+            momentsDto.userId = role.id
             await this.momentsRepository.save(momentsDto)
         })