Files
admin 875c7f9b91 feat: Complete zCode CLI X with Telegram bot integration
- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
2026-05-05 09:01:26 +00:00

64 lines
1.5 KiB
JavaScript

const Utils = require('./utils')
function clearCanvas (ctx, canvas, size) {
ctx.clearRect(0, 0, canvas.width, canvas.height)
if (!canvas.style) canvas.style = {}
canvas.height = size
canvas.width = size
canvas.style.height = size + 'px'
canvas.style.width = size + 'px'
}
function getCanvasElement () {
try {
return document.createElement('canvas')
} catch (e) {
throw new Error('You need to specify a canvas element')
}
}
exports.render = function render (qrData, canvas, options) {
let opts = options
let canvasEl = canvas
if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
opts = canvas
canvas = undefined
}
if (!canvas) {
canvasEl = getCanvasElement()
}
opts = Utils.getOptions(opts)
const size = Utils.getImageWidth(qrData.modules.size, opts)
const ctx = canvasEl.getContext('2d')
const image = ctx.createImageData(size, size)
Utils.qrToImageData(image.data, qrData, opts)
clearCanvas(ctx, canvasEl, size)
ctx.putImageData(image, 0, 0)
return canvasEl
}
exports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {
let opts = options
if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
opts = canvas
canvas = undefined
}
if (!opts) opts = {}
const canvasEl = exports.render(qrData, canvas, opts)
const type = opts.type || 'image/png'
const rendererOpts = opts.rendererOpts || {}
return canvasEl.toDataURL(type, rendererOpts.quality)
}