From bda9f7d8f11608467bf48855be2561c5fc5d5f19 Mon Sep 17 00:00:00 2001 From: Victor Maslov Date: Wed, 2 Sep 2020 12:33:01 +0300 Subject: [PATCH] stopping the bot by a PM --- examples/dut/Gemfile.lock | 4 ++-- examples/dut/main.rb | 5 +++++ examples/unisa/Gemfile.lock | 4 ++-- examples/unisa/main.rb | 5 +++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/examples/dut/Gemfile.lock b/examples/dut/Gemfile.lock index 8dd6493..2fc384b 100644 --- a/examples/dut/Gemfile.lock +++ b/examples/dut/Gemfile.lock @@ -3,11 +3,11 @@ GEM specs: addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - json (2.3.0) + json (2.3.1) nethttputils (0.4.0.0) addressable public_suffix (4.0.5) - reddit_bot (1.7.5) + reddit_bot (1.7.6) json nethttputils (~> 0.4.0.0) diff --git a/examples/dut/main.rb b/examples/dut/main.rb index 4b7de7e..681b56d 100644 --- a/examples/dut/main.rb +++ b/examples/dut/main.rb @@ -4,6 +4,11 @@ twitter = RedditBot::Twitter.init_twitter "DUT_Tweets" loop do + bot.json(:get, "/message/unread")["data"]["children"].each do |msg| + next unless %w{ nakilon technomod }.include? msg["data"]["author"] + abort "ordered to die" if %w{ die die } == msg["data"].values_at("subject", "body") + end + id = bot.new_posts.find do |post| /\(https:\/\/twitter\.com\/#{RedditBot::Twitter::TWITTER_ACCOUNT}\/status\/(\d{18,})\)/i =~ post["selftext"] and break $1 end.to_i diff --git a/examples/unisa/Gemfile.lock b/examples/unisa/Gemfile.lock index 8e45d95..eaff03e 100644 --- a/examples/unisa/Gemfile.lock +++ b/examples/unisa/Gemfile.lock @@ -4,11 +4,11 @@ GEM addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) byebug (11.0.1) - json (2.3.0) + json (2.3.1) nethttputils (0.4.0.0) addressable public_suffix (4.0.5) - reddit_bot (1.7.5) + reddit_bot (1.7.6) json nethttputils (~> 0.4.0.0) diff --git a/examples/unisa/main.rb b/examples/unisa/main.rb index c209ab0..5e2be50 100644 --- a/examples/unisa/main.rb +++ b/examples/unisa/main.rb @@ -4,6 +4,11 @@ twitter = RedditBot::Twitter.init_twitter "unisa" loop do + bot.json(:get, "/message/unread")["data"]["children"].each do |msg| + next unless %w{ nakilon technomod }.include? msg["data"]["author"] + abort "ordered to die" if %w{ die die } == msg["data"].values_at("subject", "body") + end + id = bot.new_posts.find do |post| /\(https:\/\/twitter\.com\/#{RedditBot::Twitter::TWITTER_ACCOUNT}\/status\/(\d{18,})\)/i =~ post["selftext"] and break $1 end.to_i