This file is indexed.

/usr/share/nadoka/plugins/timestampbot.nb is in nadoka 0.7.6-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
# -*-ruby-*-
#
# Copyright (c) 2004-2005 SASADA Koichi <ko1 at atdot.net>
#
# This program is free software with ABSOLUTELY NO WARRANTY.
# You can re-distribute and/or modify this program under
# the same terms of the Ruby's license.
#
#
# $Id: timestampbot.nb 240 2010-09-29 14:19:09Z znz $
#

=begin

== Abstract

Add time stamp to each log.


== Configuration
BotConfig = [
{
  :name        => :TimeStampBot,
  :interval    => 60 * 60,       # sec
  :stampformat => '== %y/%m/%d-%H:%M:%S ==========================================',
  :client      => false,
}
]

=end

class TimeStampBot < Nadoka::NDK_Bot
  def bot_initialize
    @interval    = @bot_config.fetch(:interval, 60 * 60) # default: 1 hour
    @stampformat = @bot_config.fetch(:stampformat,
      '== %y/%m/%d-%H:%M:%S ==========================================')
    @client      = @bot_config.fetch(:client, false)
    @nexttime    = nexttime
  end

  def nexttime
    t = (Time.now.to_i + @interval)
    Time.at(t - (t % @interval))
  end
  
  def on_timer tm
    if tm >= @nexttime
      stamp_log
      @nexttime = nexttime
    end
  end
  
  def stamp_log
    msg = @nexttime.strftime(@stampformat)
    @state.channels.each{|ch|
      @logger.clog(ch, msg, true)
    }
    @logger.slog(msg, true) if @client
  end
end