Commit b577f52e by Luciano Barletta

Expanded functionality, upgrades to software needed

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