initial commit; based on minerobber's cosnok bot

master
ulhar 2021-09-17 19:12:00 -04:00
commit 6050bea0fd
5 changed files with 85 additions and 0 deletions

3
Gemfile 100644
View File

@ -0,0 +1,3 @@
source "https://rubygems.org"
gem 'cinch'

26
bot.rb 100644
View File

@ -0,0 +1,26 @@
require 'cinch'
# CONFIG
#
botname = 'mechadrake'
plugins_to_load = []
Dir['plugins/*.rb'].each do |plugin|
load plugin
plugins_to_load << Object.const_get(File.basename(plugin, '.rb').capitalize)
end
bot = Cinch::Bot.new do
configure do |c|
c.server = ENV["IRC_SERVER"] || "127.0.0.1"
c.channels = ["#bot-test"]
c.port = 6667
c.nick = botname
c.user = botname
c.plugins.plugins = plugins_to_load
c.plugins.prefix = /^#{botname}_*\:? ?/
end
end
bot.start

13
plugins/hello.rb 100644
View File

@ -0,0 +1,13 @@
class Hello
include Cinch::Plugin
match "hello"
def execute(m)
m.reply "greetings, #{m.user.nick}"
end
def help
"hello - bully me into using slightly less sassy language"
end
end

29
plugins/help.rb 100644
View File

@ -0,0 +1,29 @@
class Help
include Cinch::Plugin
match /h[ae]lp(?:\s+(\w+))?/
def execute(m, command)
if command.nil?
names = bot.plugins.map do |plugin|
plugin.class.name.downcase
end
m.reply "my sacred powers: #{names.join(", ")}"
else
m.reply "looking for #{command}..."
plug = bot.plugins.first do |plugin|
plugin.class.name.downcase == command
end
unless plug.nil?
m.reply plug.class.help
else
m.reply "keep trying, buddy. you'll get it eventually."
end
end
end
def help
"help [command] - figure out how to use one (1) of two (2) commands"
end
end

View File

@ -0,0 +1,14 @@
class Rollcall
include Cinch::Plugin
set :prefix, //
match "!rollcall"
def execute(m)
m.reply "*yawns* did you miss me?"
end
def help
"rollcall - respond to !rollcall"
end
end