-
Notifications
You must be signed in to change notification settings - Fork 0
/
open_ruby_rmbot
executable file
·111 lines (90 loc) · 3.11 KB
/
open_ruby_rmbot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env ruby
# -*- mode: ruby; coding: utf-8 -*-
# OpenRubyRMBot, the nice and friendly robot hanging around
# in #OpenRubyRMK on irc.freenode.net. This is a Cinch
# robot (https://github.com/cinchrb/cinch) and if you
# want to customize it, you probably want to change the
# #configure section below. Also note all files inside
# plugins/ are automatically loaded and all constants
# defined below the CinchPlugins module will automatically
# be registered as plugins to the robot.
require "mkfifo"
require "cinch"
require_relative "plugins/echo"
require_relative "plugins/http_server"
require_relative "plugins/pid_file"
require_relative "plugins/fifo"
require_relative "plugins/link_info"
require_relative "plugins/pega_issues"
require_relative "plugins/github_commits"
require_relative "plugins/help"
require_relative "plugins/memo"
require_relative "plugins/history"
require_relative "plugins/quit"
DIR = File.dirname(File.expand_path(__FILE__))
cinch = Cinch::Bot.new do
configure do |config|
config.server = "chat.freenode.net"
config.port = 6697
config.ssl.use = true
config.ssl.verify = false
config.channels = ["#OpenRubyRMK"]
config.nick = "ORRBot"
config.user = "orrbot"
config.realname = "OpenRubyRMBot"
# Default prefix is the bot’s name
config.plugins.prefix = lambda{|msg| Regexp.compile("^#{Regexp.escape(msg.bot.nick)}:?\s*")}
config.plugins.options[Cinch::PegaIssues] = {
:base_url => "https://devel.pegasus-alpha.eu/issues"
}
config.plugins.options[Cinch::PidFile] = {
:path => "#{DIR}/tmp/orrbot.pid",
:strict => true
}
config.plugins.options[Cinch::Fifo] = {
:path => "#{DIR}/tmp/myfifo",
:mode => 0666
}
config.plugins.options[Cinch::HttpServer] = {
:host => "0.0.0.0",
:port => 46664,
:logfile => "#{DIR}/tmp/httpserver.log"
}
config.plugins.options[Cinch::Help] = {
:intro => "%s at your service. Commands starting with /msg are meant to be sent privately, <> indicate mandatory, [] optional parameters."
}
config.plugins.options[Cinch::History] = {
:mode => :max_age,
:max_age => 5
}
config.plugins.options[Cinch::Memo] = {
:max_lifetime => 48
}
config.plugins.options[Cinch::Quit] = {
:op => true
}
config.plugins.plugins = [Cinch::PidFile,
Cinch::Echo,
Cinch::HttpServer,
Cinch::LinkInfo,
Cinch::Fifo,
Cinch::GithubCommits,
Cinch::Help,
Cinch::History,
Cinch::Memo,
Cinch::Quit,
Cinch::PegaIssues]
end
trap "SIGINT" do
bot.log("Cought SIGINT, quitting...", :info)
bot.quit
end
trap "SIGTERM" do
bot.log("Cought SIGTERM, quitting...", :info)
bot.quit
end
file = File.open("#{DIR}/tmp/bot.log", "a")
file.sync = true
loggers.push(Cinch::Logger::FormattedLogger.new(file))
end
cinch.start