Skip to content

Commit ab3d1e4

Browse files
committed
added another example plugin
1 parent 928a68f commit ab3d1e4

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

doc/example-plugins/counter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
crontable = []
33
outputs = []
44

5-
#crontable.append([.5,"add_number"])
65
crontable.append([5,"say_time"])
76

87
def say_time():
9-
outputs.append(["D030GJLM2", time.time()])
8+
#NOTE: you must add a real channel ID for this to work
9+
outputs.append(["D12345678", time.time()])

doc/example-plugins/repeat2.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

doc/example-plugins/todo.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
outputs = []
2+
crontabs = []
3+
4+
tasks = {}
5+
6+
def process_message(data):
7+
global tasks
8+
channel = data["channel"]
9+
text = data["text"]
10+
#only accept tasks on DM channels
11+
if channel.startswith("D") or channel.startswith("C"):
12+
if channel not in tasks.keys():
13+
tasks[channel] = []
14+
#do command stuff
15+
if text.startswith("todo"):
16+
tasks[channel].append(text[5:])
17+
outputs.append([channel, "added"])
18+
if text == "tasks":
19+
output = ""
20+
counter = 1
21+
for task in tasks[channel]:
22+
output += "%i) %s\n" % (counter, task)
23+
counter += 1
24+
outputs.append([channel, output])
25+
if text == "fin":
26+
tasks[channel] = []
27+
if text.startswith("done"):
28+
num = int(text.split()[1]) - 1
29+
tasks[channel].pop(num)
30+
if text == "show":
31+
print tasks

0 commit comments

Comments
 (0)