Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def requirements():

setup(
name='smsactivateru',
version='1.2.6',
version='1.0.3',
long_description=long_description(),
long_description_content_type='text/markdown',
description='Wrapper for automatic reception of SMS-messages by sms-activate.ru',
Expand Down
6 changes: 3 additions & 3 deletions smsactivateru/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from .sms import Sms
from .datatype import SmsTypes
from .actions import GetBalance, GetFreeSlots, GetNumber, SetStatus, GetStatus
from .actions import GetBalance, GetFreeSlots, GetNumber,GetFullSms, SetStatus, GetStatus
from .services import SmsService
from .activations import SmsActivation

__author__ = 'tezmen'
__version__ = '1.0'
__contact__ = 'https://t.me/tezmen'
__version__ = '1.0.3'
__contact__ = 'https://t.me/tezmen'
26 changes: 24 additions & 2 deletions smsactivateru/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def request(self, wrapper):
"""
response = wrapper.request(self)
return self.__response_processing(response, wrapper=wrapper)


class GetStatus(ActionsModel):
_name = 'getStatus'
Expand All @@ -78,7 +78,29 @@ def __init__(self, id):

@error_handler
def __response_processing(self, response):
data = {'status': response, 'code': None}
data = {'status': response, 'code': None, 'response':response}
if ':' in response:
data['status'] = response.split(':', 1)[0]
data['code'] = response.split(':', 1)[1]
return data

def request(self, wrapper):
"""
:rtype: dict
"""
response = wrapper.request(self)
return self.__response_processing(response)


class GetFullSms(ActionsModel):
_name = 'getFullSms'

def __init__(self, id):
super().__init__(inspect.currentframe())

@error_handler
def __response_processing(self, response):
data = {'status': response, 'code': None, 'response':response}
if ':' in response:
data['status'] = response.split(':', 1)[0]
data['code'] = response.split(':', 1)[1]
Expand Down
194 changes: 116 additions & 78 deletions smsactivateru/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,90 +5,128 @@


class SmsActivation:
"""
This is simple worker!
For hand-settings any other params – check /example/custom.py
"""
"""
This is simple worker!
For hand-settings any other params – check /example/custom.py
"""

def __init__(self, activation_id, number, wrapper):
self.__id = activation_id
self.__number = number
self.__wrapper = wrapper
self.__last_code = str()
def __init__(self, activation_id, number, wrapper):
self.__id = activation_id
self.__number = number
self.__wrapper = wrapper
self.__last_code = str()

def cancel(self):
set_status = smsactivateru.SetStatus(
id=self.__id,
status=smsactivateru.SmsTypes.Status.Cancel
)
if self.wrapper:
return set_status.request(self.wrapper)
return set_status
def cancel(self):
set_status = smsactivateru.SetStatus(
id=self.__id,
status=smsactivateru.SmsTypes.Status.Cancel
)
if self.wrapper:
return set_status.request(self.wrapper)
return set_status

def mark_as_used(self):
set_status = smsactivateru.SetStatus(
id=self.__id,
status=smsactivateru.SmsTypes.Status.AlreadyUsed
)
if self.wrapper:
return set_status.request(self.wrapper)
return set_status
def mark_as_used(self):
set_status = smsactivateru.SetStatus(
id=self.__id,
status=smsactivateru.SmsTypes.Status.AlreadyUsed
)
if self.wrapper:
return set_status.request(self.wrapper)
return set_status

def was_sent(self):
set_status = smsactivateru.SetStatus(
id=self.__id,
status=smsactivateru.SmsTypes.Status.SmsSent
)
if self.wrapper:
return set_status.request(self.wrapper)
return set_status
def was_sent(self):
set_status = smsactivateru.SetStatus(
id=self.__id,
status=smsactivateru.SmsTypes.Status.SmsSent
)
if self.wrapper:
return set_status.request(self.wrapper)
return set_status

def wait_code(self, timeout=1200, callback=None, not_end=False, *args, **kwargs):
"""
:param wrapper: obj for work with sms-activate
:param timeout: timeout waiting of code from sms in secs. 1200 - 20 min, this is max time of a live session.
:param callback: function for eval before getting code
:param not_end:
:return: str
"""
counter = 0
while True:
time.sleep(1)
counter += 1
if counter >= timeout:
raise ('Timeout error')
response = smsactivateru.GetStatus(id=self.id).request(self.wrapper)
if response['code'] and not not_end and response['code'] != self.last_code:
self.__last_code = response['code']
smsactivateru.SetStatus(
id=self.id,
status=smsactivateru.SmsTypes.Status.End
).request(self.wrapper)
break
elif response['code'] and not_end and response['code'] != self.last_code:
self.__last_code = response['code']
smsactivateru.SetStatus(
id=self.id,
status=smsactivateru.SmsTypes.Status.OneMoreCode
)
break
if callback:
callback(self.last_code)
else:
return self.last_code
def wait_code(self, timeout=1200, callback=None, not_end=False, *args, **kwargs):
"""
:param wrapper: obj for work with sms-activate
:param timeout: timeout waiting of code from sms in secs. 1200 - 20 min, this is max time of a live session.
:param callback: function for eval before getting code
:param not_end:
:return: str
"""
counter = 0
while True:
time.sleep(1)
counter += 1
if counter >= timeout:
raise ('Timeout error')
response = smsactivateru.GetStatus(id=self.id).request(self.wrapper)
if not response['code'] and response['status'] == "STATUS_OK":
response = smsactivateru.GetFullSms(id=self.id).request(self.wrapper)
if response['code'] and not not_end and response['code'] != self.last_code:
self.__last_code = response['code']
smsactivateru.SetStatus(
id=self.id,
status=smsactivateru.SmsTypes.Status.End
).request(self.wrapper)
break
elif response['code'] and not_end and response['code'] != self.last_code:
self.__last_code = response['code']
smsactivateru.SetStatus(
id=self.id,
status=smsactivateru.SmsTypes.Status.OneMoreCode
).request(self.wrapper)
break
if callback:
callback(self.last_code.strip())
else:
return self.last_code.strip()

@property
def id(self):
return self.__id
def wait_text(self, timeout=1200, callback=None, not_end=False, *args, **kwargs):
"""
:param wrapper: obj for work with sms-activate
:param timeout: timeout waiting of code from sms in secs. 1200 - 20 min, this is max time of a live session.
:param callback: function for eval before getting code
:param not_end:
:return: str
"""
counter = 0
while True:
time.sleep(1)
counter += 1
if counter >= timeout:
raise ('Timeout error')
response = smsactivateru.GetStatus(id=self.id).request(self.wrapper)
if response['status'] == "STATUS_OK":
response = smsactivateru.GetFullSms(id=self.id).request(self.wrapper)
if response['code'] and not not_end and response['code'] != self.last_code:
self.__last_code = response['code']
smsactivateru.SetStatus(
id=self.id,
status=smsactivateru.SmsTypes.Status.End
).request(self.wrapper)
break
elif response['code'] and not_end and response['code'] != self.last_code:
self.__last_code = response['code']
smsactivateru.SetStatus(
id=self.id,
status=smsactivateru.SmsTypes.Status.OneMoreCode
).request(self.wrapper)
break
if callback:
callback(self.last_code.strip())
else:
return self.last_code.strip()

@property
def phone_number(self):
return self.__number
@property
def id(self):
return self.__id

@property
def wrapper(self):
return self.__wrapper
@property
def phone_number(self):
return self.__number

@property
def last_code(self):
return self.__last_code
@property
def wrapper(self):
return self.__wrapper

@property
def last_code(self):
return self.__last_code
28 changes: 25 additions & 3 deletions smsactivateru/datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class Country:
MM = '5' # Мьянма (Myanmar)
ID = '6' # Индонезия (Indonesia)
MY = '7' # Малайзия (Malaysia)
# KE = '8' # Кения (Kenya) – temp disable
# TZ = '9' # Танзания (Tanzania) – temp disable
KE = '8' # Кения (Kenya) – temp disable
TZ = '9' # Танзания (Tanzania) – temp disable
VN = '10' # Вьетнам (Vietnam)
KG = '11' # Кыргызстан (Kyrgyzstan)
US = '12' # США (USA)
US_VIRT = '12' # США ВИРТ (USA)
IL = '13' # Израиль (Israel)
HK = '14' # Гонконг (Hong Kong)
PL = '15' # Польша (Poland)
Expand Down Expand Up @@ -49,6 +49,28 @@ class Country:
HR = '45' # Хорватия ( Croatia)
IQ = '47' # Ирак (Iraq)
NL = '48' # Нидерланды (Netherlands)
TH = '52' # Таиланд (Thailand)
SA = '53' # Саудовская Аравия (Saudi Arabia)
MX = '54' # Мексика (Mexico)
TW = '55' # Тайвань (Taiwan)
ES = '56' # Испания (Spain)
IR = '57' # Иран (Iran)
DZ = '58' # Алжир (Algeria)
SI = '59' # Словения (Slovenia)
BD = '60' # Бангладеш (Bangladesh)
SN = '61' # Сенегал (Senegal)
TR = '62' # Турция (Turkey)
CZ = '63' # Чехия (Czechia)
LK = '64' # Шри-Ланка (Sri Lanka)
PE = '65' # Перу (Peru)
PK = '66' # Пакистан (Pakistan)
NZ = '67' # Новая Зеландия (New Zealand)
GN = '68' # Гвинея (Guinea)
ML = '69' # Мали (Mali)
VE = '70' # Венесуэла (Venezuela)
ET = '71' # Эфиопия (Ethiopia)
BR = '73'
US = '187' # США


class Status:
Expand Down
16 changes: 15 additions & 1 deletion smsactivateru/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ServiceStorage:
'Messenger': 'uk_0', 'LineMessenger': 'me_0', 'Yahoo': 'mb_0', 'DrugVokrug': 'we_0', 'FiveOrochka': 'bd_0',
'TencentQQ': 'kp_0', 'WOG': 'dt_0', 'Yandex': 'ya_0', 'YandexSmsForwarding': 'ya_1', 'Steam': 'mt_0',
'Tinder': 'oi_0', 'Mamba': 'fd_0', 'DromRu': 'zz_0', 'KakaoTalk': 'kt_0', 'AOL': 'pm_0', 'LinkedIN': 'tn_0',
'DeliveryClub': 'dt_0',
'DeliveryClub': 'dt_0', 'Craigslist': 'wc_0', 'Offerup': 'zm_0'
}


Expand Down Expand Up @@ -56,6 +56,13 @@ def Viber(self):
"""
return self._Viber

@property
def Craigslist(self):
"""
:rtype: smsactivateru.models.ServiceModel
"""
return self._Craigslist

@property
def Telegram(self):
"""
Expand Down Expand Up @@ -273,6 +280,13 @@ def Steam(self):
"""
return self._Steam

@property
def Offerup(self):
"""
:rtype: smsactivateru.models.ServiceModel
"""
return self._Offerup

@property
def Tinder(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion smsactivateru/sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Sms:
def __init__(self, api_key):
self.key = api_key
self.url = 'http://sms-activate.ru/stubs/handler_api.php'
self.url = 'https://api.sms-activate.org/stubs/handler_api.php'

def request(self, action):
try:
Expand Down