Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture and parse output of Whateverable bots

Since that is the standard way to present output in the Perl 6 documentation, I'm using the whateverable bots to evaluate expressions via the #perl6 IRC channel or the #whateverable channel. Produced output is something like this:

 10:28:19   jmerelo | p6: say 333444777 ~~ /(3+)/                                                                                                           │
 10:28:19 evalable6 | jmerelo, rakudo-moar 5ce24929f: OUTPUT: «「333」␤ 0 => 「333」␤»  

(in the WeeChat console program). From that output, I cut and paste to the document, erasing the parts I'm not interested in.

I was wondering if there was some easy way to parse and save that output directly, either server-based (some Whateverable bots save to gists, for instance), or client-based via scriptint the irssi or weechat platform.

like image 485
jjmerelo Avatar asked May 16 '18 08:05

jjmerelo


1 Answers

I think the most convenient solution in this case would be to bypass irc bots and define a bash function. Something like this:

d6() { echo -n '# OUTPUT: «'; perl6 -e "$1" | sed -z 's/\n/␤/g'; echo '»'; }

Then you can use it like this:

d6 'say 42'

Which will produce this output:

# OUTPUT: «42␤»

Of course, you'd need a different solution for other operating systems.



As a bonus, you can also put it into the clipboard automatically:

d6 'say 42' | tee >(xclip -selection clipboard)
like image 51
Aleks-Daniel Jakimenko-A. Avatar answered Sep 30 '22 18:09

Aleks-Daniel Jakimenko-A.