Skip to content

Commit

Permalink
Prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
madprops committed Jun 2, 2024
1 parent e5389a8 commit b61e2b4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,7 @@ Assign permissions in whatever way they make sense.

Some bots are meant to be fixed, others might be more dynamic, and others might belong to certain users.

---

`ask` also applies to users who can edit `prompts`.
There is also the `prompts` rule that controls who gets to set the prompts.

---

Expand Down
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"users": [],
"allow_ask": "all",
"allow_rules": "all",
"allow_prompts": "all",
"spam_limit": 3,
"spam_minutes": 30,
"compact": true,
Expand Down
24 changes: 22 additions & 2 deletions modules/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = (App) => {
`words`,
`allow_ask`,
`allow_rules`,
`allow_prompts`,
`users`,
`admins`,
]) {
Expand Down Expand Up @@ -101,6 +102,7 @@ module.exports = (App) => {
`${App.p}remove_user + [ nick ]`,
`${App.p}allow_ask + [ all | users | admins ]`,
`${App.p}allow_rules + [ all | users | admins ]`,
`${App.p}allow_prompts + [ all | users | admins ]`,
`${App.p}model + [ ${App.join(App.cmd_models, `|`)} ]`,
`${App.p}avatar + [ char ]`,
`${App.p}show_avatar + [ true | false ]`,
Expand Down Expand Up @@ -262,6 +264,18 @@ module.exports = (App) => {
}
},
},
{
name: `allow_prompts`,
on_arg: (data) => {
let allowed = [`all`, `users`, `admins`]
let value = App.cmd_similar(data.arg, allowed)

if (value) {
App.update_config(`allow_prompts`, value)
App.cmd_show(data.channel, `allow_prompts`)
}
},
},
{
name: `model`,
on_arg: (data) => {
Expand Down Expand Up @@ -494,9 +508,9 @@ module.exports = (App) => {

App.config.prompts[name] = prompt
App.update_config(`prompts`, App.config.prompts)
App.irc_respond(data.channel, "Prompt saved.")
App.irc_respond(data.channel, "Prompt Saved.")
},
allow: `ask`,
allow: `prompts`,
},
{
name: `config`,
Expand Down Expand Up @@ -546,6 +560,11 @@ module.exports = (App) => {
allowed = true
}
}
else if (c.allow === `prompts`) {
if (data.can_prompts) {
allowed = true
}
}
else if (data.is_admin) {
allowed = true
}
Expand Down Expand Up @@ -601,6 +620,7 @@ module.exports = (App) => {
data.channel = args.channel
data.cmd = args.cmd
data.can_rules = App.is_allowed(`rules`, args.from)
data.can_prompts = App.is_allowed(`prompts`, args.from)
data.is_admin = App.is_admin(args.from)
data.batch = args.batch

Expand Down

0 comments on commit b61e2b4

Please sign in to comment.