diff --git a/README.md b/README.md index ac537d9..b8e1d23 100644 --- a/README.md +++ b/README.md @@ -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 - [**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 is a XMPP transport diff --git a/constants.py.sample b/constants.py.sample index 958c2e9..9aa7f0e 100644 --- a/constants.py.sample +++ b/constants.py.sample @@ -22,13 +22,8 @@ __status__ = "Prototype" along with transWhat. If not, see . """ -DB_HOST = "localhost" -DB_USER = "" -DB_PASS = "" -DB_TABLE = "transwhat" - BASE_PATH = "/opt/transwhat" TOKEN_FILE = BASE_PATH + "/logs/tokens" MOTD_FILE = BASE_PATH + "/conf/motd" -REQUESTS_FILE = BASE_PATH + "/logs/requests" \ No newline at end of file +REQUESTS_FILE = BASE_PATH + "/logs/requests" diff --git a/session.py b/session.py index 074cbdf..ac87258 100644 --- a/session.py +++ b/session.py @@ -28,7 +28,6 @@ import urllib import time from PIL import Image -import MySQLdb import sys import os @@ -57,14 +56,11 @@ class MsgIDs: class Session(YowsupApp): - def __init__(self, backend, user, legacyName, extra, db): + def __init__(self, backend, user, legacyName, extra): super(Session, self).__init__() self.logger = logging.getLogger(self.__class__.__name__) 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.user = user self.legacyName = legacyName diff --git a/transwhat.py b/transwhat.py index 281398a..23fe84a 100755 --- a/transwhat.py +++ b/transwhat.py @@ -29,7 +29,6 @@ import traceback import logging import asyncore import sys, os -import MySQLdb import e4u import threading import Queue @@ -75,10 +74,9 @@ def connectionClosed(): closed = True # Main -db = MySQLdb.connect(DB_HOST, DB_USER, DB_PASS, DB_TABLE) 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) diff --git a/whatsappbackend.py b/whatsappbackend.py index 8761599..6c0d9aa 100644 --- a/whatsappbackend.py +++ b/whatsappbackend.py @@ -30,11 +30,10 @@ from session import Session import logging class WhatsAppBackend(SpectrumBackend): - def __init__(self, io, db, spectrum_jid): + def __init__(self, io, spectrum_jid): SpectrumBackend.__init__(self) self.logger = logging.getLogger(self.__class__.__name__) self.io = io - self.db = db self.sessions = { } self.spectrum_jid = spectrum_jid # Used to prevent duplicate messages @@ -46,7 +45,7 @@ class WhatsAppBackend(SpectrumBackend): def handleLoginRequest(self, user, legacyName, password, extra): self.logger.debug("handleLoginRequest(user=%s, legacyName=%s)", user, legacyName) 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: self.lastMessage[user] = {}