Пример #1
0
    def setUp(self):
        self.session1 = GGSession(uin=UIN1,
                                  password=PASS1,
                                  contacts_list=ContactsList(
                                      [Contact({'uin': UIN2})]))
        self.session2 = GGSession(uin=UIN2,
                                  password=PASS2,
                                  initial_status=GGStatuses.AvailDescr,
                                  initial_description=DESC1)

        self.session1.register('on_notify_reply', on_notify_reply)
        self.session1.register('on_status_changed', on_status_changed)
        self.session1.register('on_disconnecting', on_disconnecting)
        self.session2.register('on_disconnecting', on_disconnecting)
Пример #2
0
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:
        print request_to_dict(item)
    print


if __name__ == "__main__":
    if len(sys.argv) == 1:
        uin = 3993939
    else:
        uin = int(sys.argv[1])
    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.login()
    session.pubdir_request({'FmNumber': 1308535})
    time.sleep(5)
    session.send_msg(uin, 'msg1')
    time.sleep(5)
    session.send_msg(uin, 'msg2', msg_class=GGMsgTypes.Chat)
    time.sleep(5)
    print 'Changing status...'
    session.change_status(GGStatuses.AvailDescr, "pygglib")
    time.sleep(5)
Пример #3
0
	print 'msg_class:', GGMsgTypes.reverse_lookup(args.msg_class)
	print 'message:', args.message
	print
	
def print_unknown_packet(sender, args):
	print 'Unknow packet received: type: %d, length: %d' % (args.type, args.length)
	print

def notify_reply(sender, args):
	print 'reply notified'
	
	
if __name__ == "__main__":
	try:
		contacts = ContactsList([Contact({'uin':3993939}), Contact({'uin':3217426}), Contact({'uin':4102378})])
		session = GGSession(uin = 11327271, password = '******', contacts_list = contacts)
		session.register('on_login_ok', login_ok)
		session.register('on_msg_recv', print_msg)
		session.register('on_unknown_packet', print_unknown_packet)
		session.register('on_notify_reply', notify_reply)
		session.login()
		time.sleep(2)
		print "uin: %d, status: %s description: %s" % (session.contacts_list[3217426].uin, GGStatuses.reverse_lookup_without_mask(session.contacts_list[3217426].status), session.contacts_list[3217426].description)
		print "uin: %d, status: %s description: %s" % (session.contacts_list[4102378].uin, GGStatuses.reverse_lookup_without_mask(session.contacts_list[4102378].status), session.contacts_list[4102378].description)
		print "uin: %d, status: %s description: %s" % (session.contacts_list[3993939].uin, GGStatuses.reverse_lookup_without_mask(session.contacts_list[3993939].status), session.contacts_list[3993939].description)
		time.sleep(4)
		session.logout()
	finally:
		try:
			session.logout()
		except: #znaczy, ze nie jestesmy zalogowani
Пример #4
0
#


def login_ok_event_handler(sender, args):
    print 'Zalogowano :>'
    print


def status_notify_event_handler(sender, args):
    print args.args()
    print 'Numerek %d zmienil status' % args.uin
    print


def unknown_packet_event_handler(sender, args):
    print 'Unknow packet received: type: 0x%04x, length: 0x%04x' % (
        args.type, args.length)
    print


if __name__ == "__main__":
    session = GGSession(uin=11327271,
                        password='******',
                        initial_status=GGStatuses.Invisible)
    session.register('on_login_ok', login_ok_event_handler)
    session.register('on_status_changed', status_notify_event_handler)
    session.register('on_unknown_packet', unknown_packet_event_handler)
    session.login()
    time.sleep(0.5)
    session.logout('Nie ma Henia')
Пример #5
0
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()