How to use sendText method in Playwright Internal

Best JavaScript code snippet using playwright-internal

test.js

Source:test.js Github

copy

Full Screen

...13 console.log("***新一轮--连接数***:”",server.connections.length)14 // console.log("当前消息",mssage)15 // console.log("在线节点信息",currentOnlineNode)16 if(mssage.msg=='beat'){17 conn.sendText('{"msg":"online"}')18 }else if(mssage.msg=='state'){19 // console.log(currentOnlineNode)20 21 for(let c in currentOnlineNode){22 if(mssage.token==currentOnlineNode[c]){23 conn.sendText('1')24 return25 }26 }27 conn.sendText('0')28 }29 else if(mssage.msg==='connlist'){//查看所有连接用户30 31 //过滤相同token的重复登录32 let flag=false33 for(let tk in currentOnlineNode){34 if(currentOnlineNode[tk]===mssage.msg){35 currentOnlineNode[conn.key]=mssage.msg36 37 flag=true38 break39 } 40 }41 42 if(!flag){43 currentOnlineNode[conn.key]=mssage.msg 44 } 45 46 // 获取链接token数组47 let ob={48 'list':[] 49 } 50 for(let c in currentOnlineNode){51 if(currentOnlineNode[c]=='connlist'){continue}52 53 ob.list.push({token:currentOnlineNode[c],ip:serviceNodesIp[c]})54 } 55 // console.log("all node:",ob)56 conn.sendText(JSON.stringify(ob))57 }else if(mssage.msg=='AvailablePcs'){//获取某个连接的所有可用处理服务58 59 // console.log("avalipcs++++",mssage,decodeURIComponent(mssage.token))60 if(decodeURIComponent(mssage.token)!=undefined){61 mssage.token=decodeURIComponent(mssage.token)62 63 }else{64 }65 66 // 请求节点67 if(mssage.req!=undefined){68 let off=false69 for(let con of server.connections){70 if(conn==con) continue71 72 if(mssage.token===currentOnlineNode[con.key]){73 74 let avilablePcs={75 msg:"AvbPcs",76 token:mssage.token,77 type:mssage.type78 }79 // console.log("AvailablePcs",mssage.token)80 con.sendText(JSON.stringify(avilablePcs))81 off=true82 break83 }84 }85 if(!off){86 conn.sendText("node offline")87 } 88 }else{89 // console.log("to sdk",currentOnlineNode)90 //接收91 let resData={92 res:'resData',93 AvailablePcs:mssage.pcs94 }95 for(let con of server.connections){96 // console.log(con.key,currentOnlineNode[con.key])97 if(conn==con) continue98 // 找到sdk连接99 if(currentOnlineNode[con.key]=='connlist'){100 // console.log('to sdk key:',con.key)101 con.sendText(JSON.stringify(resData))102 break 103 }104 }105 106 }107 108 }109 else if(mssage.msg==="regist"){//用户注册110 // console.log("regist",mssage)111 //绑定连接与对应的容器和门户112 let flag=false113 for(let tk in currentOnlineNode){114 if(currentOnlineNode[tk]===mssage.token){115 flag=true116 break117 } 118 }119 if(!flag){120 currentOnlineNode[conn.key]=mssage.token121 serviceNodesIp[conn.key]=mssage.nodeIp!=undefined?mssage.nodeIp:undefined122 123 } 124 // console.log(mssage.token)125 conn.sendText("success");//注册成功126 127 }else if(mssage.msg==="req"||mssage.msg==="reqPcs"||mssage.msg=="capability"||mssage.msg=="reqUrls"){//发出数据请求,来自门户128 //给我一个token,和一个数据id129 130 let off=true131 132 for(let con of server.connections){133 if(conn==con) continue134 if(con.readyState===3){135 // con.sendText(JSON.stringify(reqData))136 }137 if(mssage.token===currentOnlineNode[con.key]){138 // console.log(mssage.msg)139 off=false140 let reqData141 if(mssage.msg==="req"){142 reqData={143 'req':true,144 'id':mssage.id,145 'name':mssage.name!=undefined?mssage.name:undefined,146 'token':mssage.token,147 'reqUsrOid':mssage.reqUsrOid!=undefined?mssage.reqUsrOid:undefined148 }149 }if(mssage.msg==="reqUrls"){150 reqData={151 'reqUrls':true,152 'id':mssage.id,153 'token':mssage.token,154 155 }156 }else if(mssage.msg==="reqPcs"){157 reqData={158 'reqPcs':true,159 'pcsId':mssage.pcsId,160 'dataId':mssage.dataId,161 'name':mssage.name!=undefined?mssage.name:undefined,162 'token':mssage.token,163 'reqUsrOid':mssage.reqUsrOid!=undefined?mssage.reqUsrOid:undefined,164 'params':mssage.params!=undefined?mssage.params:undefined165 }166 }else if(mssage.msg=='capability'){167 reqData={168 'capability':true,169 'id':mssage.id,170 'type':mssage.type,171 172 'token':mssage.token,173 174 }175 }176 reqData['wsToken']=''+mssage.wsId 177 con.sendText(JSON.stringify(reqData))178 179 break180 }181 182 }183 if(off){184 //离线返回offline185 conn.sendText('node offline')186 }187 188 189 }else if(mssage.msg==="resdata"){//数据处理结果190 //console.log("trsponse data&connetction length",conn.key,server.connections.length)191 // console.log("response data:",mssage)192 193 for(let con of server.connections){194 195 if(conn==con) continue196 197 if(mssage.wsToken===currentOnlineNode[con.key]){198 // console.log('resdata:',mssage.msg)199 if(mssage.type!=undefined){//当无权限时的情况200 if(mssage.type==='noAuthority'){201 con.sendText("no authority")202 }else if(mssage.type==='db find err'){203 con.sendText("no data in service node!")204 } 205 206 }else{207 208 if(mssage.stoutErr!=undefined){209 //处理方法执行出现问题210 let info={211 'msg':'pcsErr',212 'id':mssage.id,213 'reqUsr':mssage.reqUsr!=undefined?mssage.reqUsr:undefined,214 'stoutErr':mssage.stoutErr215 }216 // console.log('pcserr',mssage)217 //返回给门户请求用户oid和数据下载id218 con.sendText(JSON.stringify(info))219 }else if(mssage.capability!=undefined){220 221 let info={222 'msg':'capability',223 }224 if(mssage.stout!=undefined){//失败时225 info['stout']=mssage.stout226 }else if(mssage.data!=undefined){227 info['data']=mssage.data228 }229 //返回给门户请求用户oid和数据下载id230 con.sendText(JSON.stringify(info))231 }232 else{233 //结点在收到请求后,会把对应数据上传至数据容器,并返回下载数据的id234 let info={235 'msg':'insitudata',236 'id':mssage.id!=undefined?mssage.id:undefined,237 'stout':mssage.stout!=undefined?mssage.stout:undefined,238 'reqUsr':mssage.reqUsr!=undefined?mssage.reqUsr:undefined239 }240 //返回给门户请求用户oid和数据下载id241 con.sendText(JSON.stringify(info))242 // console.log("insitu data",mssage.id,)243 }244 245 246 }247 248 }249 }250 }else if(mssage.msg=='Migration'){251 //服务迁移,找到目标token节点252 let off=true253 254 for(let con of server.connections){255 if(conn==con) continue256 257 if(mssage.targetToken===currentOnlineNode[con.key]){258 let info={259 msg:'MigRcv',260 from:mssage.fromToken,261 dataId:mssage.serviceDownloadId262 }263 // console.log('Service Migration from:',mssage.fromToken,'target:',mssage.targetToken)264 con.sendText(JSON.stringify(info))265 let reply={266 msg:'MigRcv',267 reply:mssage.targetToken268 }269 conn.sendText(JSON.stringify(reply))270 off=false271 break272 }273 }274 if(off){275 let re={276 msg:'MigRcv',277 off:'node offline'278 }279 conn.sendText('node offline')280 }281 }else if(mssage.msg=="invokDisPcs"){282 if(mssage.token&&decodeURIComponent(mssage.token)!=undefined){283 mssage.token=decodeURIComponent(mssage.token)284 285 }else{286 }287 // 用自己的数据,调用别处的处理服务288 if(mssage.req!=undefined&&mssage.req){289 290 let off=true291 //遍历服务连接,获取对应token的容器292 for(let con of server.connections){293 if(conn==con) continue294 295 if(mssage.token===currentOnlineNode[con.key]){296 let info={297 msg:'ivkDPcs',298 token:mssage.token,299 contDtId:mssage.contDtId,300 pcsId:mssage.pcsId,301 params:mssage.params!=undefined?mssage.params:undefined,302 303 }304 if(mssage.contDtId!=undefined){305 info['contDtId']=mssage.contDtId306 }else if(mssage.url!=undefined){307 info['url']=mssage.url308 }else if(mssage.urls!=undefined){309 info['urls']=mssage.urls310 }else if(mssage.ExternalUrls!=undefined){311 info['ExternalUrls']=mssage.ExternalUrls312 }else if(mssage.urlsWithKeys!=undefined){313 info['urlsWithKeys']=mssage.urlsWithKeys314 }315 // console.log('Invoke target pcs:',mssage.token,)316 con.sendText(JSON.stringify(info))317 318 off=false319 break320 }321 }322 if(off){ 323 conn.sendText('node offline')324 }325 }else{326 327 for(let con of server.connections){328 if(conn==con) continue329 330 if('connlist'==currentOnlineNode[con.key]){331 // 处理数据处理结果返回id,给相应请求节点332 let rspData={333 msg:'ivkDPcs',334 uid:mssage.uid,335 stout:mssage.stout336 }337 con.sendText(JSON.stringify(rspData));338 }339 } 340 }341 }342 343 });344 conn.on("close", function (code, reason) {345 let i=server.connections.indexOf(conn)346 server.connections.splice(1,i)347 delete currentOnlineNode[conn.key]348 delete serviceNodesIp[conn.key]349 console.log("关闭连接,当前连接数为:",server.connections.length)350 });351 conn.on("error", function (code, reason) {...

Full Screen

Full Screen

steps.js

Source:steps.js Github

copy

Full Screen

...31 await setStage(app, number, 4)32 let save = await newService(app, user.id_user);33 console.log(save)34 let dataMenu = await menuFormated(app)35 client.sendText(number,36 `Olá ${user.name}, estou iniciando um novo atendimento, e já vou anotar seus pedidos, segue o cardapio!\n${dataMenu}`);37 } catch (msg) {38 console.log(msg)39 }40 }41 if (stage == 201) {42 try {43 await setStage(app, number, 4)44 let save = await newService(app, user.id_user);45 console.log(save)46 let dataMenu = await menuFormated(app)47 client.sendText(number,48 `Olá ${user.name}, bem vindo de volta, estou abrindo um novo atendimento ok?!\nJá pode me enviar seu pedido, estou aqui para anotar!\n${dataMenu}`);49 } catch (msg) {50 console.log(msg)51 }52 }53 if (stage === 0) {54 try {55 client.sendText(number, `Olá ${message.sender.pushname === undefined ? '' : message.sender.pushname}, bem vindo! Para iniciarmos seu atendimento, por favor, me envie uma menssagem contendo somente seu nome completo.\n*Ex:* Maria Silva Borba`);56 await stageIncrement(app, number, stage)57 } catch (msg) {58 console.log(msg)59 }60 }61 if (stage === 1) {62 try {63 client.sendText(number, `Seu nome completo é:\n${message.body}\nEstá correto? Responda com *sim* ou *não*.`);64 await saveName(app, number, message.body)65 await saveAux(app, number, message.sender.pushname)66 } catch (msg) {67 console.log("erro:", msg)68 }69 }70 if (stage === 2) {71 try {72 if (verify(message.body, respTrue)) {73 try {74 await setStage(app, number, 4)75 let save = await newService(app, user.id_user);76 console.log(save)77 let dataMenu = await menuFormated(app)78 client.sendText(number,79 `Olá ${user.name}, seu nome foi salvo com sucesso! Estou iniciando um novo atendimento, e já vou anotar seus pedidos, segue o cardapio!\n${dataMenu}`);80 } catch (msg) {81 console.log(msg)82 }83 } else {84 await stageDecrement(app, number, stage)85 client.sendText(number, `Ok, envie a próxima menssagem contendo somente seu nome completo.\n86 *Ex:* Maria Silva Borba`);87 }88 } catch (msg) {89 console.log(msg)90 }91 }92 if (stage === 3) {93 await stageDecrement(app, number, stage)94 client.sendText(number, `Ok, envie a próxima menssagem contendo somente seu nome completo.\n95 *Ex:* Maria Silva Borba`);96 }97 if (stage === 4) {98 //busca pelo produto99 try {100 if (verify(message.body, respClose)) {101 await setStage(app, number, 6)102 client.sendText(number, `Ok, fechei seu pedido! Quando ficar pronto você quer?\n1 - Retirar na loja?\n2 - Receber em casa (Delivery)?`);103 } else {104 // let dataMenu = await menuFormated(app)105 //procura o pela srting106 let productData = await cardapio(app, message.body)107 console.log('pd:',productData)108 if (productData.sucess) {109 if (productData.item.additional) {110 await setStage(app, number, 50)111 }else{112 await setStage(app, number, 5)113 }114 await newProduct(app, user.id_service, productData.item.id_product)115 client.sendText(number, `Certo, você deseja pedir ${productData.item.description_menu}?\n\n1- Sim\n2-Não?`);116 console.log('productData', productData.item)117 } else {118 client.sendText(number, `Desculpe, não entedi, seja específico e peça um produto por vez!`);119 }120 }121 // await stageIncrement(app, number, stage)122 // client.sendText(number, menuFormated(app)); 123 } catch (msg) {124 console.log(msg)125 }126 }127 if (stage === 5) {128 //sim ou nao do produto129 let compareArray = [130 { code: 1, keywords: "sim" },131 { code: 2, keywords: "não" }132 ]133 let resp = await verifyString(message.body, compareArray)134 if (resp.sucess && resp.item.code === 1) {135 //casa136 await stageDecrement(app, number, stage)137 await activeProduct(app, user.id_service)138 let dataOrder = await orderFormated(app, user.id_service)139 client.sendText(number, `Produto anotado!\n\n${dataOrder}\nVocê pode continuar pedindo pelo nome ou código dos produtos, ou pode enviar:\n*finalizar*`);140 // }else if(verify(message.body, respFalse)){141 } else {142 //cancelar143 let dataMenu = await menuFormated(app)144 await stageDecrement(app, number, stage)145 client.sendText(number, `Cancelei esse item do seu pedido, mas me envie o produto que você deseja pedir!\n\n${dataMenu}\n`);146 }147 }148 //produto com adicional149 if(stage === 50){150 let compareArray = [151 { code: 1, keywords: "sim" },152 { code: 2, keywords: "não" }153 ]154 let resp = await verifyString(message.body, compareArray)155 if (resp.sucess && resp.item.code === 1) {156 157 await setStage(app, number, 51)158 await activeProduct(app, user.id_service)159 160 let additional = await menuAdditionalFormated(app, user.id_service)161 client.sendText(number, `Produto anotado! ${additional.name} possui os seguintes adicionais:\n${additional.msg}\nQual adicional deseja? Envie um por vez!`);162 // }else if(verify(message.body, respFalse)){163 } else {164 //cancelar165 let dataMenu = await menuFormated(app)166 await setStage(app, number, 4)167 client.sendText(number, `Cancelei esse item do seu pedido, mas me envie o produto que você deseja pedir!\n\n${dataMenu}\n`);168 }169 }170 if(stage === 51){171 let compareArray = [172 { code: 0, keywords: "nenhum" },173 { code: '#', keywords: "não" }174 ]175 let resp = await verifyString(message.body, compareArray)176 if (resp.sucess && (resp.item.code === 0 || resp.item.code === '#')) {177 await setStage(app, number, 4)178 let dataOrder = await orderFormated(app, user.id_service)179 client.sendText(number, `Ok, você pode continuar pedindo pelo nome ou código dos produtos, ou pode enviar:\n*finalizar*\n\n${dataOrder}\n`);180 // }else if(verify(message.body, respFalse)){181 } else {182 //cancelar183 let productData = await searchAdditional(app, message.body, user.id_service)184 if (productData.sucess) { 185 186 let aa = await newAdditional(app, user.id_service, productData.item.id_additional, productData.item.id_sp) 187 console.log(aa)188 189 client.sendText(number, `*${productData.item.name}* adicionado!\nMais algum adicional? Envie o adicional ou *não*.`);190 191 } else {192 client.sendText(number, `Desculpe, não entedi, seja específico e peça um adicional por vez!`);193 }194 195 }196 }197 198 if (stage === 6) {199 //retirar ou delivery200 let compareArray = [201 { code: 1, keywords: "buscar loja" },202 { code: 2, keywords: "casa delivery" }203 ]204 let resp = await verifyString(message.body, compareArray)205 206 console.log('resp', resp)207 if (resp.sucess && resp.item.code === 1) {208 209 //buscar na loja210 await setStage(app, number, 10)211 let value = await orderValueTotal(app, user.id_service)212 client.sendText(number, `Ok, então você pode retirar com a gente! Assim que estiver pronto te enviaremos uma mensagem e você pode retirar aqui.\nNosso Endereço: R: de André Lourenço N 160\nSeu pedido ficou em ${value.toLocaleString('pt-br',{style: 'currency', currency: 'BRL'})}, como você deseja pagar?\n1- No dinheiro\n2- No cartão?\n3- Com PIX?`); 213 } else if (resp.sucess && resp.item.code === 2) {214 await newProduct(app, user.id_service, 15, true)//taxa de entrega215 //delivery216 if (user.id_address) {217 //existe endereço218 await setStage(app, number, 7)219 client.sendText(number, `Receber em casa é melhor né? Vi que já tenho um endereço seu aqui. Você quer receber em:\n${user.address}?\n1 - Sim\n2- Outro endereço`);220 } else {221 //não tem endereço222 await setStage(app, number, 8)223 client.sendText(number, `Receber em casa é mais confortável né? Mas antes preciso do seu endereço, me envie na proxima mensagem seu endereço completo!\nExemplo: Rua 7 detembro, número 8, conceição da aparecida.`);224 }225 } else {226 client.sendText(number, `Não entendi, escolha uma opção! Quando ficar pronto você quer?\n1 - Buscar na loja?\n2 - Receber em casa (Delivery)?`);227 }228 }229 if (stage === 7) {230 //mesmo endereço ou novo231 let compareArray = [232 { code: 1, keywords: "sim" },233 { code: 2, keywords: "outro endereço" }234 ]235 let resp = await verifyString(message.body, compareArray)236 console.log('resp', resp)237 if (resp.sucess && resp.item.code === 1) {238 //sim endereço ja cadastrado239 await saveAddressService(app, user.id_service, user.id_address)240 await setStage(app, number, 10)241 let value = await orderValueTotal(app, user.id_service)242 console.log(value)243 client.sendText(number, `Ok, anotei seu endereço, seu pedido ficou em ${value.toLocaleString('pt-br',{style: 'currency', currency: 'BRL'})}, como você deseja pagar?\n1- No dinheiro\n2- No cartão?\n3- Com PIX?`);244 } else if (resp.sucess && resp.item.code === 2) {245 //endereço novo246 await setStage(app, number, 8)247 client.sendText(number, `Certo, agora me envie em uma unica frase o endereço completo.\nExemplo: Rua 7 setembro, número 8.`);248 } else {249 client.sendText(number, `Não entendi! Responda com uma opção, você quer receber em:\n${user.address}?\n1 - Sim\n2 - Outro endereço`);;250 }251 }252 if (stage === 8) {253 //confirma endereço endereço ou novo254 await newAddress(app, user.id_user, message.body)255 await setStage(app, number, 9)256 client.sendText(number, `Seu endereço completo é:\n${message.body}?\n1- Sim\n2- Não`);257 }258 if (stage === 9) {259 //mesmo endereço ou novo260 let compareArray = [261 { code: 1, keywords: "sim" },262 { code: 2, keywords: "não" }263 ]264 let resp = await verifyString(message.body, compareArray)265 if (resp.sucess && resp.item.code === 1) {266 //endereço ok267 268 await activeAddress(app, user.id_user)269 await saveAddressService(app, user.id_service, user.id_address)270 await setStage(app, number, 10)271 let value = await orderValueTotal(app, user.id_service)272 console.log(value)273 client.sendText(number, `Ok, anotei seu endereço, seu pedido ficou em ${value.toLocaleString('pt-br',{style: 'currency', currency: 'BRL'})}, como você deseja pagar?\n1- No dinheiro\n2- No cartão?\n3- Com PIX?`);274 } else if (resp.sucess && resp.item.code === 2) {275 //corrigir endereço276 await setStage(app, number, 8)277 client.sendText(number, `Certo, agora me envie em uma unica frase o endereço completo.\nExemplo:Exemplo: Rua 7 setembro, número 8.`);278 } else {279 await setStage(app, number, 8)280 client.sendText(number, `Não entendi! me envie em uma unica frase o endereço completo.\nExemplo:Exemplo: Rua 7 setembro, número 8.`);;281 }282 }283 if (stage === 10) {284 //pagamento285 let compareArray = [286 { code: 1, keywords: "dinheiro" },287 { code: 2, keywords: "cartão" },288 { code: 3, keywords: "pix" }289 ]290 let resp = await verifyString(message.body, compareArray)291 if (resp.sucess && resp.item.code === 1) {292 //din293 await setStage(app, number, 11)294 // await closeOrder(app, user.id_service)295 client.sendText(number, `Ok, você precisa de troco para quanto? Envie *não* ou o valor para o troco:`);296 } else if (resp.sucess && resp.item.code === 2) {297 //cart298 await setStage(app, number, 100)299 await paymentCredit(app, true, user.id_service)300 await closeOrder(app, user.id_service)301 client.sendText(number, `Ok, assim que estiver pronto enviaremos seu pedido, vamos te informar! Qualquer coisa pode me chamar!`)302 } else if (resp.sucess && resp.item.code === 3) {303 //pix304 await setStage(app, number, 100)305 await paymentPix(app, true, user.id_service)306 await closeOrder(app, user.id_service)307 client.sendText(number, `A nossa chave PIX é:\n35998772439\n\nEfetue o pagamente e nos envie o comprovante para preparamos seu pedido!!`)308 309 } else {310 client.sendText(number, `Não entendi! Como você deseja pagar?\n1 - No dinheiro\n2 - No cartão?\n3- Com PIX?`);;311 }312 }313 // ok314 if (stage === 11) {315 //troco316 let compareArray = [317 { code: 1, keywords: "não" },318 ]319 let resp = await verifyString(message.body, compareArray)320 if (resp.sucess && resp.item.code === 1) {321 await setStage(app, number, 100)322 await closeOrder(app, user.id_service)323 client.sendText(number, `Ok, assim que estiver pronto enviaremos seu pedido, vamos te informar quando estiver saindo daqui. Qualquer coisa pode me chamar!`); 324 }else{325 await setStage(app, number, 100)326 await closeOrder(app, user.id_service)327 await paymentChange(app, parseFloat(message.body), user.id_service)328 client.sendText(number, `Ok, assim que estiver pronto enviaremos seu pedido, vamos te informar quando estiver saindo daqui. Qualquer coisa pode me chamar!`);329 }330 }331 if (stage === 100) {332 //mesmo endereço ou novo333 await setStage(app, number, 101)334 let dataOrder = await orderFormated(app, user.id_service)335 let address = `\n🏘️ *Endereço:* ${user.address}`336 client.sendText(number, `Olá, seu pedido está sendo preparado e vamos te avisar assim que tivermos novidades.\n\n✅ Segue o resumo do seu pedido:\n\n${dataOrder}${ user.id_address_service ? address : ''}\n💲 *Pagamento:* ${user.payment_card ? "💳 Cartão de Cŕedito" : user.payment_pix ? "PIX" : "💵 Dinheiro"}\n🗒️ *Status do pedido:* ${ user.sending ? "🛵 Saiu para a entrega" : user.producing ? "👨‍🍳 Em produção" : user.recived ? "🍳 Recebido na cozinha" : "📦 Seu pedido será atendido em breve!" }`)337 }338 return 0339}340export async function log(app, number, message, client) {341 console.log('\n\napp:', app.db, '\n\nde: ', number, "\n\nmesg: ", message, "\n\nclient: ", client)...

Full Screen

Full Screen

notlistedcommands.js

Source:notlistedcommands.js Github

copy

Full Screen

...3function neverGonnaGiveUUp(client, from, cmd)4{5 if (('' + cmd).toLowerCase() == 'never gonna') {6 if (!songLine) {7 client.sendText(from, 'give you up');8 songLine++;9 } else if (songLine == 1) {10 client.sendText(from, 'let you down');11 songLine++;12 } else if (songLine == 2) {13 client.sendText(from, 'run around, and desert you');14 songLine++;15 } else if (songLine == 3) {16 client.sendText(from, 'make you cry');17 songLine++;18 } else if (songLine == 4) {19 client.sendText(from, 'say goodbye');20 songLine++;21 } else if (songLine == 5) {22 client.sendText(from, 'tell a lie, and hurt you');23 songLine++;24 } else {25 client.sendText(from, 'give you up');26 songLine = 1;27 }28 }29}30function notListed(client, from, cmd, pushname) {31 32 var newcmd = (('' + cmd).toLowerCase());33 if (newcmd === '#hello') {34 client.sendText(from, 'Hello there how can I help?')35 return36 } 37 else if (newcmd === 'test') {38 client.sendText(from, 'the bot is currently online and runing')39 return40 } 41 else if (newcmd === 'make me a coffee') {42 client.sendText(from, 'Make it yourself, lazy baka *hmph*')43 return44 } 45 else if (newcmd === '#i love you') {46 client.sendText(from, 'T-Thanks I-I mean *looks away blushing*')47 return48 } 49 else if (newcmd === '#do you love me?') {50 client.sendText(from, 'U-Uh... n-no! *blushes* O-Of course not, bakka!')51 return52 } 53 else if (newcmd === 'god') {54 client.sendText(from, '@Kanui|EncryptionSuccess is God')55 return56 } 57 else if (newcmd === 'and the silence remains') {58 client.sendText(from, 'As always')59 return60 } else if (newcmd === 'fuck') {61 client.sendText(from, 'Hmph! *crosses arms* Take that back!')62 return63 } else if (newcmd === 'mily x yagu') {64 client.sendText(from, 'Mily x Yagu Forever✨️')65 return66 } else if (newcmd === 'mou') {67 client.sendText(from, 'sonnan ja hora')68 return69 } else if (newcmd === 'kokoro') {70 client.sendText(from, 'wa shinka suru yo Motto motto')71 return72 } else if (newcmd === 'zelda') {73 client.sendText(from, 'Link')74 return75 } else if (newcmd === 'indeed') {76 client.sendText(from, 'Pathetic')77 return78 } else if (newcmd === 'link') {79 client.sendText(from, 'Zelda')80 return81 } else if (newcmd === '#best girl') {82 client.sendText(from, '*Blushes*')83 return84 } else if (newcmd === 'se no') {85 client.sendText(from, 'Demo sonnan ja dame')86 return87 } else if (newcmd === '#faq') {88 client.sendText(from, '👋️Hello '+`${pushname}`+'\n\nSupport Group; https:\/\/bit.ly\/2CaPFyk\nGithub: https:\/\/bit.ly\/39Ld2L8\n\nThese are some of the frequently asked questions\n\nQ: Why was this bot created?\nA: We the developers wanted to increase our knowledge in JavaScript at the same time giving bac to the community\n\nQ: Will the bot ban you if you use unlisted commands?\nA: No, we\'ll not ban you if you use unlisted commands because every person isn\'t perfect, a person will make a typo or two, so we do not punish you\n\nQ: Will the bot ban you if you call the bot?\nA: No, But the bot can\'t pickup the call. Humans make mistake. we are not gonna punish you for that. Our bot is able to ban as well as block people but we won\'t do that. \n\nQ: How to make a bot like \"Emilia\"?\nA: You need to know JavaScript and Node.js If you want to, you can use our code for creating your bot. It\'d be great if you credit us if you do so, it is not necessary though.\n\nQ: Does the bot go offline?\nA: Yes, The bot services will go down for 6 or so hours because our servers are limited. The bot will be able to run for 24\/7 soon.\n \nQ: How to use the bot?\nA: Send \"#help\" to see the usable commands.\n\nQ: Who are \"Link\" and \"Zelda\"?\nA: Link and Zelda are the main charterers from The Legend of Zelda Video Game series. \n\n✨️Hope you have fun using our bot! Have a great day\n\n')89 return90 } else if (newcmd === 'can you beat goku though') {91 client.sendText(from, '*I can and I will*')92 return93 } else if (newcmd === '#s-1') {94 client.sendText(from, 'Connection Status = Active')95 return96 } else if (newcmd === 'i love rem') {97 client.sendText(from, 'Who is Rem?')98 return99 } else if (newcmd === 'yo') {100 client.sendText(from, 'Hiya *High-fives*')101 return102 } else if (newcmd === '#tsundere') {103 client.sendText(from, 'I am not a tsudere, baka!')104 return105 } else if (newcmd === '#mystery video') {106 client.sendText(from, 'https://youtu.be/dQw4w9WgXcQ')107 return108 } else if (newcmd === 'sex' | 'nudes' | 'porn') {109 client.sendText(from, 'Go home, you are horny!')110 return111 } else if (newcmd === 'ora ora ora ora') {112 client.sendText(from, 'Muda Muda Muda Muda')113 return114 } else if (newcmd === 'muda muda muda muda') {115 client.sendText(from, 'Ora Ora Ora Ora')116 return117 } else if (newcmd === '#commands') {118 client.sendText(from, '👋️Hi *${pushname}*, I\'m Emilia!\n\n*Prefix = #* 💎\n\n*Usable Commands!*✨\n\n*_CMD: #sticker_*\n*Description: Converts images into stickers*\n\n*_CMD: #anime <anime name>_*\n*Description: Displays the information of the given anime*\n\n*_CMD: #flip_*\n*Description: Flips a coin fo you*\n\n*_CMD: #roll_*\n*Description: Rolls a dice*\n\n*_CMD: #neko_*\n*Description Returns a random cat image*\n\n*_CMD: #meme_*\n*Description: Displays and anime meme from r\/wholesomeanimememes*\n\n*_CMD: #sr <subreddit>_*\n*Description: Returns a post from the given subreddit*\n\n*_CMD: #waifu_*\n*Description: Returns a picture of a waifu*\n\n*_CMD: #covid <country name>_*\n*Description: Displays the live stats Covid-19 of the given country*\n\n*_CMD: #quotes_*\n*Description: Returns a quote that will either give you existential crises or wisdom*\n\n*_CMD #pokemon_*\n*Description: Displays picture of a random pokemon*\n\n*_CMD: #wallpaper [Beta]_*\n*Displays a random anime wallpapers*\n\n*_CMD: #Seasonal anime_* [Bugged]\n*Description: Returns a list of seasonal animes*\n\n*_CMD: #info_*\n*Description: Displays the information of the bot*\n\n*_CMD: #TnC_*\n*Description: Displays the Terms and Conditions*\n\nThere are many hidden and fun keywords ;)\n\nIf yore having any trouble with the bot, please join our support group and state your issue\n\n*Support: https://bit.ly/2CaPFyk*\n\nHope you have a great day!✨\n\n')119 return120 } else if (newcmd === '#Seasonal anime') {121 client.sendText(from, 'Summer 2020 \n Re:Zero kara Hajimeru Isekai Seikatsu 2nd Season \n Yahari Ore no Seishun Love Comedy wa Machigatteiru. Kan \n The God of High School \n Sword Art Online: Alicization - War of Underworld 2nd Season \n Enen no Shouboutai: Ni no Shou \n Maou Gakuin no Futekigousha: Shijou Saikyou no Maou no Shiso, Tensei shite Shison-tachi no Gakkou e \n Kanojo, Okarishimasu \n Deca-Dence \n Uzaki-chan wa Asobitai! \n Monster Musume no Oishasan')122 return123 } else if (newcmd === '#you are idiot') {124 client.sendText(from, 'Shut up, douchbag')125 return126 } else if (newcmd === 'never gonna') {127 client.sendText(from, neverGonnaGiveUUp(client, from, cmd))128 return129 } else if (newcmd === '#leave') {130 if(isGroupMsg){131 if (`${ContactId}` == '919744375687@c.us') {132 client.sendText(from,'Sayonara')133 client.leaveGroup(from)134 }135 }136 return137 } else if (newcmd === 'se no') {138 client.sendText(from, 'Demo sonnan ja dame')139 return140 } else if (newcmd === 'el psy congroo') {141 client.sendFileFromUrl(from, 'https://i.ibb.co/s9Rw8hN/index.jpg','Steins;Gate.jpg','El Psy Congroo')142 return143 } else if (newcmd === 'heave ho' | 'heave ho!') {144 client.sendFileFromUrl(from, 'https://i.ibb.co/KjJx5ps/Whats-App-Image-2020-08-01-at-16-36-10.jpg','Soran.jpg','*Soran Soran*');145 return146 } else if (newcmd === '#you are idiot') {147 client.sendText(from, 'Shut up, douchebag');148 return149 } else if (newcmd === '#you are baka') {150 client.sendText(from, "I'll smack on your gut so hard that you will cry for mommy!")151 return152 } else if (newcmd === '#you are bakka') {153 client.sendText(from, 'I believe hell will wipe itself when you will go there!')154 return155 } else if (newcmd === 'prepare for trouble') {156 client.sendText(from, 'And make it double!')157 return158 } else if (newcmd === 'to protect the world from devastation') {159 client.sendText(from, 'To unite all peoples within our nation!')160 return161 } else if (newcmd === 'to denounce the evils of truth and love') {162 client.sendText(from, 'to extend our reach to the stars above!')163 return164 } else if (newcmd === 'team Rocket blasts off at the speed of light') {165 client.sendText(from, 'Surrender now, or prepare to fight!')166 return167 } else if (newcmd === '#codesyaknow') {168 var culture_code;169 culture_code = Math.floor(Math.random() * 100001) + 10000;170 client.sendText(from, "Here you go b-ba-baka \n" + culture_code);171 return172 } else if (newcmd === '#sauceyaknow') {173 var culture_code;174 culture_code = Math.floor(Math.random() * 100001) + 10000;175 var sauce_Yaknow = "https://nhentai.net/g/" + culture_code;176 client.sendText(from, sauce_Yaknow);177 } else if (newcmd === '#botw') {178 client.sendFileFromUrl(from, 'https://mocah.org/uploads/posts/197514-princess-zelda-2350x1175.png','BOTW.jpg','...')179 } else if (newcmd === 'freedom') {180 client.sendFileFromUrl(from, 'https://i.ibb.co/6J9ST0d/IMG-20200731-WA0791.jpg','freedom.jpg','...')181 } else if (newcmd === '#rem') {182 q12 = Math.floor(Math.random() * 9) + 1183 client.sendFileFromUrl(from, 'http://0.0.0.0:8082/Rem/'+q12+'.png', 'Rem.png','Rem ✨️')184 }185}186module.exports = {187 188 notListed189 190}

Full Screen

Full Screen

connect.js

Source:connect.js Github

copy

Full Screen

1const app = getApp()2Page({3 /**4 * 页面的初始数据5 */6 data: {7 receiverText: '',8 receiverLength: 0,9 sendText: '',10 sendLength: 0,11 time: 1000,12 timeSend: false,13 num: 014 },15 /**16 * 自定义数据17 */18 customData: {19 sendText: '',20 deviceId: '',21 serviceId: '',22 characteristicId: '',23 canWrite: false,24 canRead: false,25 canNotify: false,26 canIndicate: false,27 time: 028 },29 /**30 * 生命周期函数--监听页面加载31 */32 onLoad: function (options) {33 const self = this34 this.customData.deviceId = options.deviceId35 this.customData.serviceId = options.serviceId36 this.customData.characteristicId = options.characteristicId37 this.customData.canWrite = options.write === 'true' ? true : false38 this.customData.canRead = options.read === 'true' ? true : false39 this.customData.canNotify = options.notify === 'true' ? true : false40 this.customData.canIndicate = options.indicate === 'true' ? true : false41 /**42 * 如果支持notify43 */44 if (options.notify) {45 wx.notifyBLECharacteristicValueChange({46 deviceId: options.deviceId,47 serviceId: options.serviceId,48 characteristicId: options.characteristicId,49 state: true,50 success: function (res) {51 // do something...52 }53 })54 }55 },56 /**57 * 生命周期函数--监听页面初次渲染完成58 */59 onReady: function () {60 const self = this;61 function buf2string(buffer) {62 var arr = Array.prototype.map.call(new Uint8Array(buffer), x => x)63 return arr.map((char, i) => {64 return String.fromCharCode(char);65 }).join('');66 }67 /**68 * 监听蓝牙设备的特征值变化69 */70 wx.onBLECharacteristicValueChange(function (res) {71 const receiverText = buf2string(res.value);72 const num = receiverText.charCodeAt()73 console.log("接收到的数据:" + receiverText)74 self.setData({75 receiverLength: self.data.receiverLength + receiverText.length76 })77 //var num = receiverText.charCodeAt()78 console.log("数字是:" + num)79 setTimeout(() => {80 self.setData({81 receiverText: (self.data.receiverText + receiverText).substr(-4000, 4000),82 numberText: num83 })84 }, 200)85 })86 },87 /**88 * 生命周期函数--监听页面卸载89 */90 onUnload: function () {91 this.setData({92 receiverText: '',93 receiverLength: 0,94 sendText: '',95 sendLength: 0,96 time: 1000,97 timeSend: false98 })99 },100 /**101 * 更新发送框内容102 */103 updateSendText: function (event) {104 const value = event.detail.value105 this.customData.sendText = value106 this.setData({107 sendText: value108 })109 },110 /**111 * 更新定时发送时间间隔112 */113 updateTime: function (event) {114 const self = this115 const value = event.detail.value116 this.setData({117 time: /^[1-9]+.?[0-9]*$/.test(value) ? +value : 1000118 })119 clearInterval(this.customData.time)120 const deviceId = this.customData.deviceId // 设备ID121 const serviceId = this.customData.serviceId // 服务ID122 const characteristicId = this.customData.characteristicId // 特征值ID123 this.customData.time = setInterval(() => {124 const sendText = self.customData.sendText125 const sendPackage = app.subPackage(sendText) // 数据分每20个字节一个数据包数组126 if (app.globalData.connectState) {127 if (self.customData.canWrite) { // 可写128 self.writeData({ deviceId, serviceId, characteristicId, sendPackage })129 }130 }131 }, self.data.time)132 },133 /**134 * 清除接收135 */136 clearReceiverText: function (event) {137 // this.customData.receiverText = ''138 this.setData({139 receiverText: '',140 receiverLength: 0141 })142 },143 /**144 * 清除发送145 */146 clearSendText: function (event) {147 this.customData.sendText = ''148 this.setData({149 sendText: '',150 sendLength: 0151 })152 },153 /**154 * 手动发送155 */156 manualSend: function (event) {157 const deviceId = this.customData.deviceId // 设备ID158 const serviceId = this.customData.serviceId // 服务ID159 const characteristicId = this.customData.characteristicId // 特征值ID160 const sendText = this.customData.sendText161 const sendPackage = app.subPackage(sendText) // 数据分每20个字节一个数据包数组162 if (app.globalData.connectState) {163 if (this.customData.canWrite) { // 可写164 this.writeData({ deviceId, serviceId, characteristicId, sendPackage })165 }166 } else {167 wx.showToast({168 title: '已断开连接',169 icon: 'none'170 })171 }172 },173 /**174 * 自动发送175 */176 timeChange(event) {177 this.setData({178 timeSend: event.detail.value.length ? true : false179 })180 if (!this.data.timeSend) {181 clearInterval(this.customData.time)182 } else {183 const self = this184 const deviceId = this.customData.deviceId // 设备ID185 const serviceId = this.customData.serviceId // 服务ID186 const characteristicId = this.customData.characteristicId // 特征值ID187 this.customData.time = setInterval(() => {188 const sendText = self.customData.sendText189 const sendPackage = app.subPackage(sendText) // 数据分每20个字节一个数据包数组190 if (app.globalData.connectState) {191 if (self.customData.canWrite) { // 可写192 self.writeData({ deviceId, serviceId, characteristicId, sendPackage })193 }194 }195 }, self.data.time)196 }197 },198 /**199 * 向特征值写数据(write)200 */201 writeData: function ({ deviceId, serviceId, characteristicId, sendPackage, index = 0 }) {202 const self = this203 let i = index;204 let len = sendPackage.length;205 if (len && len > i) {206 wx.writeBLECharacteristicValue({207 deviceId,208 serviceId,209 characteristicId,210 value: app.string2buf(sendPackage[i]),211 success: function (res) {212 self.setData({213 sendLength: self.data.sendLength + sendPackage[i].length // 更新已发送字节数214 })215 i += 1;216 self.writeData({ deviceId, serviceId, characteristicId, sendPackage, index: i }) // 发送成功,发送下一个数据包217 },218 fail: function (res) {219 self.writeData({ deviceId, serviceId, characteristicId, sendPackage, index }) // 发送失败,重新发送220 }221 })222 }223 },224 //跳转至显示详情页面225 //const deviceName = this.customData.deviceName226 togo: function (e) {227 var that = this228 console.log("ASCII值----------------------------->>>>>>>>>>>>>>>>" + this.data.receiverText)229 var receiveText = this.data.receiverText230 var num = receiveText.charCodeAt()231 console.log("------------------------------------receiveText:" + this.data.receiverText)232 console.log("------------------------------------num:" + this.data.num)233 wx.navigateTo({234 url: '../details/details?receiveText='+receiveText + '&num=' + num,235 })236 }...

Full Screen

Full Screen

messageHandler.js

Source:messageHandler.js Github

copy

Full Screen

...49 case '#sticker':50 case '#stiker':51 try {52 if (isMedia && type === 'image') {53 client.sendText(from, msg.wait);54 const mediaData = await decryptMedia(message);55 const imageBase64 = `data:${mimetype};base64,${mediaData.toString('base64')}`;56 client.sendImageAsSticker(from, imageBase64);57 client.sendText(from, msg.done);58 }59 if (quotedMsg && quotedMsg.type === 'image') {60 client.sendText(from, msg.wait);61 const mediaData = await decryptMedia(quotedMsg);62 const imageBase64 = `data:${quotedMsg.mimetype};base64,${mediaData.toString('base64')}`;63 client.sendImageAsSticker(from, imageBase64);64 client.sendText(from, msg.done);65 }66 } catch (error) {67 client.sendText(from, msg.errFailed);68 console.log(error.message);69 }70 break;71 case '#menu':72 client.sendText(from, menu);73 break;74 case '#korona':75 try {76 client.sendText(from, msg.wait);77 client.sendText(from, await korona());78 client.sendText(from, msg.done);79 } catch (error) {80 client.sendText(from, msg.errFailed);81 console.log(error.message);82 }83 break;84 case '#quotes':85 try {86 client.sendText(from, msg.wait);87 client.sendText(from, quotes());88 client.sendText(from, msg.done);89 } catch (error) {90 client.sendText(from, msg.errFailed);91 console.log(error.message);92 }93 break;94 case '#wp':95 client.sendText(from, msg.wait);96 wallpaper97 .then((result) => {98 client.sendFileFromUrl(from, result);99 client.sendText(from, msg.done);100 })101 .catch((error) => {102 client.sendText(from, msg.errFailed);103 console.log(error.message);104 });105 break;106 case '#zodiak':107 client.sendText(from, msg.wait);108 getZodiak(args1, args2)109 .then((result) => {110 client.sendText(from, result);111 client.sendText(from, msg.wait);112 })113 .catch((error) => {114 client.sendText(from, msg.errFailed);115 console.log(error.message);116 });117 break;118 case '#ramalan':119 client.sendText(from, msg.wait);120 ramalanCinta(args1, args2, args3, args4)121 .then((result) => {122 client.sendText(from, result);123 client.sendText(from, msg.done);124 })125 .catch((error) => {126 client.sendText(from, msg.errFailed);127 console.log(error.message);128 });129 break;130 case '#shrtlink':131 if (args.length !== 1) return await client.reply(from, 'Kirim perintah *!shrtlink https://google.com*', id)132 const slink = await get.get('https://api.haipbis.xyz/bitly?url='+ args[1]).json()133 if (slink.error) return await client.reply(from, slink.error, id)134 await client.reply(from, `ShortLink : ${slink.result}`, id)135 break;136 default:137 if (!isGroupMsg) {138 const thanks = ['terimakasi', 'makasi', 'thx', 'thank', 'trim', 'oke'];139 const isThanks = !!new RegExp(thanks.join('|')).test(commandArgs.toLowerCase());140 if (type === 'image' && !caption) {141 client.sendText(from, msg.errImgNoCaption);142 } else if (isThanks) {143 client.sendText(from, msg.replyThanks);144 } else if (from === process.env.ADMIN_CONTACT && command === '#savendelete') {145 const allChats = await client.getAllChats();146 client.sendText(from, `total chat di hp => ${allChats.length}`);147 let saved = 0;148 let skiped = 0;149 let failed = 0;150 for await (const element of allChats) {151 const isExists = await Chats.exists({ 'data.id': element.id });152 if (!isExists) {153 const newChats = new Chats({ data: element });154 newChats.save((err) => {155 if (err) {156 failed++;157 client.sendText(from, err);158 console.log(err);159 } else {160 // delete chat161 saved++;162 debug(`${element.id} BERHASIL di simpan ke db`);163 client.deleteChat(element.id);164 }165 });166 } else {167 // delete chat168 skiped++;169 debug(`${element.id} SUDAH ADA di db`);170 client.deleteChat(element.id);171 }172 }173 client.sendText(from, `berhasil => ${saved}\ngagal => ${failed}\nskip duplikat => ${skiped}`);174 } else {175 client.sendText(from, msg.errUnkCommand);176 }177 break;178 }179 }...

Full Screen

Full Screen

history.js

Source:history.js Github

copy

Full Screen

1const { WebSocketObserver } = require("../../../model/WebSocketModel");2const permssion = require("../../../helper/Permission");3const serverModel = require("../../../model/ServerModel");4const response = require("../../../helper/Response");5const HISTORY_SIZE_LINE = 1024;6// 正序历史记录路由7WebSocketObserver().listener("server/console/history", (data) => {8 let userName = data.WsSession.username;9 let bodyJson = JSON.parse(data.body);10 let serverName = bodyJson["serverName"] || "";11 if (permssion.isCanServer(userName, serverName)) {12 const server = serverModel.ServerManager().getServer(serverName);13 if (!server) throw new Error("查询某服务器日志历史时,此服务器并不存在。");14 const logHistory = server.logHistory;15 if (!logHistory) {16 response.wsSend(data.ws, "server/console/history", "terminalBack", "[控制面板]: 暂无任何历史记录.\r\n");17 return;18 }19 logHistory.readLine(userName, HISTORY_SIZE_LINE, (sendText) => {20 if (sendText) {21 sendText = sendText.replace(/\n/gim, "\r\n");22 sendText = sendText.replace(/\r\r\n/gim, "\r\n");23 response.wsSend(data.ws, "server/console/history", "terminalBack", sendText);24 } else {25 response.wsSend(data.ws, "server/console/history", "terminalBack", "[控制面板]: 无法再读取更多的服务端日志.\r\n");26 }27 });28 }29});30// 首次进入终端使用,倒序历史记录路由31WebSocketObserver().listener("server/console/history_reverse", (data) => {32 let userName = data.WsSession.username;33 let bodyJson = JSON.parse(data.body);34 let serverName = bodyJson["serverName"] || "";35 if (permssion.isCanServer(userName, serverName)) {36 const server = serverModel.ServerManager().getServer(serverName);37 if (!server) throw new Error("查询某服务器日志历史时,此服务器并不存在。");38 const logHistory = server.logHistory;39 if (!logHistory) return;40 logHistory.readLineOnce(userName, HISTORY_SIZE_LINE * 3, (sendText) => {41 if (sendText) {42 sendText = sendText.replace(/\n/gim, "\r\n");43 sendText = sendText.replace(/\r\r\n/gim, "\r\n");44 response.wsSend(data.ws, "server/console/history", "terminalBack", sendText);45 }46 });47 }48});49// 历史指针重置路由50WebSocketObserver().listener("server/console/history_reset", (data) => {51 let userName = data.WsSession.username;52 let bodyJson = JSON.parse(data.body);53 let serverName = bodyJson["serverName"] || "";54 if (permssion.isCanServer(userName, serverName)) {55 const server = serverModel.ServerManager().getServer(serverName);56 if (!server) throw new Error("查询某服务器日志历史时,此服务器并不存在。");57 const logHistory = server.logHistory;58 if (!logHistory) return;59 logHistory.setPoint(userName, 0);60 }...

Full Screen

Full Screen

watsonConversation.js

Source:watsonConversation.js Github

copy

Full Screen

1function sendText(sendContext){2 var context;//Retrieve the context from the previous server response3 var latestResponse = Api.getResponsePayload();4 if (latestResponse)5 context = latestResponse.context;6 Api.sendRequest(sendContext, context);//Send the user message7}8function pricePlan(pricePlan){9 switch(pricePlan){10 case "automaticTransfer":11 sendText('轉帳');12 break;13 case "atm":14 sendText('自動櫃員機');15 break;16 case "internetBanking":17 sendText('網上銀行');18 break;19 case "telephoneFinance":20 sendText('電話理財');21 break;22 case "mailCheckbook":23 sendText('郵寄支票');24 break;25 case "counter":26 sendText('櫃檯繳費');27 break;28 case "checkbook":29 sendText('支票通');30 break;31 default:32 break;33 }34}35function priceElectric(selected){36 switch(selected){37 case "electricity":38 if(selectedLanguage == "UK English Female")39 sendText('Electricity');40 else if(selectedLanguage == "Portuguese Female")41 sendText('Eletricidade');42 else43 sendText('電量');44 break;45 case "bill":46 sendText('帳單');47 break;48 case "account":49 sendText('帳戶');50 break;51 case "payForPrice":52 sendText('付費方式');53 break;54 case "calculation":55 sendText('計費方式');56 break;57 default:58 break;59 }60}61function calculatePricePlan(selected){62 switch(selected){63 case "a1":64 sendText('一般收費');65 break;66 case "a2":67 sendText('平民收費');68 break;69 case "a3":70 sendText('社會慈善機構收費');71 break;72 case "a4":73 sendText('社會援助收費');74 break;75 default:76 break;77 }78}79function selectedLocation1(){80 var selectedLocation = document.getElementById('selectLocation1').value;81 switch(selectedLocation){82 case '大堂區':83 sendText('大堂區');84 break;85 case '望德堂區':86 sendText('望德堂區');87 break;88 case '風順堂區':89 sendText('風順堂區');90 break;91 case '花地瑪堂區':92 sendText('花地瑪堂區');93 break;94 case '聖安多尼堂區':95 sendText('聖安多尼堂區');96 break;97 case '嘉模堂區':98 sendText('嘉模堂區');99 break;100 case '聖方濟各堂區':101 sendText('聖方濟各堂區');102 break;103 }104}105function aboutGov(selectedAbountGov){106 sendText(selectedAbountGov.value);107}108function accumuationAboutGovMoney(selectedAccumuationAboutGovMoney){109 sendText(selectedAccumuationAboutGovMoney.value);110}111function checkLocation(){112 var checkLocation = document.getElementById('selectLocation1');...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...11venom.create().then((client) => start(client));12function start(client) {13 for(i=0;i<mynumber.length;i++){14 if (day==='Monday'){15 client.sendText(mynumber[i],'Jadwal Kuliah Hari Ini');16 client.sendText(mynumber[i],'Fisika Dasar II\n08:00-09:30\nR.303');17 client.sendText(mynumber[i],'Kalkulus II\n09:45-11:15\nR.303');18 } else if (day==='Tuesday'){19 client.sendText(mynumber[i],'Jadwal Kuliah Hari Ini');20 client.sendText(mynumber[i],'Fisika Dasar II\n08:00-09:30\nR.303');21 client.sendText(mynumber[i],'Kalkulus II\n09:45-11:15\nR.303');22 } else if (day==='Wednesday'){23 client.sendText(mynumber[i],'Jadwal Kuliah Hari Ini');24 client.sendText(mynumber[i],'Islamologi\n08:00-09:30\nR.303');25 client.sendText(mynumber[i],'Pengantar Basis Data\n09:45-11:15\nR.303');26 client.sendText(mynumber[i],'Bahasa Indonesia\n09:45-11:15\nR.303');27 } else if (day==='Saturday'){28 client.sendText(mynumber[i],'Jadwal Kuliah Hari Ini');29 client.sendText(mynumber[i],'Fisika Dasar II\n08:00-09:30\nR.303');30 client.sendText(mynumber[i],'Kalkulus II\n09:45-11:15\nR.303');31 }32}33 client.onMessage((message) => {34 if (message.body === 'Hi') {35 var delayInMilliseconds = 10000;36 setTimeout(client.startTyping(message.from),client.sendText(message.client), delayInMilliseconds, client.sendText(message.from, 'Welcome Venom 🕷'));37 }else if (message.from === mynumber[0]){38 client.sendText(mynumber[0],message.body) || client.forwardMessages(mynumber[0], [message.id.toString()], true);;39 }40 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { sendText } = require('playwright/lib/server/supplements/recorder/recorderSupplement');3(async () => {4 const browser = await chromium.launch({ headless: false });5 const context = await browser.newContext();6 const page = await context.newPage();7 await sendText(page, 'hello');8 await browser.close();9})();10const { chromium } = require('playwright');11const { sendText } = require('playwright/lib/server/supplements/recorder/recorderSupplement');12(async () => {13 const browser = await chromium.launch({ headless: false });14 const context = await browser.newContext();15 const page = await context.newPage();16 await sendText(page, 'hello');17 await browser.close();18})();19const { chromium } = require('playwright');20const { sendText } = require('playwright/lib/server/supplements/recorder/recorderSupplement');21(async () => {22 const browser = await chromium.launch({ headless: false });23 const context = await browser.newContext();24 const page = await context.newPage();25 await sendText(page, 'hello');26 await browser.close();27})();28const { chromium } = require('playwright');29const { sendText } = require('playwright/lib/server/supplements/recorder/recorderSupplement');30(async () => {31 const browser = await chromium.launch({ headless: false });32 const context = await browser.newContext();33 const page = await context.newPage();34 await sendText(page, 'hello');35 await browser.close();36})();37const { chromium } = require('playwright');38const { sendText } = require('playwright/lib/server/supplements/recorder/recorderSupplement');39(async () => {40 const browser = await chromium.launch({ headless: false });

Full Screen

Using AI Code Generation

copy

Full Screen

1const { sendText } = require('playwright/lib/server/browserType');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await sendText(page, 'Hello World');8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { sendText } = require('@playwright/test/lib/server/stdio');2const { sendText } = require('@playwright/test/lib/server/stdio');3const { sendText } = require('@playwright/test/lib/server/stdio');4const { sendText } = require('@playwright/test/lib/server/stdio');5const { sendText } = require('@playwright/test/lib/server/stdio');6const { sendText } = require('@playwright/test/lib/server/stdio');7const { sendText } = require('@playwright/test/lib/server/stdio');8const { sendText } = require('@playwright/test/lib/server/stdio');9const { sendText } = require('@playwright/test/lib/server/stdio');10const { sendText } = require('@playwright/test/lib/server/stdio');11const { sendText } = require('@playwright/test/lib/server/stdio');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { sendText } = require('playwright/lib/internal/keyboard');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await sendText(page, 'Hello World!');6 await page.screenshot({ path: 'google.png' });7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright')2const context = await playwright.chromium.launchPersistentContext('userDataDir', {3})4const page = await context.newPage()5await page.sendText('Hello World')6{7 "background": {8 },9 {10 }11}12chrome.contextMenus.create({13})14chrome.contextMenus.onClicked.addListener(function(info, tab) {15 if (info.menuItemId === 'myExtensionContextMenuId') {16 chrome.tabs.sendMessage(tab.id, { action: 'myExtensionContextMenuClicked' })17 }18})19chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {20 if (request.action === 'myExtensionContextMenuClicked') {21 sendResponse({22 text: window.getSelection().toString()23 })24 }25})26const playwright = require('playwright')27const context = await playwright.chromium.launchPersistentContext('userDataDir', {28})29const page = await context.newPage()30await page.sendText('Hello World')31{32 "background": {33 },

Full Screen

Using AI Code Generation

copy

Full Screen

1const { sendText } = require('playwright/lib/server/supplements/recorder/recorderApp');2sendText('Hello World');3 at CDPSession.send (C:\Users\Karthik\Desktop\playwright\playwright\lib\server\cdp.js:123:23)4 at CDPSession.send (C:\Users\Karthik\Desktop\playwright\playwright\lib\server\cdp.js:123:23)5 at CDPSession.send (C:\Users\Karthik\Desktop\playwright\playwright\lib\server\cdp.js:123:23)6 at CDPSession.send (C:\Users\Karthik\Desktop\playwright\playwright\lib\server\cdp.js:123:23)7 at CDPSession.send (C:\Users\Karthik\Desktop\playwright\playwright\lib\server\cdp.js:123:23)8 at CDPSession.send (C:\Users\Karthik\Desktop\playwright\playwright\lib\server\cdp.js:123:23)9 at CDPSession.send (C:\Users\Karthik\Desktop\playwright\playwright\lib\server\cdp.js:123:23)10 at CDPSession.send (C:\Users\Karthik\Desktop\playwright\playwright\lib\server\cdp.js:123:23)11 at CDPSession.send (C:\Users\Karthik\Desktop\playwright\playwright\lib\server\cdp.js:123:23)12 at CDPSession.send (C:\Users\Karthik\Desktop\playwright\playwright\lib\server\cdp.js:123:23)

Full Screen

Using AI Code Generation

copy

Full Screen

1import { chromium, firefox, webkit } from 'playwright';2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 await page._delegate.sendText('hello');7 await page._delegate.sendText('');8 await page._delegate.sendText('hello');9 await page._delegate.sendText('');10 await browser.close();11})();

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful