stuff
This commit is contained in:
parent
bc9c0bc737
commit
ca223256a9
24
extendobot
24
extendobot
@ -1,24 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'cinch'
|
||||
require 'emoji'
|
||||
require 'emoji/string_ext'
|
||||
require_relative './classes/Util'
|
||||
|
||||
utils = Util::Util.new;
|
||||
bots = Util::BotFamily.instance
|
||||
servers = utils.getServers()
|
||||
servers.each { |serv|
|
||||
if serv['autoconnect']
|
||||
bots.add( {
|
||||
"host" => serv['host'],
|
||||
"name" => serv['name']
|
||||
}
|
||||
)
|
||||
puts "autoconnect to #{serv['name']}"
|
||||
else
|
||||
puts "ignoring #{serv['name']}"
|
||||
end
|
||||
}
|
||||
bots.startAll
|
||||
utils.MainLoop
|
46
hooktest
46
hooktest
@ -1,46 +0,0 @@
|
||||
#!/usr/bin/env rubyrequire 'cinch'
|
||||
|
||||
module RandHook
|
||||
include Cinch::Plugin
|
||||
def self.generate_random_number(m)
|
||||
# Hooks are called in the same thread as the handler and thus
|
||||
# using thread local variables is possible.
|
||||
Thread.current[:rand] = Kernel.rand
|
||||
end
|
||||
def self.prehook(method)
|
||||
hook :pre, method: method.to_sym
|
||||
end
|
||||
prehook("generate_random_number")
|
||||
|
||||
def self.cheer(m)
|
||||
m.reply "Yay, I successfully ran a command"
|
||||
end
|
||||
def initialize(*args)
|
||||
super
|
||||
self.hook :pre, method: :generate_random_number
|
||||
self.hook :post, method: :cheer
|
||||
end
|
||||
end
|
||||
|
||||
class HooksDemo
|
||||
include Cinch::Plugin
|
||||
include RandHook
|
||||
|
||||
match "rand"
|
||||
def execute(m)
|
||||
m.reply "Random number: " + Thread.current[:rand].to_s
|
||||
end
|
||||
end
|
||||
|
||||
bot = Cinch::Bot.new do
|
||||
configure do |c|
|
||||
c.nick = "cinch_hooks"
|
||||
c.server = "irc.freenode.org"
|
||||
c.channels = ["#dacleeze"]
|
||||
c.verbose = true
|
||||
c.plugins.plugins = [HooksDemo]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
bot.start
|
1
tcpbot
1
tcpbot
@ -1 +0,0 @@
|
||||
extendobot
|
24
tcpbot
Executable file
24
tcpbot
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'cinch'
|
||||
require 'emoji'
|
||||
require 'emoji/string_ext'
|
||||
require_relative './classes/Util'
|
||||
|
||||
utils = Util::Util.new;
|
||||
bots = Util::BotFamily.instance
|
||||
servers = utils.getServers()
|
||||
servers.each { |serv|
|
||||
if serv['autoconnect']
|
||||
bots.add( {
|
||||
"host" => serv['host'],
|
||||
"name" => serv['name']
|
||||
}
|
||||
)
|
||||
puts "autoconnect to #{serv['name']}"
|
||||
else
|
||||
puts "ignoring #{serv['name']}"
|
||||
end
|
||||
}
|
||||
bots.startAll
|
||||
utils.MainLoop
|
Loading…
Reference in New Issue
Block a user