A couple weeks back I was in need of a discord bot with steem integration, and saw that had one running off of Ruby. Since I previously had only toyed a bit with Ruby, I had a bit of initial trouble getting it off the ground, and just for my reference I'm just going to document my steps here. I'm working with a server running Ubuntu (16.xx).
The repository is here: https://github.com/steem-third-party/cosgrove
Local Changes and Bundling
The initial instructions show how to use it as is, but I also wanted to make some changes to it, so I dug into how to set up the package with bundler:
sudo apt-get install ruby
gem install bundler
bundle install
And this is where I ran into a quite a few problems. As of the time I did this, I had the following errors and resolutions:
nokogiri: mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
A search revealed that I need ruby dev libraries:
sudo apt-get install ruby`ruby -e 'puts RUBY_VERSION[/\d+\.\d+/]'`-dev
After that was resolved, there was a complaint about not having 'freetds'... some googling and I found I needed to install it.
mkdir freetds
cd freetds
wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.27.tar.gz
tar -xzf freetds-1.00.27.tar.gz
cd freetds-1.00.27
./configure --prefix=/usr/local --with-tdsver=7.3
sudo make install
After that, a complaint about not having imagemagick....
sudo apt-get install libmagickwand-dev imagemagick
Then for an error about conflicting 'reset' scope...
vi /var/lib/gems/2.3.0/gems/steem_api-1.1.2/lib/steem_api/models/tx/custom/follow.rb
In this file, I looked for where the 'reset' scope was, and commented it out. Will probably need confirmation if that breaks something... so far it has been working. Probably for my purposes, better to remove the activerecord sql dep since I don't hook into SQL.
Using the local bundle
After bundle install worked, I set up another directory to point to this package, with Gemfile:
# Gemfile
source "https://rubygems.org"
gem "cosgrove", path: "{PATH_TO_LOCAL_COSGROVE_GEM}"
Here I also set up the config.yml, as documented in the repository.
And now my main file:
# main.rb
require 'cosgrove'
# For some reason, no default prefix, so needs specification
bot = Cosgrove::Bot.new prefix: '$'
bot.run
Now to run it:
bundle exec ruby main.rb
That got it to start and respect various commands.
I did run into trouble because I did not have Steem SQL set up. In this case, I commented out a bunch of lines to get it to revert to non-SQL behavior. Will be looking into patching with an option that can turn SQL off. At some point...
But anyway, now that I've done that, I've had some fun toying with various modifications to it. Now for example, we have manual curation within our community via the
account. Curators call on the bot to upvote, resteem, and leave a cupcake comment. And more fun things to come...
So far I've found it very easy to extend with what I need, and there's still plenty to explore in terms of what is baked into Cosgrove. Looks to have all sorts of fun dependencies.