Remove all mention of MySQL database
This commit is contained in:
parent
c44baf892d
commit
17c8057db7
|
@ -10,7 +10,6 @@ transWhat is a WhatsApp XMPP Gateway based on [Spectrum 2](http://www.spectrum.i
|
||||||
|
|
||||||
- **e4u**: is a simple emoji4unicode python bindings
|
- **e4u**: is a simple emoji4unicode python bindings
|
||||||
- [**yowsup**](https://github.com/tgalal/yowsup): is a python library that enables you build application which use WhatsApp service.
|
- [**yowsup**](https://github.com/tgalal/yowsup): is a python library that enables you build application which use WhatsApp service.
|
||||||
- **mysqldb**: MySQL client python bindings
|
|
||||||
|
|
||||||
#### Spectrum 2
|
#### Spectrum 2
|
||||||
is a XMPP transport
|
is a XMPP transport
|
||||||
|
|
|
@ -22,13 +22,8 @@ __status__ = "Prototype"
|
||||||
along with transWhat. If not, see <http://www.gnu.org/licenses/>.
|
along with transWhat. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DB_HOST = "localhost"
|
|
||||||
DB_USER = ""
|
|
||||||
DB_PASS = ""
|
|
||||||
DB_TABLE = "transwhat"
|
|
||||||
|
|
||||||
BASE_PATH = "/opt/transwhat"
|
BASE_PATH = "/opt/transwhat"
|
||||||
|
|
||||||
TOKEN_FILE = BASE_PATH + "/logs/tokens"
|
TOKEN_FILE = BASE_PATH + "/logs/tokens"
|
||||||
MOTD_FILE = BASE_PATH + "/conf/motd"
|
MOTD_FILE = BASE_PATH + "/conf/motd"
|
||||||
REQUESTS_FILE = BASE_PATH + "/logs/requests"
|
REQUESTS_FILE = BASE_PATH + "/logs/requests"
|
||||||
|
|
|
@ -28,7 +28,6 @@ import urllib
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import MySQLdb
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -57,14 +56,11 @@ class MsgIDs:
|
||||||
|
|
||||||
class Session(YowsupApp):
|
class Session(YowsupApp):
|
||||||
|
|
||||||
def __init__(self, backend, user, legacyName, extra, db):
|
def __init__(self, backend, user, legacyName, extra):
|
||||||
super(Session, self).__init__()
|
super(Session, self).__init__()
|
||||||
self.logger = logging.getLogger(self.__class__.__name__)
|
self.logger = logging.getLogger(self.__class__.__name__)
|
||||||
self.logger.info("Created: %s", legacyName)
|
self.logger.info("Created: %s", legacyName)
|
||||||
|
|
||||||
#self.db = db
|
|
||||||
self.db = MySQLdb.connect(DB_HOST, DB_USER, DB_PASS, DB_TABLE)
|
|
||||||
|
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
self.user = user
|
self.user = user
|
||||||
self.legacyName = legacyName
|
self.legacyName = legacyName
|
||||||
|
|
|
@ -29,7 +29,6 @@ import traceback
|
||||||
import logging
|
import logging
|
||||||
import asyncore
|
import asyncore
|
||||||
import sys, os
|
import sys, os
|
||||||
import MySQLdb
|
|
||||||
import e4u
|
import e4u
|
||||||
import threading
|
import threading
|
||||||
import Queue
|
import Queue
|
||||||
|
@ -75,10 +74,9 @@ def connectionClosed():
|
||||||
closed = True
|
closed = True
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
db = MySQLdb.connect(DB_HOST, DB_USER, DB_PASS, DB_TABLE)
|
|
||||||
io = IOChannel(args.host, args.port, handleTransportData, connectionClosed)
|
io = IOChannel(args.host, args.port, handleTransportData, connectionClosed)
|
||||||
|
|
||||||
plugin = WhatsAppBackend(io, db, args.j)
|
plugin = WhatsAppBackend(io, args.j)
|
||||||
|
|
||||||
plugin.handleBackendConfig('features', 'send_buddies_on_login', 1)
|
plugin.handleBackendConfig('features', 'send_buddies_on_login', 1)
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,10 @@ from session import Session
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
class WhatsAppBackend(SpectrumBackend):
|
class WhatsAppBackend(SpectrumBackend):
|
||||||
def __init__(self, io, db, spectrum_jid):
|
def __init__(self, io, spectrum_jid):
|
||||||
SpectrumBackend.__init__(self)
|
SpectrumBackend.__init__(self)
|
||||||
self.logger = logging.getLogger(self.__class__.__name__)
|
self.logger = logging.getLogger(self.__class__.__name__)
|
||||||
self.io = io
|
self.io = io
|
||||||
self.db = db
|
|
||||||
self.sessions = { }
|
self.sessions = { }
|
||||||
self.spectrum_jid = spectrum_jid
|
self.spectrum_jid = spectrum_jid
|
||||||
# Used to prevent duplicate messages
|
# Used to prevent duplicate messages
|
||||||
|
@ -46,7 +45,7 @@ class WhatsAppBackend(SpectrumBackend):
|
||||||
def handleLoginRequest(self, user, legacyName, password, extra):
|
def handleLoginRequest(self, user, legacyName, password, extra):
|
||||||
self.logger.debug("handleLoginRequest(user=%s, legacyName=%s)", user, legacyName)
|
self.logger.debug("handleLoginRequest(user=%s, legacyName=%s)", user, legacyName)
|
||||||
if user not in self.sessions:
|
if user not in self.sessions:
|
||||||
self.sessions[user] = Session(self, user, legacyName, extra, self.db)
|
self.sessions[user] = Session(self, user, legacyName, extra)
|
||||||
|
|
||||||
if user not in self.lastMessage:
|
if user not in self.lastMessage:
|
||||||
self.lastMessage[user] = {}
|
self.lastMessage[user] = {}
|
||||||
|
|
Loading…
Reference in a new issue