Skip to content

Commit

Permalink
Add switch to prevent bot tweeting in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Jan 2, 2018
1 parent c02d84b commit 19ac74a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -81,6 +81,22 @@ The styles are in `static/main.scss`. You'll need to run `./sassify` to
have [SASS preprocessor](http://sass-lang.com/) watch for changes and
generate CSS styles for the site.

### IRC Bot development mode

Use `./dev-BOT` script to power on the bot in dev mode. It'll start the bot
with `P6LERT_IRC_HOST=localhost` and `P6LERT_DEBUG=1` env vars. The available
vars are:

* `P6LERT_IRC_HOST`—Specifies the IRC server host to connect to
* `P6LERT_DEBUG`—Enables debug mode, which:
* Sets alerter URL to `http://localhost:10000/alert`
* Joins `#zofbot` IRC channel instead of the usual set
* Disables tweeting by default
* Reduces delay before alerts go public to 60 seconds (only affects the
time when they get tweeted out)
* `P6LERT_DEBUG_DO_TWEET`—Enables debug mode tweeting. **This includes
re-tweeting untweeted alerts from the database on load.**

### IRC Bot Admins

Admins are allowed to post/update/delete alerts. Their hosts are stored in
Expand Down
9 changes: 6 additions & 3 deletions bin/bot.p6
Expand Up @@ -12,6 +12,9 @@ my $alert-re = rx:i/
$<alert>=.+
/;

my $tweet = True;
$tweet = False if %*ENV<P6LERT_DEBUG> and not %*ENV<P6LERT_DEBUG_DO_TWEET>;

.run with IRC::Client.new:
:nick<p6lert>,
:username<p6lert-zofbot>,
Expand All @@ -26,7 +29,7 @@ class P6Lert::IRC::Plugin {
|(:alert-url<http://localhost:10000/alert> if %*ENV<P6LERT_DEBUG>),
|(:60public-delay if %*ENV<P6LERT_DEBUG>);

submethod TWEAK { $!alerter.retweet }
submethod TWEAK { $tweet and $!alerter.retweet }

multi method irc-to-me ($ where /^ \s* 'help' \s* '?'? \s* $/) {
https://github.com/perl6/alerts P6lert commands: [insta]?add ALERT, update ID ALERT,
Expand All @@ -35,7 +38,7 @@ class P6Lert::IRC::Plugin {
multi method irc-to-me(AdminMessage $e where
rx:i/^\s* [$<insta>=insta]? add \s+ $<alert>=<$alert-re>/
) {
my $id = try $!alerter.add: ~$<alert><alert>, :tweet, :creator($e.nick.subst: /'_'+ $/, ''),
my $id = try $!alerter.add: ~$<alert><alert>, :$tweet, :creator($e.nick.subst: /'_'+ $/, ''),
|(:affects(~$_) with $<alert><affects> ),
|(:severity(~$_) with $<alert><severity>),
|(:time(time - 62*10) if $<insta>);
Expand All @@ -47,7 +50,7 @@ class P6Lert::IRC::Plugin {
) {
my $alert = $!alerter.get: +$<id> or return "No alert with ID $<id>";
(try $!alerter.update:
+$<id>, ~$<alert><alert>, :tweet, :creator($e.nick.subst: /'_'+ $/, ''),
+$<id>, ~$<alert><alert>, :$tweet, :creator($e.nick.subst: /'_'+ $/, ''),
|(:affects(~$_) with $<alert><affects> ),
|(:severity(~$_) with $<alert><severity>)
) or return "Error: $!";
Expand Down

0 comments on commit 19ac74a

Please sign in to comment.