class ChangeStatusTest(unittest.TestCase): 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) def testChangeStatus(self): self.session2.login() while self.session2.logged != True: time.sleep(0.1) print "Session2 logged in" time.sleep(1) self.session1.login() while self.session1.logged != True: time.sleep(0.1) print "Session1 logged in" time.sleep(5) self.session2.change_description(DESC2) time.sleep(5) self.session1.logout() self.session2.logout() self.assertTrue(PASSED) self.assertTrue(CHANGED) self.assertTrue(INITIAL)
class ChangeStatusTest(unittest.TestCase): 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) def testChangeStatus(self): self.session2.login() while self.session2.logged != True: time.sleep(0.1) print "Session2 logged in" time.sleep(1) self.session1.login() while self.session1.logged != True: time.sleep(0.1) print "Session1 logged in" time.sleep(5) self.session2.change_description(DESC2) time.sleep(5) self.session1.logout() self.session2.logout() self.assertTrue(PASSED) self.assertTrue(CHANGED) self.assertTrue(INITIAL)
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) print 'Changing description...' session.change_description("ala ma kota") time.sleep(5) session.logout('Nie ma Henia') x = raw_input()
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) print "Eksport" session.export_contacts_list() session.export_contacts_list("kontakty.txt") print "Wylogowanie..." session.logout("Ni ma Henia...") print "Wylogowano"
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'
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 pass
from GGConstans import * import time # # 11327271, haslo eto2007 # 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')
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) print "Eksport" session.export_contacts_list() session.export_contacts_list("kontakty.txt") print "Wylogowanie..." session.logout("Ni ma Henia...") print "Wylogowano"