How to use the wechaty.log.error function in wechaty

To help you get started, we’ve selected a few wechaty examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github huan / botbuilder-wechaty-adapter / src / wechaty-adapter.ts View on Github external
// console.log('Bot Id: ', this.wechaty.userSelf().id)
          // console.log(activity)

          if (!recipientId) {
            throw new Error('no recipient id')
          }
          if (!text) {
            throw new Error('no text')
          }

          const user = this.wechaty.Contact.load(recipientId)
          await user.say(text)
          // console.log((activity.text != null) ? activity.text : '')
          break
        default:
          log.error(`The [${activity.type}] is not supported by the Wechaty Adapter(yet).`)
          break
      }
    }
    return responses
  }
github kaiyuanshe / oss-bot / src / handlers / on-message.ts View on Github external
log.info('on-message', 'Begin to find the OSS Bot ChatOps room')
    const room = this.Room.load(CHATOPS_ROOM_ID)

    if (room) {
      await room.add(contact)

      // To Be Fix: Change a formal welcome message
      await room.say('Welcome to join OSS Bot ChatOps Group', contact)
    }
  }
  log.info('on-message', 'onMessage(%s)', message)

  try {
    await VoteManager.checkVote(message)
  } catch (e) {
    log.error('on-message', 'Failed to check vote for the message:\n', e)
  }

  await dingDong.call(this, message)
  await ctpStatus(this, message)
}
github wechaty / wechaty-getting-started / examples / advanced / self-testing-bot.js View on Github external
.catch(async e => {
  log.error('Bot', 'start() fail: %s', e)
  await bot.stop()
  process.exit(-1)
})
github wechaty / wechaty-getting-started / examples / professional / ctrl-c-signal-bot.ts View on Github external
.catch(async e => {
  log.error('Bot', 'start() fail: %s', e)
  await bot.stop()
  process.exit(-1)
})
github wechaty / wechaty-getting-started / examples / professional / ctrl-c-signal-bot.ts View on Github external
bot.on('error', async e => {
  log.error('Bot', 'error: %s', e)
  if (bot.logonoff()) {
    await bot.say('Wechaty error: ' + e.message).catch(console.error)
  }
})
github wechaty / wechaty-getting-started / examples / advanced / room-bot.js View on Github external
/**
           * room not found
           */
          log.info('Bot', 'onMessage: dingRoom not found, try to create one')
          /**
           * create the ding room
           */
          const newRoom = await createDingRoom(from)
          console.log('createDingRoom id:', newRoom.id)
          /**
           * listen events from ding room
           */
          await manageDingRoom()
        }
      } catch (e) {
        log.error(e)
      }
    }
  }
})
.start()
github wechaty / wechaty-getting-started / examples / advanced / room-bot.js View on Github external
async function getOutRoom(contact, room) {
  log.info('Bot', 'getOutRoom("%s", "%s")', contact, room)

  try {
    await room.say('You said "ding" in my room, I will remove you out.')
    await room.del(contact)
  } catch (e) {
    log.error('Bot', 'getOutRoom() exception: ' + e.stack)
  }
}
github wechaty / wechaty-getting-started / examples / advanced / room-bot.js View on Github external
.on('room-topic', async function(room, topic, oldTopic, changer) {
  try {
    log.info('Bot', 'EVENT: room-topic - Room "%s" change topic from "%s" to "%s" by member "%s"',
                    room,
                    oldTopic,
                    topic,
                    changer,
                )
    await room.say(`room-topic - change topic from "${oldTopic}" to "${topic}" by member "${changer.name()}"` )
  } catch (e) {
    log.error('Bot', 'room-topic event exception: %s', e.stack)
  }
})