Setting Up Inertia's Cosgrove Bot

in discordbot •  6 years ago  (edited)

A couple weeks back I was in need of a discord bot with steem integration, and saw that @inertia 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 @helpie community via the @helpiecake 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.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Oh man, I really need to clean up cosgrove.

Hehe no worries. I've been meaning to help a bit too but for now I'm just using what works. Thanks for publishing what you have either way!

Posted using Partiko Android

This all looks like Mandarin to me. Lol

I wish I knew how to decipher this stuff. #useless

Posted using Partiko iOS

I think it's Aramaic, everyone always forgets Aramaic xD

Now for real, am I crazy for wanting to learn Latin? At least the basics? Even though it's a dead language it's one of the most important languages in the world, it's one of the few that gave birth to all the current languages!

One day, my friend. We will all be forced to speak bot.

The bot will speak english when that day comes :)

Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

Hi @eonwarped!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 4.996 which ranks you at #1145 across all Steem accounts.
Your rank has improved 3 places in the last three days (old rank 1148).

In our last Algorithmic Curation Round, consisting of 201 contributions, your post is ranked at #9.

Evaluation of your UA score:
  • Some people are already following you, keep going!
  • The readers appreciate your great work!
  • Great user engagement! You rock!

Feel free to join our @steem-ua Discord server

What can you do with Ruby? Never used it, have no idea what it does, but if it is useful I might dip my pinky toe in it and see if I can do something nice with it

Why is the hardest part always getting the thing to run

Dear eonwarped:

We are SteemBet, the next generation STEEM based gaming platform. We are honored to invite you to join our first fantastic dice game, which is just the beginning of SteemBet game series. Our dividend system has now launched. The prize pool has already accumulated 2,000 STEEM and more than 60 players have participated in staking mining token SBT. A huge reward of 40,000 STEEM is awaiting! Join us NOW with other 500 STEEM users to loot HUGE dividend reward!!

SteemBet Team

Official Website
https://steem-bet.com

Discord Server
https://discord.gg/95cBN3W

Telegram Group
https://t.me/steembet