Skip to content

Commit

Permalink
Merge pull request #151 from destinygg/static-output-args
Browse files Browse the repository at this point in the history
Add args to static output commands.
  • Loading branch information
11k authored Feb 20, 2024
2 parents ef60b09 + 60ad8e4 commit ea02e6c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 39 deletions.
74 changes: 37 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,43 +56,43 @@ Durations are in the format of the number, followed by h,m,s or d.

(Note on adding commands/scheduled commands for admins, when you add the commands to twitch/dgg, you need to !restart the bot in the other chat to pick these changes up. This will change with a future update.)

| Command | Input | What it does | Requires Admin | Example |
|------------------------------------------------|------------------------------|-----------------------------------------------------------------------------------------|----------------|-----------------------------------------------------|
| !restart | None | Restarts the dgg or Twitch.tv bot. Don't overuse the command, it resets caches. | Yes | !restart |
| !stalk | {user} (postnumber) | Overrustle logs posts | Yes | !stalk Destiny 5 |
| !time | None | Current Steven Time | No | !time |
| !schedule !sch | None | Show next upcoming scheduled event, and a link to the schedule calendar. | No | !schedule |
| !addcommand !ac | {command} {text} | Adds a static command that can be called by anyone. | Yes | !addcommand !hello HEY HOWDY THERE PAL HOW YOU DOIN |
| !deletecommand !delcommand !removecommand !dc | {commandToDelete} | Deletes a static command | Yes | !deleteCommand !hello |
| !listcommands !lc | None | Lists all static database stored commands | Yes | !listcommands |
| !listscheduled !lsc | None | Lists all currently scheduled commands. Youtube and Calendar are always scheduled. | Yes | !lsc |
| !mute !mu | (duration) {user} | Mutes a user | Yes | !mute 10m MrMouton |
| !unmute !um !unm | {user} | Unmutes a user | Yes | !unmute MrMouton |
| !ban or !ipban (alias !ip) | (duration) {user} (reason) | Bans a user | Yes | !ban 1024h JAYL For being too cute |
| !voteban !voteipban | (duration) {user} (reason) | Starts a poll in DGG chat, if there's a majority yes the user is banned. | Yes | !voteban 1024h JAYL being too cute |
| !svoteban !svoteipban | (duration) {user} (reason) | SUB WEIGHTED - Same as voteban, but subs votes count for more, increasing with sub tier.| Yes | !voteban 1024h JAYL being too cute |
| !unban | {user} | Unbans a user | Yes | !unban JAYL |
| !nuke | (duration) {phrase or regex} | Mutes anyone using the nuked phrase for 10m by default. | Yes | !nuke 30m KING MOUTON !nuke 30d /[A-Z]+\s?420/ |
| !meganuke | (duration) {phrase or regex} | IPBans anyone using the nuked phrase for 10m by default. | Yes | !nuke 30m KING MOUTON !nuke 30d /[A-Z]+\s?420/ |
| !aegis | None | Removes any nukes that have been fired in the last 10 minutes and unmutes all users muted | Yes | !aegis |
| !aegisSingle !an !unnuke !as | (nukePhrase) | Removes single a Nuke by the phrase that was nuked | Yes | !as KING MOUTON |
| !love | None | Gives you love | No | !love Linusred |
| !addschcmd !asc | (commandToAdd) | Schedules a static command to be sent from the bot every few minutes. | Yes | !asc !hello |
| !deleteschcmd !dsc !unschedule | (commandToDelete) | Deletes a scheduled command so its not longer sent. | Yes | !dsc !hello |
| !song | None | Current song being played on Last.fm | No | !song |
| !lastsong !pastsong !previoussong !earlierSong | None | Previous song before the current one being played on last.fm | No | !lastsong |
| !youtube !yt !lastvideo | None | Last video posted on Destiny's youtube channel | No | !yt |
| !addban !addmute | (duration) {banned phrase} | Adds a banned phrase that will auto mute/ban upon a user posting it. | Yes | !addban 10d HAHA GNOMED !addmute /\bwee(woo)?\b/ |
| !mutelinks !mutelink !linksmute !linkmute | {on,off,all} (duration) | Auto mute linkers. `on` only mutes links that mention the command sender. `all` mutes all links. | Yes | !mutelinks on !mutelinks on 10m !mutelinks all 10m |
| !breakingnews !breaking !bn | {on,off,all} (max link age) | Breaking news mode. `on` only mutes old links (5m by default) that mention the command sender. `all` mutes all old links. | Yes | !breakingnews on 5m |
| !deleteban !dban !deletemute !mute | {banned phrase} | Removes a banned or muted phrase. Works for both. | Yes | !deleteban HAHA GNOMED |
| !live | None | Reports the last time a stream was live, or how long the stream has been going. | No | !live |
| !ud !updateduo !duoupdate | Any text | Updates the !duo command with whatever text you type. | Yes | !ud Lilypichu AYAYA |
| !duo | None | Outputs whatever is current stored using !ud | No | !duo |
| !deaths !death !died | None | Outputs the current death counter | No | !death !died |
| !incdeaths !ideaths !incd !id | None | Adds 1 to the current death counter. Can only be updated once every 15 seconds to prevent 2 people updating | Yes | !id !ideaths !incd |
| !setdeaths !setd !sdeaths | (number to set deaths to)) | Sets the death counter to the value specified | Yes | !setd 50 !sdeaths 100 |
| !gulag | (duration) {user1} (user2) ... (user n) | Voteban between all included users. `random` as a username will select a recent random chatter. | Yes | !gulag 30m derDeidra Dan |
| Command | Input | What it does | Requires Admin | Example |
|------------------------------------------------|------------------------------|---------------------------------------------------------------------------------------------------|----------------|-----------------------------------------------------------|
| !restart | None | Restarts the dgg or Twitch.tv bot. Don't overuse the command, it resets caches. | Yes | !restart |
| !stalk | {user} (postnumber) | Overrustle logs posts | Yes | !stalk Destiny 5 |
| !time | None | Current Steven Time | No | !time |
| !schedule !sch | None | Show next upcoming scheduled event, and a link to the schedule calendar. | No | !schedule |
| !addcommand !ac | {command} {text} | Adds a static command that can be called by anyone. `{%n%}` can be used in text to get arguments. | Yes | !addcommand !hello HEY HOWDY THERE PAL HOW YOU DOIN {%1%} |
| !deletecommand !delcommand !removecommand !dc | {commandToDelete} | Deletes a static command | Yes | !deleteCommand !hello |
| !listcommands !lc | None | Lists all static database stored commands | Yes | !listcommands |
| !listscheduled !lsc | None | Lists all currently scheduled commands. Youtube and Calendar are always scheduled. | Yes | !lsc |
| !mute !mu | (duration) {user} | Mutes a user | Yes | !mute 10m MrMouton |
| !unmute !um !unm | {user} | Unmutes a user | Yes | !unmute MrMouton |
| !ban or !ipban (alias !ip) | (duration) {user} (reason) | Bans a user | Yes | !ban 1024h JAYL For being too cute |
| !voteban !voteipban | (duration) {user} (reason) | Starts a poll in DGG chat, if there's a majority yes the user is banned. | Yes | !voteban 1024h JAYL being too cute |
| !svoteban !svoteipban | (duration) {user} (reason) | SUB WEIGHTED - Same as voteban, but subs votes count for more, increasing with sub tier. | Yes | !voteban 1024h JAYL being too cute |
| !unban | {user} | Unbans a user | Yes | !unban JAYL |
| !nuke | (duration) {phrase or regex} | Mutes anyone using the nuked phrase for 10m by default. | Yes | !nuke 30m KING MOUTON !nuke 30d /[A-Z]+\s?420/ |
| !meganuke | (duration) {phrase or regex} | IPBans anyone using the nuked phrase for 10m by default. | Yes | !nuke 30m KING MOUTON !nuke 30d /[A-Z]+\s?420/ |
| !aegis | None | Removes any nukes that have been fired in the last 10 minutes and unmutes all users muted | Yes | !aegis |
| !aegisSingle !an !unnuke !as | (nukePhrase) | Removes single a Nuke by the phrase that was nuked | Yes | !as KING MOUTON |
| !love | None | Gives you love | No | !love Linusred |
| !addschcmd !asc | (commandToAdd) | Schedules a static command to be sent from the bot every few minutes. | Yes | !asc !hello |
| !deleteschcmd !dsc !unschedule | (commandToDelete) | Deletes a scheduled command so its not longer sent. | Yes | !dsc !hello |
| !song | None | Current song being played on Last.fm | No | !song |
| !lastsong !pastsong !previoussong !earlierSong | None | Previous song before the current one being played on last.fm | No | !lastsong |
| !youtube !yt !lastvideo | None | Last video posted on Destiny's youtube channel | No | !yt |
| !addban !addmute | (duration) {banned phrase} | Adds a banned phrase that will auto mute/ban upon a user posting it. | Yes | !addban 10d HAHA GNOMED !addmute /\bwee(woo)?\b/ |
| !mutelinks !mutelink !linksmute !linkmute | {on,off,all} (duration) | Auto mute linkers. `on` only mutes links that mention the command sender. `all` mutes all links. | Yes | !mutelinks on !mutelinks on 10m !mutelinks all 10m |
| !breakingnews !breaking !bn | {on,off,all} (max link age) | Breaking news mode. `on` only mutes old links (5m by default) that mention the command sender. `all` mutes all old links. | Yes | !breakingnews on 5m |
| !deleteban !dban !deletemute !mute | {banned phrase} | Removes a banned or muted phrase. Works for both. | Yes | !deleteban HAHA GNOMED |
| !live | None | Reports the last time a stream was live, or how long the stream has been going. | No | !live |
| !ud !updateduo !duoupdate | Any text | Updates the !duo command with whatever text you type. | Yes | !ud Lilypichu AYAYA |
| !duo | None | Outputs whatever is current stored using !ud | No | !duo |
| !deaths !death !died | None | Outputs the current death counter | No | !death !died |
| !incdeaths !ideaths !incd !id | None | Adds 1 to the current death counter. Can only be updated once every 15 seconds to prevent 2 people updating | Yes | !id !ideaths !incd |
| !setdeaths !setd !sdeaths | (number to set deaths to) | Sets the death counter to the value specified | Yes | !setd 50 !sdeaths 100 |
| !gulag | (duration) {user1} (user2) ... (user n) | Voteban between all included users. `random` as a username will select a recent random chatter. | Yes | !gulag 30m derDeidra Dan |


## Todo
Expand Down
14 changes: 13 additions & 1 deletion lib/commands/implementations/static-output.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
const CommandOutput = require('../command-output');

function staticCommand(staticOutput) {
return () => new CommandOutput(null, staticOutput);
return (input) => {
let output = staticOutput;
const args = input ? input.split(' ') : [];

output = output.replace(/\{%(\d+)%\}/g, (_, i) => {
if (parseInt(i, 10) && args[parseInt(i, 10) - 1]) {
return args[parseInt(i, 10) - 1];
}
return '';
});

return new CommandOutput(null, output);
};
}

module.exports = staticCommand;
Loading

0 comments on commit ea02e6c

Please sign in to comment.