yowsup icon indicating copy to clipboard operation
yowsup copied to clipboard

Problems with "/lastseen" command

Open alegr3 opened this issue 12 years ago • 8 comments

Hello,

I have been using this python library to get the last seen hour of a contact. It had worked fine since November but recently it has been some errors.

When I use the /lastseen command I get a response only the first time and then It doesnt work for 5 minutes (more or less).

Has something changed? Can anyone help me?

Thank you (and sorry for my awful English level)

alegr3 avatar Jul 03 '14 17:07 alegr3

Nice to see spanish people ;) So, it prints only once the 'last seen' time, right? Post the error/debug you had, and ill try to make a fix

mgp25 avatar Jul 03 '14 22:07 mgp25

Hello, thanks for your answer.

It is not an error, It just prints the connection hour the first time I execute my script. If I stop it and then I play it again, Yowsup gets frozen (coz it doesnt print anything).

I have modified the "CmdClient.py" to get automatically the /lastseen and It worked so well but nowadays I'm having this trouble. That's why I'm asking for help if something has changed because it's strange.

alegr3 avatar Jul 04 '14 10:07 alegr3

--> #290

mgp25 avatar Jul 04 '14 11:07 mgp25

alegr3, Ya solucionaste tu problema? pasa un mail asi te escribo

elrodrix avatar Jul 06 '14 00:07 elrodrix

De momento, sin haber cambiado nada, vuelve a funcionar. Eso sí, las horas de conexión son muy imprecisas...

Si quieres puedes contactarme en: [email protected]

alegr3 avatar Jul 07 '14 13:07 alegr3

валенок ушанка wazapp медведь балалайка yowsup водка зима whatsapp сибирь колыма lastseen

CODeRUS avatar Jul 07 '14 13:07 CODeRUS

I'm sorry but I can't understand you @CODeRUS. Where are you from?

alegr3 avatar Jul 07 '14 13:07 alegr3

sigh ...

#!/usr/bin/python

import argparse, sys, os, csv
from Yowsup.Common.utilities import Utilities
from Yowsup.Common.debugger import Debugger
from Yowsup.Common.constants import Constants
from Yowsup.Contacts.contacts import WAContactsSyncRequest
from Yowsup.connectionmanager import YowsupConnectionManager

import threading,time, base64

########## DO NOT COMMIT THIS FILE WITH YOUR CREDENTIALS ###########
#.....................WhatsApp Account Config.......................

nickname = ""
username = ""
password = ""
id = ""
# Degug is False by default if you add -d you will set it to True
target = ["34123456789", "34987654321"]

#....................................................................

password = base64.b64decode(bytes(password.encode('utf-8')))
jid = range(len(target))
for x in range(0, len(target)):
    jid[x] = "%[email protected]" % target[x]
Debugger.enabled = True if '-d' in sys.argv else False

def login(username, password):
    print "[] Logging in as %s (%s)\n" % (nickname, username)
    methodsInterface.call("auth_login", (username, password))

def send(jid, msg):
    methodsInterface.call("message_send", (jid, msg))

def onAuthSuccess(username):
    print("Authed!!\n\n")
    methodsInterface.call("ready")
    methodsInterface.call("presence_sendAvailableForChat", (nickname,))
    methodsInterface.call("presence_sendAvailable")
    for x in range(0, len(target)):
        methodsInterface.call("presence_request", (jid[x],))
    t = 5
    i = 0
    while i < t:
        time.sleep(0.5)
        i=i+1

def onAuthFailed(username, err):
    print("Auth Failed!")

def onPresenceUpdated(jid, lastSeen):
        print time.strftime("Ultima vez en linea hace: %H horas %M minutos", time.gmtime(lastSeen))


########################### BIND EVENTS #############################   
connectionManager = YowsupConnectionManager()
signalsInterface = connectionManager.getSignalsInterface()
methodsInterface = connectionManager.getMethodsInterface()
connectionManager.setAutoPong(True)

signalsInterface.registerListener("auth_success", onAuthSuccess)
signalsInterface.registerListener("auth_fail", onAuthFailed)
signalsInterface.registerListener("presence_updated", onPresenceUpdated)
#####################################################################

login(username, password)

mgp25 avatar Jul 07 '14 13:07 mgp25