Git Product home page Git Product logo

qiji-bot's People

Contributors

huan avatar lijiarui avatar rickyyin98 avatar windmemory avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

qiji-bot's Issues

Can not send picture via FileBox

QijiBot/src/coupling/sendpic.ts

import { getWechaty } from '../get-wechaty'
import { FileBox }  from 'file-box'

export async function sendpic (
  url: string,
  toId: string,
) {
  const name = process.env.WECHATY_NAME || 'heroku-wechaty'
  const bot = getWechaty(name)
  const contact = bot.Contact.load(toId)
  await contact.sync()
  const fileBox = FileBox.fromUrl(url)
  await contact.say(fileBox)
}

QijiBot/src/start-web.ts

import { sendpic } from './coupling/sendpic'
async function sendpicHandler (request: Request, response: ResponseToolkit) {
  log.info('startWeb', 'sendpicHandler()')

  const payload: {
    url: string,
    toId: string,
  } = request.payload as any

  await sendpic(payload.url, payload.toId)

  return response.redirect('/')
}
  const SendpicHtml = (mes: Message, saying: string, abb: string, color:string) => {
    const from = mes.from()
    // <label for="sendmes">${saying}</label>
    return `
      <form action="/sendpic/" method="post" style="display:inline">
        <input id="${mes.id}" type="hidden" name="url" value="${saying}" >
        <input id="${mes.id}" type="hidden" name="toId" value="${(from && from.id) || ''}">
        <input type="submit" value="${abb}" title="${saying}" style="width:10%;height:40px;background-color: #${color};border-radius:5px;color:#575169;margin:0 0.5% 0.5% 0">
      </form>
    `
  }
const FourThree = SendpicHtml(mes, 'https://phaedodata-1253507825.cos.ap-beijing.myqcloud.com/YCCooperate/%E6%88%91%E6%83%B3%E6%8A%95%E8%B5%84%E5%B0%8F%E6%B5%85.png', '发图片png', 'f9f5ea')
  server.route({
    handler: sendpicHandler,
    method : 'POST',
    path   : '/sendpic/',
  })

The function can be run, but the picture can not be sent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.