java - limit users in group chat of whatsapp by an android app -
i m trying developing app want monitor whatsapp group chat , limit users e.g max 5 users can join if 6th coming, ignore or remove inactive , add new user chat have no idea how can ? requires root acess or not? there api available ?
you can use yowsup python library. need setup separate whatsapp account logs whatsapp servers using library. account need "owner" of groups , need manage adding , removing users chat. code need monitor chat traffic figure out talking. code develop not need run time.
you need register listeners number of whatsapp events. of init code this:
class whatsappclient: def __init__(self): atexit.register(self.exitfunction) connectionmanager = yowsupconnectionmanager() connectionmanager.setautopong(true) self.signalsinterface = connectionmanager.getsignalsinterface() self.methodsinterface = connectionmanager.getmethodsinterface() self.signalsinterface.registerlistener("auth_success", self.onauthsuccess) self.signalsinterface.registerlistener("auth_fail", self.onauthfailed) self.signalsinterface.registerlistener("message_received", self.onmessagereceived) self.signalsinterface.registerlistener("receipt_messagesent", self.onmessagesent) self.signalsinterface.registerlistener("disconnected", self.ondisconnected) self.signalsinterface.registerlistener("group_messagereceived", self.ongroup_messagereceived) self.signalsinterface.registerlistener("notification_groupparticipantadded", self.onnotification_groupparticipantadded) self.signalsinterface.registerlistener("notification_groupparticipantremoved", self.onnotification_groupparticipantremoved) self.signalsinterface.registerlistener("group_gotinfo", self.ongroup_gotinfo) self.signalsinterface.registerlistener("group_gotparticipants", self.ongroup_gotparticipants) self.signalsinterface.registerlistener("group_subjectreceived", self.ongroup_subjectreceived) self.signalsinterface.registerlistener("notification_grouppictureupdated", self.onnotification_grouppictureupdated) self.signalsinterface.registerlistener("group_setsubjectsuccess", self.ongroup_setsubjectsuccess) self.signalsinterface.registerlistener("group_createsuccess", self.ongroup_createsuccess) self.signalsinterface.registerlistener("group_createfail", self.ongroup_createfail) self.signalsinterface.registerlistener("group_endsuccess", self.ongroup_endsuccess) self.signalsinterface.registerlistener("group_addparticipantssuccess", self.ongroup_addparticipantssuccess) self.signalsinterface.registerlistener("group_removeparticipantssuccess", self.ongroup_removeparticipantssuccess)
some examples of method implementations above:
def ongroup_messagereceived(self, messageid, gjid, author, content, timestamp, receiptrequested, pushname): formatteddate = datetime.datetime.fromtimestamp(timestamp).strftime('%y-%m-%d %h:%m:%s') log("group message %s - %s (%s):%s"%(gjid, pushname, author, content)) if receiptrequested: self.methodsinterface.call("message_ack", (gjid, messageid)) # message.... def ongroup_addparticipantssuccess(self, gjid, jid): log ("participant added success g=%s j=%s " % (gjid, jid)) def ongroup_removeparticipantssuccess(self, gjid, jid): log ("participant removed success g=%s j=%s " % (gjid, jid))
Comments
Post a Comment