Changeset 763 for project/lazy-people/thanksbot
- Timestamp:
- 10/20/09 01:21:35 (5 months ago)
- Files:
-
- project/lazy-people/thanksbot/thanksbot.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
project/lazy-people/thanksbot/thanksbot.rb
r762 r763 16 16 include Observable 17 17 18 def initialize(*args) 19 p args 20 @channel = args[2] 21 args.delete_at 2 22 super 18 def initialize(config) 19 @channel = config[:irc][:opts][:channel] 20 21 super( 22 config[:irc][:host], 23 config[:irc][:port], 24 config[:irc][:opts] 25 ) 23 26 end 24 27 … … 30 33 if match = m[1].match(/^thanksbot:\s*(.*)/) 31 34 changed 32 notify_observers('', match[1]) 33 post NOTICE, m[0], "#{m.prefix.nick}: #{match[1]}" 35 begin 36 notify_observers(match[1]) 37 post NOTICE, m[0], "#{m.prefix.nick}: #{match[1]}" 38 rescue 39 post NOTICE, m[0], "ごめん、失敗したかも" 40 end 34 41 end 35 42 end … … 37 44 38 45 class ThanksDB < WedataDatabase 39 def update( name,message)40 create_item( name, { 'message' => message })46 def update(message) 47 create_item('thanksbot', { 'message' => message }) 41 48 end 42 49 end … … 44 51 config = YAML.load_file('thanksbot.yaml') 45 52 46 thanksbot = ThanksBot.new( 47 config['irc']['host'], 48 config['irc']['port'], 49 config['irc']['channel'], 50 config['irc']['nicks'] 51 ) 53 thanksbot = ThanksBot.new(config) 52 54 53 thanksdb = ThanksDB.new('thanks', config[ 'wedata_api'])55 thanksdb = ThanksDB.new('thanks', config[:wedata_api]) 54 56 lazysan = LazySan::Twitter.new(config[:twitter][:user], config[:twitter][:pass]) 55 57
