1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import requests
- 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="st_request_new"
- JID=botname+"@"+config.JSERVER
- PORT=config.PORT
- PASSWORD=hashlib.md5((botname+config.PASSWORD).encode('utf-8')).hexdigest()
- listen_to=["st_request_new@ej.sharix-app.org"]
- proceed_to=["numbers"]
- idle_value=10
- def status_new_process(ticket):
-
- tickets_new=jsreq.requestGetTicket_user(token, config.API_URL+f"tickets/api/ticket_list/{ticket.id}")
- for ticket_new in tickets_new:
- send_to_user(ticket_new)
- def send_to_user(ticket_new):
- user = jsreq.requestGetListUser(token)
- print(user.json()[0]['id'])
- headers = {'Authorization': f'Token {token}'}
- url = config.API_URL+f"tickets/api/ticket_list/{ticket_new.id}"
- if ticket_new.assigned_to == None:
- ticket_new.assigned_to = user.json()[0]['id']
- user = 'test@ej.sharix-app.org'
- print({'id':ticket_new.id, 'assigned_to' :ticket_new.assigned_to })
- response = requests.put(url, json={'id':ticket_new.id, 'assigned_to' :ticket_new.assigned_to }, headers=headers)
- print(response)
- if response:
- bot.send_notification(user,ticket_new)
- def status_new():
- while True:
- ticketlist=jsreq.requestGetList(token, config.API_URL+"tickets/api/ticket_list/")
- for ticket in ticketlist:
- bot.bot_log(botname + " " + datetime.now().strftime('%Y-%m-%d') + " "+ "Тикет отправлен в очередь на обработку\n")
- t1 = threading.Thread(target=status_new_process, args=(ticket,))
- t1.start()
- t1.join()
- time.sleep(300)
- ticketlist = []
- token = jsreq.requestGetToken(config.API_URL+"api/v1/auth/token/login/")
- bot = JabberBot(JID, PASSWORD, PORT)
- bot.start(status_new)
|