Class: TickingAway::ChatBot
- Inherits:
-
Object
- Object
- TickingAway::ChatBot
- Defined in:
- lib/ticking_away/chat_bot.rb
Instance Method Summary collapse
-
#initialize(server, channels) ⇒ ChatBot
constructor
A new instance of ChatBot.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(server, channels) ⇒ ChatBot
Returns a new instance of ChatBot.
11 12 13 14 15 |
# File 'lib/ticking_away/chat_bot.rb', line 11 def initialize(server, channels) @server = server @channels = channels @bot = nil end |
Instance Method Details
#start ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ticking_away/chat_bot.rb', line 17 def start # Required for dealing with scope. # The block provided when instantiating the # bot and the configuration block only have the # scope of the start method while the start # method has access to the class's instance vars # The block cannot access the class's instance vars # unless they're assigned to a var in the method's scope # Good target for some refactoring server = @server channels = @channels @bot = Cinch::Bot.new do configure do |c| c.server = server c.channels = channels c.nick = 'TickingAwayBot' c.plugins.plugins = [TickingAway::TimeInfo] end end @bot.start end |
#stop ⇒ Object
41 42 43 |
# File 'lib/ticking_away/chat_bot.rb', line 41 def stop @bot.stop end |