SMS_HOST 89 113 17 SMS_PORT 2775 SMS_SYSTEM_ID staropramen SMS_PASSWOR

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
SMS_HOST = '89.113.17.4'
SMS_PORT = '2775'
SMS_SYSTEM_ID = 'staropramen'
SMS_PASSWORD = 'koo9Poov'
def run_smpp_sender(parts, client, encoding_flag, msg_type_flag):
for part in parts:
print part
pdu = client.send_message(
source_addr_ton=smpplib.consts.SMPP_TON_INTL,
#source_addr_npi=smpplib.consts.SMPP_NPI_ISDN,
source_addr='4441',
dest_addr_ton=smpplib.consts.SMPP_TON_INTL,
#dest_addr_npi=smpplib.consts.SMPP_NPI_ISDN,
destination_addr='+79312155803', # change phone
short_message=part,
data_coding=encoding_flag,
esm_class=msg_type_flag,
registered_delivery=True,
)
@task
def run_smpp_listener():
logging.basicConfig(level='DEBUG')
parts, encoding_flag, msg_type_flag = smpplib.gsm.make_parts(u'SPtest Привет мир 321!\n')
client = smpplib.client.Client(SMS_HOST, SMS_PORT)
client.connect()
client.bind_transceiver(system_id=SMS_SYSTEM_ID, password=SMS_PASSWORD)
while True:
# Слушаем
try:
client.listen()
# При получени входящего смс отправляем ответ
except:
print 'start except'
p = client.read_pdu()
print 'read_pdu'
print p
run_smpp_sender(parts, client, encoding_flag, msg_type_flag)