Module: Actions
- Included in:
- Instabot
- Defined in:
- lib/instabot/actions.rb
Instance Method Summary collapse
- #comment(media_id, text = '') ⇒ Object
- #follow(user_id) ⇒ Object
- #like(media_id) ⇒ Object
- #unfollow(user_id) ⇒ Object
- #unlike(media_id) ⇒ Object
Instance Method Details
#comment(media_id, text = '') ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/instabot/actions.rb', line 46 def comment(media_id, text = '') log("trying to send a comment to media[#{media_id}]", 'ACTIONS') check_login_status url = "https://www.instagram.com/web/comments/#{media_id}/add/" set_mechanic_data(comment_text: text.to_s) response = @agent.post(url, @params, @headers) save_action_log media_id, :comment @local_stroage[:commented_medias] << media_id { media_id: media_id, response_code: response.code } end |
#follow(user_id) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/instabot/actions.rb', line 2 def follow(user_id) log("trying to follow a user [#{user_id}]", 'ACTIONS') check_login_status url = "https://www.instagram.com/web/friendships/#{user_id}/follow/" set_mechanic_data response = @agent.post(url, @params, @headers) save_action_log user_id, :follow @local_stroage[:followed_users] << user_id { user_id: user_id, response_code: response.code } end |
#like(media_id) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/instabot/actions.rb', line 24 def like(media_id) log("trying to like a media[#{media_id}]", 'ACTIONS') check_login_status url = "https://www.instagram.com/web/likes/#{media_id}/like/" set_mechanic_data response = @agent.post(url, @params, @headers) save_action_log media_id, :like @local_stroage[:liked_medias] << media_id { media_id: media_id, response_code: response.code } end |
#unfollow(user_id) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/instabot/actions.rb', line 13 def unfollow(user_id) log("trying to unfollow a user [#{user_id}]", 'ACTIONS') check_login_status url = "https://www.instagram.com/web/friendships/#{user_id}/unfollow/" set_mechanic_data response = @agent.post(url, @params, @headers) save_action_log user_id, :unfollow @local_stroage[:unfollowed_users] << user_id { user_id: user_id, response_code: response.code } end |
#unlike(media_id) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/instabot/actions.rb', line 35 def unlike(media_id) log("trying to unlike a media[#{media_id}]", 'ACTIONS') check_login_status url = "https://www.instagram.com/web/likes/#{media_id}/unlike/" set_mechanic_data response = @agent.post(url, @params, @headers) save_action_log media_id, :unlike @local_stroage[:unliked_medias] << media_id { media_id: media_id, response_code: response.code } end |