|
|
|
@ -9,7 +9,7 @@ chatid_daniel = 220888832 |
|
|
|
|
|
|
|
|
|
# Configuration |
|
|
|
|
subreddit = "rarepuppers" |
|
|
|
|
chatid = chatid_joann |
|
|
|
|
chatid = chatid_daniel |
|
|
|
|
delay = 1.hours |
|
|
|
|
active_hours = 7..24 |
|
|
|
|
bot_token = "599474797:AAEmjQNO32uqurI16blS9FT4OoO7GdUZ6h0" |
|
|
|
@ -25,11 +25,12 @@ bot.command "ping" do |update, args| |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
bot.command "pupper" do |update, args| |
|
|
|
|
url = get_reddit_post(subreddit, completed) |
|
|
|
|
if url |
|
|
|
|
url_tuple = get_reddit_post(subreddit, completed) |
|
|
|
|
if url_tuple |
|
|
|
|
url, title = url_tuple |
|
|
|
|
command_chatid = update.message.as(Telepathy::Message).chat.id |
|
|
|
|
logger.info "Using URL #{url} for request from #{command_chatid}" |
|
|
|
|
bot.send_photo(command_chatid, url) |
|
|
|
|
bot.send_photo(command_chatid, url, title) |
|
|
|
|
else |
|
|
|
|
logger.error "Unable to find a post to send." |
|
|
|
|
end |
|
|
|
@ -38,10 +39,11 @@ end |
|
|
|
|
spawn do |
|
|
|
|
loop do |
|
|
|
|
time = Time.now |
|
|
|
|
url = get_reddit_post(subreddit, completed) if (active_hours.includes? time.hour) |
|
|
|
|
if url |
|
|
|
|
url_tuple = get_reddit_post(subreddit, completed) if (active_hours.includes? time.hour) |
|
|
|
|
if url_tuple |
|
|
|
|
url, title = url_tuple |
|
|
|
|
logger.info "Sending regular picture to #{chatid}." |
|
|
|
|
bot.send_photo(chatid.to_i64, url) |
|
|
|
|
bot.send_photo(chatid.to_i64, url, title) |
|
|
|
|
else |
|
|
|
|
logger.error "Unable to find a post to send. (Or it's quiet hours)" |
|
|
|
|
end |
|
|
|
|