Skip to main content

Hubot test

I was searching for peer to peer video conferencing and landed up on Peer2Peer. While evaluating it and checking for other option i landed up to RocketChat and in terms how it supports bot by using  hubot. Today i will list out my quick test done on same.


Step 0:
 Hubot support various deployment platforms i.e. Heroku, Unix, Windows and Azure. So choose one for you. I just choose unix and create a VM on google cloud console.

Step 1:

Basic shell comes with node support, so just execute below command to install hubot.

npm install -g yo generator-hubot



Once successfully installed it will message like below:

No .bowerrc file in home directory Global configuration file is valid NODE_PATH matches the npm root No .yo-rc.json file in home directory Node.js version npm version yo versionEverything looks all right!npm WARN notsup Unsupported engine for got@5.7.1: wanted: {"node":">=0.10.0 <7"} (current: {"node":"10.14.2","npm":"6.14.5"})npm WARN notsup Not compatible with your version of node/npm: got@5.7.1+ yo@3.1.1+ generator-hubot@0.4.0added 994 packages from 424 contributors in 37.724s




Step 2:

Create a bot directory  and run "yo hubot" command from inside directory.


ashudevelopment2019@cloudshell:~$ mkdir botashudevelopment2019@cloudshell:~$ cd botashudevelopment2019@cloudshell:~/bot$ yo hubot _____________________________ / \ //\ | Extracting input for | ////\ _____ | self-replication process | //////\ /_____\ \ / ======= |[^_/\_]| /---------------------------- | | _|___@@__|__ +===+/ /// \_\ | |_\ /// HUBOT/\\ |___/\// / \\ \ / +---+ \____/ | | | //| +===+ \// |xx|? Owner abc@gmail.com? Bot name test? Description A test bot? Bot adapter shell create bin/hubot create bin/hubot.cmd create Procfile create README.md create external-scripts.json create hubot-scripts.json create .gitignore create package.json create scripts/example.coffee create .editorconfig _____________________________ _____ / \ \ \ | Self-replication process |

_____ / \ \ \ | Self-replication process | | | _____ | complete... | |__\\| /_____\ \ Good luck with that. / |//+ |[^_/\_]| /---------------------------- | | _|___@@__|__ +===+/ /// \_\ | |_\ /// HUBOT/\\ |___/\// / \\ \ / +---+ \____/ | | | //| +===+ \// |xx|npm notice created a lockfile as package-lock.json. You should commit this file.+ hubot-redis-brain@1.0.0+ hubot-diagnostics@1.0.0+ hubot-help@1.0.1+ hubot-google-translate@0.2.1+ hubot-maps@0.0.3+ hubot-google-images@0.2.7+ hubot-pugme@0.1.1+ hubot-scripts@2.17.2+ hubot@3.3.2+ hubot-heroku-keepalive@1.0.3+ hubot-rules@1.0.0+ hubot-shell@1.0.2+ hubot-shipit@0.2.1added 93 packages from 54 contributors and audited 93 packages in 3.606sfound 0 vulnerabilitiesashudevelopment2019@cloudshell:~/bot$

We have chosen shell adapter for testing/ development only. You can chose campfire after you have signed on campfire portal.

Step 3: Now its ready for test. you can execute like below:

Run bin/hubot on same prompt.


ashudevelopment2019@cloudshell:~/bot$ bin/hubotaudited 93 packages in 1.029sfound 0 vulnerabilitiesNo history availabletest> [Sun Jun 28 2020 20:34:52 GMT+0530 (India Standard Time)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.Your hubot-scripts.json is empty, so you just need to remove it.[Sun Jun 28 2020 20:34:52 GMT+0530 (India Standard Time)] INFO hubot-redis-brain: Using default redis on localhost:6379[Sun Jun 28 2020 20:34:52 GMT+0530 (India Standard Time)] ERROR hubot-heroku-keepalive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. `heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s | grep web.url | cut -d= -f2)`


Step 4:

You can execute test help to list down what are the option with bot.

test> test helptest> ship it - Display a motivation squirreltest adapter - Reply with the adaptertest animate me <query> - The same thing as `image me`, except adds a few parameters to try to return an animated GIF instead.test echo <text> - Reply back with <text>test help - Displays all of the help commands that this bot knows about.test help <query> - Displays all help commands that match <query>.test image me <query> - The Original. Queries Google Images for <query> and returns a random top result.test map me <query> - Returns a map view of the area returned by `query`.test mustache me <url|query> - Adds a mustache to the specified URL or query result.test ping - Reply with pongtest pug bomb N - get N pugstest pug me - Receive a pugtest the rules - Make sure hubot still knows the rules.test time - Reply with current timetest translate me <phrase> - Searches for a translation for the <phrase> and then prints that bad boy out.test translate me from <source> into <target> <phrase> - Translates <phrase> from <source> into <target>. Both <source> and <target> are optional


There are plenty of NPM packages for various activities. Check here for more details. hubot-scripts


As i explore will add more here.


Comments

Popular posts from this blog

[PUZZLE] ELEPHANT AND BANANA PUZZLE

A merchant has bough some 3000 banana from market and want to bring them to his home which is 1000 km far from Market. He have a elephant which can carry maximum of 1000/- banana at time. That could have been easy but this elephant is very shrewd and he charges 1 banana for every one kilometer he travel. Now we have to maximise number of banana which should reach to home. Solution: At present we are at 0th km with 3000 banana and elephant. Lets see if elephant have to shift all the 3000 banana and elephant by 1 km. For 1 km shift: Take first 1000 banana and drop at 1st km. 2 banana consumed. One banana each for to and fro. Second  1000 banana and drop at 1st km. 2 banana consumed. Third 1000 banana and reach at 1st km. 1 banana consumed. So all in all total 5 banana will be consumed if we shift a kilometer. But that's not all, our total banana number are also reducing so we may have to reduce the number of turns too. And this will happen once we have reduced the b

[JAVA] Evil Null

Elvis operator could have been a good use here. But unfortunately have been decline till now. Its used to say "?." Operate only if not null. Class A {  public B getB() {    return new B(); } } public void test( A a) {     if ( a != null  )         return a.getB();  } Above method would be replaced with public void test ( A a) {      return a?.getB();  } Unfortunately its still some time we can see some think like that. So till that we have to live with two choices: 1. Check for null. 2. Use the Null Object Pattern. So we all know that how to check for null objects and believe me i had real long chain of checking null. Second way can be useful but if this chain is pretty long its can be tiresome to have null object for all the hierarchy Null Object means there will be definition of class A (mostly derived from same interface.) and will have dummy methods which will nullify any call to these methods.

Two numbers with minimum difference

Find the two numbers whose difference is minimum among the set of numbers. For example the sequence is 5, 13, 7, 0, 10, 20, 1, 15, 4, 19 The algorithm should return min diff = 20-19 = 1. Make an efficient algorithm, yeah best could be O(n). Not sure if i could use DP here, will post a solution tommorow. Let me know if you find a answer. Algorithm:MiniMumDiffN Get the size of array , say n. Get the range of array, range. Bucket Sort the above array. Search the above sorted array for minimum difference. This will be the minimum difference numbers. Now question comes where the range of above given array is very big. Algorithm:DivideArray Take an random element. Search for its position in array. Return the index of element. Algorithm:MiniMumDiff if array_range > MAXRANGE int mid = divideArray (arr,start,end); d1,max1 = MiniMumDiff( arr,start,mid-1); d2,max2 = MiniMumDIff(arr,mid+1,end); d3 = difference max1 and arr[mid] d4 = difference max2 and arr[mid] return minimum( d1,d2