-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.server.js
1 lines (1 loc) · 3.28 KB
/
test.server.js
1
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=11)}([function(e,t,r){const n=r(1),o=n(),a=(r(2),r(3),r(4),r(5)),c=r(6),s=(r(7),r(8),r(9),r(10));const i=e=>{try{return e=(e=(e=(e=(e=(e=(e=(e=(e=e.text["*"]).replace(/\n/g,"").replace(/\r/g,"")).replace(/<table(.*?)<\/table>/g,"")).replace(/\n/g,"").replace(/\r/g,"")).replace(/<p class="mw-empty(.*?)<\/p>/g,"")).match(/<p>(.+?)<\/p>/)[0]).replace(/<sup id="cite_ref(.*?)<\/sup>/g,"")).replace(/<[^>]+>/g," ")).replace(/#(.*?);/g,"")}catch(e){a.speak("Sorry, but that information could not be found.")}};e.exports=class{constructor(...e){e.length&&(this.commands=e[0].concat([{commands:["who is"],onMatch:(e,t)=>{c.page.data(t.replace("who is a ","").replace("who is ","").replace("who are ","").replace("whos ","").replace(/ /g,"_"),{content:!0},e=>{a.speak(i(e))})}},{commands:["what is"],onMatch:(e,t)=>{c.page.data(t.replace("what is a ","").replace("what is ","").replace("what are ","").replace("whats ","").replace(/ /g,"_"),{content:!0},e=>{a.speak(i(e))})}},{commands:["calculator"],onMatch:(e,t)=>{a.speak("equals "+s.toWords(t))}}]),this.options=Object.assign({url:"/",base:"/",port:"8025"},e[1]?e[1]:{}),this.commands.length&&this.init())}init(){o.use(n.json()),o.get(this.options.url,(e,t,r)=>{t.header("Access-Control-Allow-Origin","*"),t.header("Access-Control-Allow-Headers","Origin, X-Requested-With, Content-Type, Accept");let n=t.req.query.task,o=t.req.query.data;if("say"===n)return void a.speak(o,null,null,()=>{t.send(),r()});let c=!1,s=[],i=[];Object.keys(this.commands).map(e=>{s=this.commands[e],i=s.commands,!0!==c&&(Object.keys(i).map(e=>{!0!==c&&-1!==n.indexOf(i[e])&&("function"==typeof s.onMatch&&(a.stop(),s.onMatch(t.req.query.task,t.req.query.data)),c=!0)}),!1===c&&t.send())})}),o.listen(this.options.port,()=>{console.log("Alex server now running at localhost:8025.")})}}},function(e,t){e.exports=require("express")},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("opn")},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("say")},function(e,t){e.exports=require("node-wikipedia")},function(e,t){e.exports=require("recursive-readdir")},function(e,t){e.exports=require("child_process")},function(e,t){e.exports=require("find-in-files")},function(e,t){e.exports=require("number-to-words")},function(e,t,r){new(r(0))([{commands:["alex"],onMatch:()=>{}},{commands:["hello world"],onMatch:()=>{}},{commands:["feedback test"],onMatch:()=>{}}],{url:"/",post:"8025",base:"/"})}]);