Browse Source

0.1.3 bot, gen action inside lib

push-params
Evan Feenstra 4 years ago
parent
commit
64db4b7fd2
  1. 28
      api/bots/mother.ts
  2. 25
      dist/api/bots/mother.js
  3. 2
      dist/api/bots/mother.js.map
  4. 6
      package-lock.json
  5. 2
      package.json

28
api/bots/mother.ts

@ -1,11 +1,11 @@
import * as Sphinx from 'sphinx-bot'
import {Action, finalAction} from '../controllers/actions'
import {finalAction} from '../controllers/actions'
const msg_types = Sphinx.MSG_TYPE
export function init() {
const client = new Sphinx.Client()
client.login('_', embedToAction)
client.login('_', finalAction)
client.on(msg_types.MESSAGE, async (message:Sphinx.Message) => {
console.log("INCOMING MSG",message)
@ -21,27 +21,3 @@ export function init() {
message.channel.send({ embed })
})
}
function embedToAction(a){
let text = ''
let botName = 'Bot'
if(a.embed && a.embed.html) {
text = a.embed.html
botName = a.embed.author
} else if(typeof a==='string') {
text = a
}
finalAction(<Action>{
botName,
text, action:'broadcast',
})
}
// const helpHTML=`<div>
// <b>Bot commands:</b>
// <ul>
// <li><b>/bot install {BOTNAME}:</b>&nbsp;Install a new bot
// <li><b>/bot help:</b>&nbsp;Print out this help message
// </ul>
// <div>
// `

25
dist/api/bots/mother.js

@ -14,7 +14,7 @@ const actions_1 = require("../controllers/actions");
const msg_types = Sphinx.MSG_TYPE;
function init() {
const client = new Sphinx.Client();
client.login('_', embedToAction);
client.login('_', actions_1.finalAction);
client.on(msg_types.MESSAGE, (message) => __awaiter(this, void 0, void 0, function* () {
console.log("INCOMING MSG", message);
const embed = new Sphinx.MessageEmbed()
@ -28,27 +28,4 @@ function init() {
}));
}
exports.init = init;
function embedToAction(a) {
let text = '';
let botName = 'Bot';
if (a.embed && a.embed.html) {
text = a.embed.html;
botName = a.embed.author;
}
else if (typeof a === 'string') {
text = a;
}
actions_1.finalAction({
botName,
text, action: 'broadcast',
});
}
// const helpHTML=`<div>
// <b>Bot commands:</b>
// <ul>
// <li><b>/bot install {BOTNAME}:</b>&nbsp;Install a new bot
// <li><b>/bot help:</b>&nbsp;Print out this help message
// </ul>
// <div>
// `
//# sourceMappingURL=mother.js.map

2
dist/api/bots/mother.js.map

@ -1 +1 @@
{"version":3,"file":"mother.js","sourceRoot":"","sources":["../../../api/bots/mother.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,qCAAoC;AACpC,oDAA0D;AAC1D,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAA;AAEjC,SAAgB,IAAI;IAElB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,CAAA;IAClC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;IAEhC,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,CAAO,OAAsB,EAAE,EAAE;QAC5D,OAAO,CAAC,GAAG,CAAC,cAAc,EAAC,OAAO,CAAC,CAAA;QAEnC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,YAAY,EAAE;aACpC,SAAS,CAAC,WAAW,CAAC;aACtB,QAAQ,CAAC,eAAe,CAAC;aACzB,SAAS,CAAC;YACT,EAAC,IAAI,EAAC,mBAAmB,EAAC,KAAK,EAAC,wBAAwB,EAAC;YACzD,EAAC,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,WAAW,EAAC;SAChC,CAAC,CAAA;QAEJ,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IACjC,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC;AAlBD,oBAkBC;AAED,SAAS,aAAa,CAAC,CAAC;IACtB,IAAI,IAAI,GAAG,EAAE,CAAA;IACb,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE;QAC1B,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAA;QACnB,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAA;KACzB;SAAM,IAAG,OAAO,CAAC,KAAG,QAAQ,EAAE;QAC7B,IAAI,GAAG,CAAC,CAAA;KACT;IACD,qBAAW,CAAS;QAClB,OAAO;QACP,IAAI,EAAE,MAAM,EAAC,WAAW;KACzB,CAAC,CAAA;AACJ,CAAC;AAED,wBAAwB;AACxB,yBAAyB;AACzB,SAAS;AACT,gEAAgE;AAChE,6DAA6D;AAC7D,UAAU;AACV,gBAAgB;AAChB,IAAI"}
{"version":3,"file":"mother.js","sourceRoot":"","sources":["../../../api/bots/mother.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,qCAAoC;AACpC,oDAAkD;AAClD,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAA;AAEjC,SAAgB,IAAI;IAElB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,CAAA;IAClC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,qBAAW,CAAC,CAAA;IAE9B,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,CAAO,OAAsB,EAAE,EAAE;QAC5D,OAAO,CAAC,GAAG,CAAC,cAAc,EAAC,OAAO,CAAC,CAAA;QAEnC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,YAAY,EAAE;aACpC,SAAS,CAAC,WAAW,CAAC;aACtB,QAAQ,CAAC,eAAe,CAAC;aACzB,SAAS,CAAC;YACT,EAAC,IAAI,EAAC,mBAAmB,EAAC,KAAK,EAAC,wBAAwB,EAAC;YACzD,EAAC,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,WAAW,EAAC;SAChC,CAAC,CAAA;QAEJ,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IACjC,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC;AAlBD,oBAkBC"}

6
package-lock.json

@ -10876,9 +10876,9 @@
}
},
"sphinx-bot": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/sphinx-bot/-/sphinx-bot-0.1.2.tgz",
"integrity": "sha512-sIPk3Up2I4tI+nE6RfMKlh0mWVUpEbQXUYBts1TW8z6OhF27o+guMvp1KKJKd0dqZDIxO/ucB9zLKAY54RDYog==",
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/sphinx-bot/-/sphinx-bot-0.1.3.tgz",
"integrity": "sha512-MF0+WKVkfNn3yRoL5DcH22td8v3Tu6G1RBdYwcCzaOGDFfjUs+tSmvfY3x4kqU3tZ8wJwzeUVSiwh+hGWZ7W0w==",
"requires": {
"eventemitter3": "^4.0.7"
},

2
package.json

@ -78,7 +78,7 @@
"short-uuid": "^3.1.1",
"sjcl": "^1.0.8",
"socket.io": "^2.3.0",
"sphinx-bot": "^0.1.2",
"sphinx-bot": "^0.1.3",
"tail": "^2.0.3",
"ts-node": "^8.5.4",
"tsc": "^1.20150623.0",

Loading…
Cancel
Save