forked from bntzio/whatsapp-debt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR bntzio#1 Basic Restructure & Authentication handling, Message Form…
…atting, And Basic Sending
- Loading branch information
Showing
7 changed files
with
404 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"default_xpath_text_area": "//footer/div/div[2]/div/div[2]", | ||
"default_xpath_authenticated": "//*[text() = 'Keep your phone connected']", | ||
"default_xpath_searchbar":"//div[@id='side']/div/div/label/div/div[2]", | ||
"default_xpath_send_button":"/html/body/div[1]/div/div/div[4]/div/footer/div[1]/div[3]/button", | ||
"default_xpath_target_user":"//span[contains(.,'%s')]", | ||
"control_user": {"user":"Enrique","currency_format":"$","bank_account":"4531-2321-3421-3421"}, | ||
"kill_on_auth":"0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
## Glossary | ||
|
||
whatsapp_debt_framework : | ||
Arguments | ||
- production - Optional | Default : True | ||
- message - Required - Raises ValueError if None example : Invalid Message Can Not Be None, Empty, or Null! | ||
- debug - Optional - Default True - Turns Verbose on | ||
- debug_data - Optional - Default False - Switches from database mode to importing json data from debtor_data.json | ||
|
||
Public methods: | ||
- self.production - | ||
- self.url_bin - | ||
- self.notice - | ||
- self.msg_count - | ||
|
||
Private methods: | ||
- self.queue - | ||
- self._kill_on_auth - | ||
- self._default_xpath_text_area - | ||
- self._default_xpath_authenticated - | ||
- self._callbacks - | ||
- self._control_user - | ||
|
||
Public Functions: | ||
- self.collect - | ||
Arguments | ||
- | ||
Returns | ||
- | ||
|
||
- self.authenticate | ||
Arguments | ||
- None | ||
|
||
Returns | ||
- | ||
|
||
- self.connect - # Depreciated | ||
Arguments | ||
-None | ||
|
||
Returns | ||
- | ||
|
||
- self.get_message - | ||
Arguments | ||
-target_data - required list(target,amount) Strict | ||
-message - Optional -Type: Str - Has preset text if left default - Default : 'default.upper()' | ||
|
||
Returns | ||
- | ||
|
||
Private Functions: | ||
- self._logit - | ||
Arguments | ||
- log_text - Required - Type: Str | ||
- verbose - Optional - Default False - Print or just Return logs (T/F) Overridden by self.debug | ||
Returns | ||
- | ||
- self._set_chrome_options - Sets browser to headless and screen size to 1920x1080 Mac OSX headers | ||
Arguments | ||
- None | ||
Returns | ||
- | ||
## About | ||
Payment Gateways: | ||
- N/A | ||
|
||
|
||
<br/> | ||
|
||
## Usage | ||
|
||
Using the whats app debt framework is very straight forward. | ||
|
||
example : | ||
|
||
TARGETS = {'name': amount} # yep it is that easy, format the debtor and the value here and run! | ||
whatsapp_debt_framework().start(targets=TARGETS) | ||
|
||
name = str | ||
amount = int | ||
|
||
calling start() will automatically open an instance of chrome and request you scan the qr code for your whatsapp on your phone. | ||
Once authenticated the framework will continue through your dictionary of 'TARGETS' and send a message to each debtor about the amount using a default message, if you want to personalize what message goes into the chat windows, refer to the following example: | ||
|
||
|
||
TARGETS = {'name': amount} # yep it is that easy, format the debtor and the value here and run! | ||
message = '{name} Don't forget you have an outstanding balance with Apple for {amount}' | ||
whatsapp_debt_framework().start(targets=TARGETS,message=message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from whatsapp_framework import whatsapp_debt_framework | ||
import schedule | ||
import time | ||
|
||
# pip install scheduler | ||
|
||
TARGETS = {'GAGAN-DEV': 10} # yep it is that easy, format the debtor and the value here and run! | ||
|
||
|
||
def job(): | ||
return whatsapp_debt_framework()._logit(f'Running Job...'),whatsapp_debt_framework().start(targets=TARGETS) | ||
|
||
schedule.every().day.at('15:16').do(job) #24hr format | ||
|
||
whatsapp_debt_framework()._logit(f'Waiting for Scheduled Jobs to Trigger...') | ||
while True: | ||
schedule.run_pending() | ||
time.sleep(1) # reduce CPU load with a wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from whatsapp_framework import whatsapp_debt_framework | ||
|
||
|
||
# pip install scheduler | ||
|
||
TARGETS = {'GAGAN-DEV': 10} # yep it is that easy, format the debtor and the value here and run! | ||
whatsapp_debt_framework().start(targets=TARGETS) |
Oops, something went wrong.