all the project copy
This commit is contained in:
138
telepot/filter.py
Normal file
138
telepot/filter.py
Normal file
@@ -0,0 +1,138 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT_DIR = Path(__file__).resolve().parents[1]
|
||||
for path in (ROOT_DIR / "api", ROOT_DIR / "conn"):
|
||||
if str(path) not in sys.path:
|
||||
sys.path.insert(0, str(path))
|
||||
|
||||
import filters
|
||||
import mysql5
|
||||
|
||||
|
||||
competenze = ""
|
||||
|
||||
|
||||
|
||||
'''Returns all the competences from db'''
|
||||
def get_competences():
|
||||
docList = mysql5.getCompetences()
|
||||
competenze1 = ""
|
||||
competenze2 = ""
|
||||
docSize = 0
|
||||
for i in docList:
|
||||
docSize +=1
|
||||
id_c = int(i[0])
|
||||
|
||||
if id_c < 0:
|
||||
id_c = str( "_" + str(id_c)[1:] )
|
||||
else:
|
||||
id_c = str(id_c)
|
||||
|
||||
competence = str(i[1])
|
||||
|
||||
if docSize > 80:
|
||||
competenze2 += competence + " " + "/_id_c_" + id_c + "\n"
|
||||
else:
|
||||
competenze1 += competence + " " + "/_id_c_" + id_c + "\n"
|
||||
|
||||
return competenze1, competenze2
|
||||
|
||||
|
||||
def get_products():
|
||||
docList = mysql5.getProducts()
|
||||
productrs = ""
|
||||
print("lista:", docList)
|
||||
for i in docList:
|
||||
productrs += str(i[1]) + " " + "/_id_p_" + str(i[0]) + "\n"
|
||||
print(productrs)
|
||||
return productrs
|
||||
|
||||
def get_areas():
|
||||
area_list = mysql5.get_areas()
|
||||
areas = ""
|
||||
print("lista:", area_list)
|
||||
for i in area_list:
|
||||
areas += " " + str(i[2]) + " "+ "/_id_area_" + str(i[0]) + "\n"
|
||||
print(areas)
|
||||
return areas
|
||||
|
||||
def get_sub_areas(tid):
|
||||
|
||||
# Fetch the saved areas for the user tid.
|
||||
sub_areas = filters.get_area_from_tid(tid)
|
||||
if len(sub_areas) < 1:
|
||||
return "Non esiste Area per la sottoarea selezionata. Inserire prima l'area"
|
||||
|
||||
s_area_list = []
|
||||
seen_sub_area_ids = set()
|
||||
for area in sub_areas:
|
||||
for sub_area in mysql5.get_sub_areas(area[0]):
|
||||
if sub_area[0] in seen_sub_area_ids:
|
||||
continue
|
||||
seen_sub_area_ids.add(sub_area[0])
|
||||
s_area_list.append(sub_area)
|
||||
|
||||
s_areas = ""
|
||||
print("lista:", s_area_list)
|
||||
for i in s_area_list:
|
||||
s_areas += " " + str(i[1]) + " "+ "/_id_suba_" + str(i[0]) + "\n"
|
||||
print(s_areas)
|
||||
return s_areas
|
||||
|
||||
|
||||
|
||||
def decodeCompetence(cid,docList):
|
||||
for i in docList:
|
||||
if str(i['id']).strip() == cid:
|
||||
return str(i['label']).strip()
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
def getMyFilters(tid):
|
||||
mylist = filters.getFilters(tid)
|
||||
listFilterAsString= ""
|
||||
for i in mylist:
|
||||
tipo = ""
|
||||
if str(i[2]) == "C":
|
||||
tipo = "Competenza"
|
||||
elif str(i[2]) == 'P':
|
||||
tipo = "Prodotto"
|
||||
elif str(i[2]) == 'A':
|
||||
tipo = "Area"
|
||||
elif str(i[2]) == 'S':
|
||||
tipo = "Sottoarea"
|
||||
listFilterAsString += tipo + ": (" + str(i[3]) + ") " + mysql5.getProductOrCompetence(str(i[2]), str(i[3]))[0][0] + "\n"
|
||||
return listFilterAsString
|
||||
|
||||
|
||||
def showFilterToBeDelete(tid):
|
||||
mylist = filters.getFilters(tid)
|
||||
listFilterAsString= ""
|
||||
for i in mylist:
|
||||
tipo = ""
|
||||
if str(i[2]) == "C":
|
||||
tipo = "Competen"
|
||||
elif str(i[2]) == 'P':
|
||||
tipo = "Prodotto"
|
||||
elif str(i[2]) == 'A':
|
||||
tipo = "Area"
|
||||
elif str(i[2]) == 'S':
|
||||
tipo = "Sottoarea"
|
||||
listFilterAsString += "/" + tipo + "_id_cf_" + str(i[0]) + ") " + mysql5.getProductOrCompetence(str(i[2]), str(i[3]))[0][0] + "\n"
|
||||
return listFilterAsString
|
||||
|
||||
|
||||
|
||||
def deleteFilter(telid, fid):
|
||||
if filters.deleteFilter(telid, fid):
|
||||
return "Filtro cancellato con successo"
|
||||
else:
|
||||
return "Non è stato possibile cancella il tuo filtro, riprova piu tardi!"
|
||||
|
||||
|
||||
|
||||
# print(getMyFilters(145645559))
|
||||
#print(deleteFilter(145645559))
|
||||
# get_competence()
|
||||
BIN
telepot/gifs/welcome.gif
Normal file
BIN
telepot/gifs/welcome.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 865 KiB |
16
telepot/insertCompetence.py
Normal file
16
telepot/insertCompetence.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT_DIR = Path(__file__).resolve().parents[1]
|
||||
CONN_DIR = ROOT_DIR / "conn"
|
||||
if str(CONN_DIR) not in sys.path:
|
||||
sys.path.insert(0, str(CONN_DIR))
|
||||
|
||||
import filters
|
||||
|
||||
|
||||
def manageCompetence(tid,cid, sort):
|
||||
if filters.insertFilter(tid, sort, cid):
|
||||
return "Filtro inserito con successo"
|
||||
else:
|
||||
return "Filtro gia' esistente!"
|
||||
48
telepot/keyboards.py
Normal file
48
telepot/keyboards.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import telepot
|
||||
from telepot.loop import MessageLoop
|
||||
from telepot.namedtuple import InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardMarkup, KeyboardButton
|
||||
|
||||
|
||||
|
||||
|
||||
def getKeyboard():
|
||||
keyboard = ReplyKeyboardMarkup(
|
||||
keyboard=[
|
||||
[KeyboardButton(text="🖍 Crea filtro x Competenze")
|
||||
, KeyboardButton(text="📦 Crea filtro x Prodotto")
|
||||
,KeyboardButton(text="📌 I mie filtri")
|
||||
]
|
||||
,
|
||||
[
|
||||
KeyboardButton(text="✖ Cancella filtro")
|
||||
, KeyboardButton(text="👥 Crea filtro x Area")
|
||||
, KeyboardButton(text="👥 Crea filtro x Sott.Area")
|
||||
# KeyboardButton(text="🗂 Ticket ultimi 20")
|
||||
]
|
||||
,
|
||||
[
|
||||
KeyboardButton(text="💜 Preferiti")
|
||||
]
|
||||
]
|
||||
)
|
||||
return keyboard
|
||||
|
||||
|
||||
def getFilterKeyboard():
|
||||
keyboard = ReplyKeyboardMarkup(
|
||||
keyboard=[
|
||||
[KeyboardButton(text="+ Filtro x competenze")
|
||||
, KeyboardButton(text="+ Filtro x Cliente")
|
||||
]
|
||||
|
||||
]
|
||||
)
|
||||
return keyboard
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1060
telepot/tele.py
Normal file
1060
telepot/tele.py
Normal file
File diff suppressed because it is too large
Load Diff
17
telepot/test.py
Normal file
17
telepot/test.py
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
# 133
|
||||
|
||||
my_str = 'Possibile soluzione 3) : [ 🎫 /Ticket_dettaglio_353716 ] https://tsnew.sanmarcoweb.com/it/ticket/index/index/operation/view/id/353716'
|
||||
|
||||
my_str2 = 'SOLUZIONE [ Buongiorno Fabio, scrivo in merito al ticket in oggetto. Per sbloccare la provvigione intende togliere il "costo provvigione contabilizzato"? Dopo la mia modifica tramite SQL ha bisogno di reimpostarlo di nuovo? Attendo prima di procedere.'
|
||||
|
||||
|
||||
# print((500*5) + (len(my_str)*5))
|
||||
|
||||
|
||||
|
||||
my_str_main = "🔹"
|
||||
|
||||
|
||||
print(len(my_str_main))
|
||||
104
telepot/ticketToday.py
Normal file
104
telepot/ticketToday.py
Normal file
@@ -0,0 +1,104 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT_DIR = Path(__file__).resolve().parents[1]
|
||||
for path in (ROOT_DIR / "api", ROOT_DIR / "conn"):
|
||||
if str(path) not in sys.path:
|
||||
sys.path.insert(0, str(path))
|
||||
|
||||
import phrase_similarity
|
||||
import detailTicket
|
||||
import filters
|
||||
import tickets
|
||||
import mysql5
|
||||
|
||||
|
||||
HIGH_GRAVITY_WORDS = ("alta", "urgente", "critica", "critico", "bloccante", "grave", "high")
|
||||
|
||||
|
||||
def _is_high_gravity(value):
|
||||
text = str(value or "").strip().lower()
|
||||
return any(word in text for word in HIGH_GRAVITY_WORDS)
|
||||
|
||||
|
||||
|
||||
def getTicketToday(teleId):
|
||||
|
||||
listOfStrings = []
|
||||
listFilters = filters.getFilters(teleId)
|
||||
ticketAsString = ""
|
||||
for j in listFilters:
|
||||
|
||||
docList = mysql5.getTicket(j[2], j[3])
|
||||
ticketAsString = ""
|
||||
for i in docList:
|
||||
ticketAsString += "🎫 /Ticket_dettaglio_"+ str(i[0]) + "\n" +"🏢 Cliente: "+ str(i[1]) + "\n" +"🔎 Oggetto: "+ str(i[2])+ "\n" +"🎨 Gravita': "+ str(i[3])+ "\n" + "🧑 Competenza': "+ str(i[4])+ "\n" + "📅 Apertura': "+ str(i[6]) + "\n\n"
|
||||
if len(docList):
|
||||
# max char 4096
|
||||
listOfStrings.append(str(ticketAsString))
|
||||
return listOfStrings
|
||||
|
||||
|
||||
|
||||
def getTicketTodayForNotification(teleId, high_gravity_only=False):
|
||||
|
||||
listOfStrings = []
|
||||
listFilters = filters.getFilters(teleId)
|
||||
|
||||
# print("Lista di filtri: ",listFilters)
|
||||
# print("\n\n\n")
|
||||
|
||||
ticketTodayList = mysql5.getTicketsByFilterSet(listFilters)
|
||||
for i in ticketTodayList:
|
||||
if high_gravity_only and not _is_high_gravity(i[3]):
|
||||
continue
|
||||
|
||||
ticket_id = int(i[0])
|
||||
if len(tickets.getTicketForTid(teleId, ticket_id)) > 0:
|
||||
continue
|
||||
|
||||
object_ = str(i[2])
|
||||
if len(object_) > 250:
|
||||
object_ = object_[:250] + "..."
|
||||
ticketAsStringSingle = "🎫 /Ticket_dettaglio_"+ str(i[0]) + "\n https://tsnew.sanmarcoweb.com/it/ticket/index/index/operation/view/id/"+ str(i[0]) + "\n" +"🏢 Cliente: "+ str(i[1]) + "\n" +"🔎 Oggetto: "+ str(object_) + "\n" +"🎨 Gravita': "+ str(i[3])+ "\n" + "🧑 Competenza: "+ str(i[4])+ "\n" + "📦 Prodotto:" + str(i[5])+ "\n" + "💜/preferito_"+ str(i[0]) + "\n\n"
|
||||
for j in listFilters:
|
||||
if len(tickets.getTickets(int(j[0]), ticket_id)) == 0:
|
||||
tickets.insertTicket(int(j[0]), ticket_id)
|
||||
listOfStrings.append(str(ticketAsStringSingle))
|
||||
# print("Lista ticket finale:: ",len(listOfStrings))
|
||||
# print("\n\n\n")
|
||||
return listOfStrings
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def getDetailTicket(ticketId):
|
||||
downloaded = detailTicket.getDetail(str(ticketId))
|
||||
return downloaded
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# newTicketList = getTicketTodayForNotification(145645559)
|
||||
|
||||
# for ticket in newTicketList:
|
||||
# hole_message = ticket
|
||||
# # print("Messaggio: ", ticket)
|
||||
# # Guessing from other ticket
|
||||
# prefix = "🎫 /Ticket_dettaglio_"
|
||||
# ticket_value = ticket.split(prefix, 1)[-1].split("\n", 1)[0].strip()
|
||||
|
||||
# best_matches_indices = phrase_similarity.start_guessing_new(ticket_value)
|
||||
# for ticket_info in best_matches_indices:
|
||||
# # print("Gesing Ticket: ", str(ticket_info))
|
||||
# hole_message += str(ticket_info)
|
||||
|
||||
# hole_message += "\n\n\n\n"
|
||||
# print(hole_message)
|
||||
Reference in New Issue
Block a user