Commit b577f52e by Luciano Barletta

Expanded functionality, upgrades to software needed

1 parent 957291d6
*.sh
*.db
*.pyc
__pycache__
\ No newline at end of file
*
!.py
!.md
!templates
\ No newline at end of file
......@@ -14,7 +14,7 @@ class DBconnection:
dir text,\
serv text CHECK( serv IN ('wpp1', 'wwp2', 'telegram', 'sms') ),\
dest text CHECK( LENGTH(dest) <= 13 ),\
type text CHECK( type IN ('text', 'file', 'multimedia') ),\
type text CHECK( type IN ('text', 'image', 'file', 'multimedia') ),\
state text CHECK( state IN ('delivered', 'queued') ) )")
# delivered messages that were informed
self.query("CREATE TABLE IF NOT EXISTS history(\
......@@ -22,7 +22,7 @@ class DBconnection:
dir text,\
serv text CHECK( serv IN ('wpp1', 'wwp2', 'telegram', 'sms') ),\
dest text CHECK( LENGTH(dest) <= 13 ),\
type text CHECK( type IN ('text', 'file', 'multimedia') ),\
type text CHECK( type IN ('text', 'image', 'file', 'multimedia') ),\
state text CHECK( state IN ('delivered', 'queued') ) )")
def query(self,query,*args):
......
import requests
import json
import os
from abc import ABC, abstractmethod
class Services:
......@@ -16,11 +17,20 @@ class Services:
class Datatypes:
text = "text"
image = "image"
document = "document"
link = "link"
@staticmethod
def validate(datatype):
if datatype == Datatypes.text:
return True
if datatype == Datatypes.image:
return True
if datatype == Datatypes.document:
return True
if datatype == Datatypes.link:
return True
return False
class ServiceBase(ABC):
......@@ -35,23 +45,29 @@ class ServiceBase(ABC):
class Wpp1(ServiceBase):
URL = "https://www.waboxapp.com/api/send/chat"
URL = "https://www.waboxapp.com/api/send/"
URLmode = {
Datatypes.text : 'chat',
Datatypes.image : 'image',
Datatypes.document : 'media',
Datatypes.link : 'link'
}
token = "fd378337aebead91c2eb25209aa51a7d5ce9754ea1718"
uid = "5493413674832"
server = "https://archivos.hgtsa.com.ar/"
def send(self,data):
file_path = "./" + data['dir'] + "/" + str(data['id'])
if data['type'] == Datatypes.text:
f = open("./" + data['dir'] + "/" + str(data['id']))
f = open(file_path)
text = f.read()
f.close()
result = requests.get(url = Wpp1.URL,params = {
'token':Wpp1.token,
'uid':Wpp1.uid,
'to':data['dest'],
'text':text
})
result = requests.get(url = Wpp1.URL + Wpp1.URLmode[data['type']],params = {'token':Wpp1.token,'uid':Wpp1.uid,'to':data['dest'],'text':text})
return result.json()['success']
else:
path = requests.post(url = Wpp1.server, files = { 'data' : (str(data['id']),open(file_path,'rb')) })
result = requests.get(url = Wpp1.URL + Wpp1.URLmode[data['type']],params = {'token':Wpp1.token,'uid':Wpp1.uid,'to':data['dest'],'url':Wpp1.server + path.text})
return result.json()['success']
return False
def validate(self,datatype):
return Datatypes.validate(datatype)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!