Class: Cinch::Plugins::TaskBot::Tasks

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/cinch/plugins/taskbot/tasks.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Tasks

Returns a new instance of Tasks.



21
22
23
# File 'lib/cinch/plugins/taskbot/tasks.rb', line 21

def initialize(*args)
  super
end

Instance Method Details

#add_task(m, content) ⇒ Object

Add a task for yourself



42
43
44
# File 'lib/cinch/plugins/taskbot/tasks.rb', line 42

def add_task(m, content)
  add_task_for_user(m, m.user.nick, content)
end

#add_task_for(m, nick, content) ⇒ Object

Add a task for <nick>



47
48
49
# File 'lib/cinch/plugins/taskbot/tasks.rb', line 47

def add_task_for(m, nick, content)
  add_task_for_user(m, nick, content)
end

#complete_task(m, cmd_alias, task_id2) ⇒ Object

Mark a task completed



52
53
54
# File 'lib/cinch/plugins/taskbot/tasks.rb', line 52

def complete_task(m, cmd_alias, task_id2)
  set_task_status(m, task_id2.to_i, :completed)
end

#get_list(m) ⇒ Object

Get a list of your uncompleted tasks



68
69
70
# File 'lib/cinch/plugins/taskbot/tasks.rb', line 68

def get_list(m)
  get_list_for_user(m, m.user.nick)
end

#get_list_for(m, nick) ⇒ Object

Get a list of <nick>‘s uncompleted tasks



73
74
75
# File 'lib/cinch/plugins/taskbot/tasks.rb', line 73

def get_list_for(m, nick)
  get_list_for_user(m, nick)
end

#help(m) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cinch/plugins/taskbot/tasks.rb', line 25

def help(m)
  m.reply "Simple to-do lists implemented as an IRC robot"

  m.reply "!task add \"Take out the trash\" - Add a task for yourself"
  m.reply "!task add <nick> \"Take out the trash\" - Add a task for <nick>"

  m.reply "!task complete|finish #<task_id> - Mark a task completed"
  m.reply "!task rm|delete|remove #<task_id> - Remove a task"

  m.reply "!task list - Get a list of your uncompleted tasks"
  m.reply "!task list <nick> - Get a list of <nick>'s uncompleted tasks"

  m.reply "Author: Logan Koester <[email protected]>"
  m.reply "Fork me at https://github.com/logankoester/taskbot>"
end

#remove_task(m, cmd_alias, task_id2) ⇒ Object

Remove a task



57
58
59
60
61
62
63
64
65
# File 'lib/cinch/plugins/taskbot/tasks.rb', line 57

def remove_task(m, cmd_alias, task_id2)
  task = Task.find_by_id2(task_id2.to_i)
  if task
    task.destroy
    m.reply "Task ##{task_id2} has been removed."
  else
    m.reply "Task ##{task_id2} not found."
  end
end