Sun, 20 May 2018 01:57:58 +0200
riddim.plugins.pubsub2room: Return early from extractor if no stanza given
79
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 | function riddim.plugins.topic(bot) |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 | bot:hook("commands/topic", function(cmd) |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 | local room = cmd.room; |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 | if not room then return "This isn't a room!"; end |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 | if not cmd.param then return room.subject or "No topic here"; end |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 | room:set_subject(cmd.param); |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 | end); |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 | |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 | bot:hook("commands/addtopic", function(cmd) |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 | local room = cmd.room; |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 | if not room then return "This isn't a room!"; end |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 | if not cmd.param then return "What do you want me do add?"; end |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 | room:set_subject((#room.subject>0 and room.subject .. cmd.param) or cmd.param) |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 | end); |
43ae29f2c69b
plugins.topic: Lets anyone (no ACL yet) change topic
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 | end |