123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- import xmpp
- from xmpp import cli
- import config
- from BotClass import JabberBot
- import json
- import hashlib
- from datetime import datetime
- import time
- import threading
- import jsonAndRequest as jsreq
- global tasklist
- botname="open_negrequest_pending"
- operating_status=420
- JID=botname+"@"+config.JSERVER
- PORT=config.PORT
- PASSWORD=hashlib.md5((botname+config.PASSWORD).encode('utf-8')).hexdigest()
- print(JID, PASSWORD)
- listen_to=["open_negrequest_pending@ej.sharix-app.org"]
- proceed_to=["open_negrequest_pending@ej.sharix-app.org", "open_negrequest_declined@ej.sharix-app.org"]
- idle_value=10
- def message_handler(conn, mess):
- text = mess.getBody()
- user = mess.getFrom()
-
-
-
- print (str(user).split("/")[0])
- if (str(user).split("/")[0]) in listen_to:
- print(text)
- print(mess)
- if text is not None:
- orderObj = jsreq.jsonToOrderTicket(text)
- print (orderObj)
- tasklist.append(orderObj)
- bot.bot_log(str(datetime.now())+" Поступивший заказ успешно добавлен в очередь обработки\n")
- def pending_wait(period,localtask):
- bot.bot_log(botname+" "+str(datetime.now())+" "+"Заказ ожидает пользовательской реакции\n")
- time.sleep(period)
-
-
-
- bot.proceed_status(proceed_to[1],localtask)
- bot.bot_log(botname+" "+str(datetime.now())+" "+"Заказ отклонен\n")
- def open_negrequest_pending():
-
- while (len(tasklist)):
- localtask=tasklist.pop(0)
- bot.bot_log(botname + " " + datetime.now().strftime('%Y-%m-%d') + " "+ "Заказ в очереди на обработке\n")
-
-
-
-
-
-
-
-
- t1=threading.Thread(target=pending_wait, args=(100,localtask))
- t1.start()
-
-
-
-
- tasklist = []
- token = jsreq.requestGetToken(botname, PASSWORD, config.API_URL+"/auth/token/login/")
- tasklist=jsreq.requestGetList(token, config.API_URL+"/tickets/api/tickets/?status=210&list_id=10")
- print (len(tasklist))
- bot = JabberBot(JID, PASSWORD, PORT)
- bot.register_handler('message', message_handler)
- bot.start(open_negrequest_pending)
|