whatsapp_bot 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/whatsapp_bot.rb +48 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1821bd51b6f045e596c021be92df14a22dd4fa43df4215772b55f306cee9bba4
|
4
|
+
data.tar.gz: 8712f8a9531d546d882c7efe1c7c8c31c19bfefd6670c5689ccef9d1ea1a2249
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8d5d7b93043447f3154f69440a057b70482322508518e9cf5219d2c83677660aaede6a87f01c8e8e04dd107ae4db5db04b2391c7bd5eed55e2b46fed66b7424b
|
7
|
+
data.tar.gz: b75855bb3e6e55ee99d16ea9730d4b160cf5656abb4bd9f2f5af1d3cfb421b388895a71276c99675c9e6983f7bb591e9a8cc3c62517d65a9e23534dd0009e075
|
data/lib/whatsapp_bot.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "selenium-webdriver"
|
2
|
+
|
3
|
+
class WhatsappBot
|
4
|
+
URL = "https://web.whatsapp.com/"
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@driver = Selenium::WebDriver.for :chrome
|
8
|
+
@driver.get(URL)
|
9
|
+
@driver.find_element(css: '[name="rememberMe"]').click
|
10
|
+
@logged_in = false
|
11
|
+
end
|
12
|
+
|
13
|
+
def logged_in?
|
14
|
+
@logged_in
|
15
|
+
end
|
16
|
+
|
17
|
+
def try_logging_in
|
18
|
+
@driver.find_element(class: "landing-title")
|
19
|
+
@logged_in = false
|
20
|
+
puts "Please log in with your phone in the chrome driver"
|
21
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError => e
|
22
|
+
@logged_in = true
|
23
|
+
end
|
24
|
+
|
25
|
+
def send_message(to:, text:)
|
26
|
+
if (logged_in?)
|
27
|
+
return send_text_message(to, text)
|
28
|
+
else
|
29
|
+
if (try_logging_in)
|
30
|
+
return send_text_message(to, text)
|
31
|
+
end
|
32
|
+
puts "Not logged in"
|
33
|
+
return false
|
34
|
+
end
|
35
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError => e
|
36
|
+
puts "Couldnt find the user please check if name is correct or try again after some seconds"
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def send_text_message(to, text)
|
43
|
+
@driver.find_element(css: "[title='#{to}']").click
|
44
|
+
@driver.find_element(css: "[contenteditable='true']").send_keys(text)
|
45
|
+
@driver.find_element(css: 'span[data-icon="send"]').click
|
46
|
+
return @driver.find_elements(css: ".message-out").last.text.include?(text)
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: whatsapp_bot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mujadded Al Rabbani Alif
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-09-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This gem lets you send whatsapp message without using its api only whats
|
14
|
+
app web. It lets you log in with webdriver and then you can send message with your
|
15
|
+
app. It can help if you want to make a app that can send message but you dont want
|
16
|
+
to buy any app
|
17
|
+
email: mujadded.alif@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- lib/whatsapp_bot.rb
|
23
|
+
homepage: https://github.com/Mujadded/whatsapp_bot
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.7.6
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Send message in whatsapp without api
|
47
|
+
test_files: []
|