@wirelineio/botkit

0.3.0 • Public • Published

Botkit2

Prereqs

  • Remove old globally installed @wirelineio/cli if any;

  • Install new version:

npm install -g @wirelineio/cli

Chat

  • Generate new topic key:
$ openssl rand -hex 32
0a6a89932d5fbbadda979eecd34606f261560441dc2a16c585fa88eeb88c87e7
  • Copy created key and run same command in 2 terminals:
wire peer chat --topic <key>

e.g.

wire peer chat --topic 0a6a89932d5fbbadda979eecd34606f261560441dc2a16c585fa88eeb88c87e7
  • Type messages in both terminals.

Bots

To start a bot, you can use wire bot run or yarn start in bot folder. Params are (all are optional):

  • --name
  • --botVersion
  • --topic
  • --reset

name and botVersion would end up in bot.yml (override current values)

topic would end up in service.yml (override current value). If not provided, generated automatically and stored.

No need to pass the params if config files already exist.

reset would remove bots storage, e.g. reset existed before bots.

yarn clean:bots to do the reset; yarn clean:conf to remove service.yml (on the next start BotFactory would be listening on another topic)

Debug bot

  • cd into bot folder and start the factory:
cd ./packages/debug-bot
$ yarn start
yarn run v1.15.2
$ wire bot run -v
  bot Bot started. +0ms
  bot {"peerId":"eighteen-delaware-double-gee","topic":"390b8771a08d7d23bbe7b33f329dbbb6f0b1a86644173e469790892b3c6bb74d"} +3ms
  • open a new terminal window, and run wire peer chat --topic <key> with the key from output above:
$ wire peer chat --topic 390b8771a08d7d23bbe7b33f329dbbb6f0b1a86644173e469790892b3c6bb74d
{"peerId":"kansas-ink-eight-alpha","topic":"390b8771a08d7d23bbe7b33f329dbbb6f0b1a86644173e469790892b3c6bb74d"}
[eleven-item-edward-golf] > 
eighteen-delaware-double-gee joined the chat.
  • type @spawn debugbot in chat

  • go to the BotFactory terminal, it would contain information about spawned bot:

 bot-factory Spawned bot. +0ms
  bot-factory {"pid":18260,"name":"debugbot","childDir":"/Users/egorgripasov/Projects/wireline/upstream/botkit/packages/debug-bot/.bots/350551ee-0819-4534-b8f1-a8a0e0407a8b","env":{"topic":"f5c0ccb18f20c33699dea06265275986bc89e8fe36cc6a585cfa670aa7457e7d","peerId":"b8317050702d7fcacdd6006f13929ea145913d32e112613ce8a78268568ff295"}} +0ms
  bot-factory pid: 18260, stdout:
  bot-factory  $ /Users/egorgripasov/Projects/wireline/upstream/botkit/node_modules/.bin/babel-watch --use-polling ./src/main.js
  bot-factory  +454ms
  bot-factory pid: 18260, stderr:
  bot-factory  2019-08-01T12:33:54.880Z bot Bot started.
  bot-factory  +3s
  bot-factory pid: 18260, stderr:
  bot-factory  2019-08-01T12:33:54.882Z bot {"peerId":"edward-delaware-emma-harry","topic":"f5c0ccb18f20c33699dea06265275986bc89e8fe36cc6a585cfa670aa7457e7d"}
  bot-factory  +1ms
  • open new terminal window and use topic from output above to chat with spawned bot process (send @ping command):
$ wire peer chat --topic f5c0ccb18f20c33699dea06265275986bc89e8fe36cc6a585cfa670aa7457e7d
{"peerId":"december-earth-jupiter-golf","topic":"f5c0ccb18f20c33699dea06265275986bc89e8fe36cc6a585cfa670aa7457e7d"}
edward-delaware-emma-harry joined the chat.
[eighteen-iowa-edward-harry] > @ping
[eighteen-iowa-edward-harry] > edward-delaware-emma-harry > @pong
[eighteen-iowa-edward-harry] > 
  • Modify ./src/debugbot.js and save the file. Spawned bots should be respawned, and you still should be able to chat with the bot process (from second chat terminal with @ping commands).

  • Stop/start BotFactory, Spawned bots should be respawned, and you still should be able to chat with the bot process (from second chat terminal with @ping commands).

Chess Bot

  • cd into bot folder and start the factory:
cd ./packages/chess-bot
$ yarn start
yarn run v1.15.2
$ wire bot run -v
  bot Bot started. +0ms
  bot {"peerId":"delaware-island-eleven-grey","topic":"8a3307a91b8d46001596ad72bbc04ab60bffe01844166f371128dd0b66a4583a"} +3ms
  • open a new terminal window, and run wire peer chat --topic <key> with the key from output above:
$ wire peer chat --topic 8a3307a91b8d46001596ad72bbc04ab60bffe01844166f371128dd0b66a4583a
wire peer chat --topic 8a3307a91b8d46001596ad72bbc04ab60bffe01844166f371128dd0b66a4583a
{"peerId":"idaho-eighteen-double-green","topic":"8a3307a91b8d46001596ad72bbc04ab60bffe01844166f371128dd0b66a4583a"}
[diet-kansas-kansas-green] > 
delaware-island-eleven-grey joined the chat.
[diet-kansas-kansas-green] >
  • obtain Party Key from the launchpad, on browser console:
__DSUITE__._partySerializer._partyKey.toString('hex')
"44adb26bfd6f26549cd4eb23956587a140cf9e00daeb993c8f75c74abf4a88f3"
  • type @spawn chessbot <party key> in chat terminal
[diet-kansas-kansas-green] > @spawn chessbot 44adb26bfd6f26549cd4eb23956587a140cf9e00daeb993c8f75c74abf4a88f3
[diet-kansas-kansas-green] > 

Bot should be started and join the party. Create a game and play some moves.

  • Modify ./src/chessbot.js and save the file. Spawned bots should be respawned within proper party, and you still should be able to play with the bot (but need to create a new game).

  • Stop/start BotFactory, Spawned bots should be respawned within proper party, and you still should be able to play with the bot (but need to create a new game).

Readme

Keywords

none

Package Sidebar

Install

npm i @wirelineio/botkit

Weekly Downloads

0

Version

0.3.0

License

ISC

Unpacked Size

91.9 kB

Total Files

22

Last publish

Collaborators

  • dboreham
  • telackey
  • egorgripasov
  • richburdon
  • ashwinp