Esempio n. 1
0
		print contact.shown_name, contact.uin, GGStatuses.reverse_lookup_without_mask(contact.status), contact.description

def on_pubdir_recv_event_handler(sender, args):
	entry = request_to_dict(args.reply.split("\0\0")[0])
	contact = Contact({'uin':entry['FmNumber'], 'shown_name':entry['nickname']})
	sender.add_contact(contact)

if __name__ == "__main__":
	session = GGSession(uin = 11327271, password = '******')
	session.register('on_login_ok', login_ok_event_handler)
	session.register('on_msg_recv', msg_recv_event_handler)
	session.register('on_unknown_packet', on_unknown_packet_event_handler)
	session.register('on_userlist_reply', on_userlist_reply)
	session.register('on_pubdir_recv', on_pubdir_recv_event_handler)
	session.register('on_status_changed', on_status_changed)
        session.import_contacts_list("kontakty.txt")
	session.login()
	session.pubdir_request({'FmNumber':1308535})
	session.change_status(GGStatuses.AvailDescr, ':>')
	print "Dodaje kontakt"
	session.add_contact(Contact({'uin':3993939,'shown_name':'Ty'}))
	time.sleep(10)
	print "Zmiana typu - blokada"
	session.change_user_type(1308535, GGUserTypes.Blocked)
	session.change_user_type(3993939, GGUserTypes.Blocked)
	time.sleep(10)
	print "Zmiana typu - odblokowanie mnie"
	session.change_user_type(1308535, GGUserTypes.Normal)
	print "Usuniecie ciebie"
	session.remove_contact(3993939)
	time.sleep(10)
Esempio n. 2
0
def msg_recv_event_handler(sender, args):
	print 'Message received:'
        print 'sender:', args.sender
	print 'seq:', args.seq
	print 'msg_class:', GGMsgTypes.reverse_lookup(args.msg_class)
	print 'message:', args.message
	print
	
def on_unknown_packet_event_handler(sender, args):
	print 'Unknow packet received: type: %d, length: %d' % (args.type, args.length)
	print
	
def on_userlist_reply(sender, args):
    if args.reqtype != GGUserListReplyTypes.GetReply:
        print 'Eksport udany'
	
if __name__ == "__main__":
	session = GGSession(uin = 11327271, password = '******')
	session.register('on_login_ok', login_ok_event_handler)
	session.register('on_msg_recv', msg_recv_event_handler)
        session.register('on_userlist_reply', on_userlist_reply)
	session.register('on_unknown_packet', on_unknown_packet_event_handler)
        session.import_contacts_list("kontakty.txt")
        clist = session.contacts_list
        assert clist[12345678].shown_name == "Ania"
	session.login()
        session.export_contacts_list()
        time.sleep(10)
	session.logout()

Esempio n. 3
0
		print '"' + args.contact.description + '"'

def on_disconnecting_event_handler(sender, args):
	print '---'
	print 'Server has closed the connection'
	
if __name__ == "__main__":
	contacts_list = ContactsList([Contact({'uin':3993939,'shown_name':'Tralala'}), Contact({'uin':4668758,'shown_name':'Anna'})])
	# Inicjowanie sesji
	session = GGSession(uin = 11327271, password = '******', initial_status = GGStatuses.AvailDescr, initial_description = 'pygglib echo demo', contacts_list = contacts_list)
	# Rejestrowanie obslugi zdarzen
	session.register('on_login_ok', on_login_ok_event_handler)
	session.register('on_msg_recv', on_msg_recv_event_handler)
	session.register('on_msg_recv', on_msg_recv_echo)
	session.register('on_unknown_packet', on_unknown_packet_event_handler)
	session.register('on_send_msg_ack', on_msg_ack_event_handler)
	session.register('on_notify_reply', on_notify_reply_event_handler)
	session.register('on_userlist_reply', on_userlist_reply_event_handler)
	session.register('on_status_changed', on_status_changed_event_handler)
	session.register('on_disconnecting', on_disconnecting_event_handler)

	session.login()
	session.import_contacts_list()
	x = ''
	while x != 'quit':
		x = raw_input()
	print 'wylogowuje...'
	session.logout()
	print 'wylogowalem'
	
Esempio n. 4
0
	
def on_send_msg_ack_event_handler(sender, args):
	print 'msg_send_ack received: status: %s, recipient: %d, seq: %d' % (GGMsgStatus.reverse_lookup(args.status), args.recipient, args.seq)
	
def on_pubdir_recv_event_handler(sender, args):
	print 'PubDir type', args.req_type
	print 'PubDir sequence numer', args.seq
	entries = args.reply.split("\0\0")
	for item in entries.data:
		print request_to_dict(item)
	print
	
def on_userlist_reply(sender, args):
	print 'UserListReply'
	assert type(args.contacts_list) == ContactsList
	print

if __name__ == "__main__":
	session = GGSession(uin = 11327271, password = '******')
	session.register('on_login_ok', login_ok_event_handler)
	session.register('on_msg_recv', msg_recv_event_handler)
	session.register('on_unknown_packet', on_unknown_packet_event_handler)
	session.register('on_send_msg_ack', on_send_msg_ack_event_handler)
	session.register('on_pubdir_recv', on_pubdir_recv_event_handler)
        session.register('on_userlist_reply', on_userlist_reply)
	session.login()
        session.import_contacts_list()
        session.export_contacts_list("kontakty.txt")
	session.logout()
	x = raw_input()