Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 51 lines (37 sloc) 1.193 kB
cefce99 @whitequark Added new logger.
authored
1 #!/usr/bin/env ruby
2
4d06aee @whitequark Change directory structure.
authored
3 $: << File.join(File.dirname(__FILE__), 'lib')
4
cefce99 @whitequark Added new logger.
authored
5 require 'irclogger'
689248a @whitequark Some refactoring.
authored
6 require 'irclogger/cinch_plugin'
4939df8 @whitequark Add a backend for live logging.
authored
7 require 'redis'
b3e5b31 @whitequark Rewrite the logger to use cinch.
authored
8
d802c25 @whitequark Add some failsafe.
authored
9 pidfile = File.join(File.dirname(__FILE__), 'tmp', 'logger.pid')
5bc7ba1 @whitequark Add protection from starting logger multiple times.
authored
10
11 begin
12 old_pid = File.read(pidfile).to_i
13 Process.kill 0, old_pid
14
15 raise "An existing logger process is running with pid #{old_pid}. Refusing to start"
07461ad @whitequark Don't die if logger.pid is not present (fixes #6).
authored
16 rescue Errno::ESRCH, Errno::ENOENT
5bc7ba1 @whitequark Add protection from starting logger multiple times.
authored
17 end
18
d802c25 @whitequark Add some failsafe.
authored
19 File.open(pidfile, 'w') do |f|
20 f.write Process.pid
21 end
22
b3e5b31 @whitequark Rewrite the logger to use cinch.
authored
23 bot = Cinch::Bot.new do
24 configure do |c|
101a915 @whitequark Add more config options (fixes #11).
authored
25 # Server config
b3e5b31 @whitequark Rewrite the logger to use cinch.
authored
26 c.server = Config['server']
101a915 @whitequark Add more config options (fixes #11).
authored
27 c.port = Config['port'] unless Config['port'].nil?
28 c.ssl.use = Config['ssl'] unless Config['ssl'].nil?
29
30 # Auth config
b3e5b31 @whitequark Rewrite the logger to use cinch.
authored
31 c.user = Config['username']
101a915 @whitequark Add more config options (fixes #11).
authored
32 c.password = Config['password'] unless Config['password'].nil?
b3e5b31 @whitequark Rewrite the logger to use cinch.
authored
33 c.realname = Config['realname']
e48dbbb @whitequark Don't append _ to nickname on conflict forever.
authored
34 c.nicks = [Config['nickname']]
101a915 @whitequark Add more config options (fixes #11).
authored
35 c.nick = Config['nickname']
36
37 # Logging config
38 c.channels = Config['channels']
cefce99 @whitequark Added new logger.
authored
39
689248a @whitequark Some refactoring.
authored
40 # cinch, oh god why?!
41 c.plugins.plugins = [IrcLogger::CinchPlugin]
5ec3d2a @whitequark Limit messages per second to 1 to avoid Excess Flood on Freenode.
authored
42
43 # Trying to avoid "Excess Flood"
da1cb7b @whitequark Lower cinch.messages_per_second to 0.5.
authored
44 c.messages_per_second = 0.5
b3e5b31 @whitequark Rewrite the logger to use cinch.
authored
45 end
cefce99 @whitequark Added new logger.
authored
46 end
b3e5b31 @whitequark Rewrite the logger to use cinch.
authored
47
689248a @whitequark Some refactoring.
authored
48 IrcLogger::CinchPlugin.redis = Redis.new(url: Config['redis'])
49
d802c25 @whitequark Add some failsafe.
authored
50 bot.start
Something went wrong with that request. Please try again.