Hi, Feel free to review the attached patch, before I commit it to pokersource trunk:
2009-07-17 Johan Euphrosine <[email protected]> * database/schema.sql.in: * pokernetwork/pokerservice.py (PokerService.chatMessageArchive): * tests/test-pokerservice.py.in (PokerServiceTestCase.test25_chatMessageArchive): * pokernetwork/pokertable.py (PokerTable.chatPlayer): * tests/test-pokertable.py.in (PokerTableTestCase.test10_info_and_chat): add database archiving of chat messages. This patch is copyrighted by me and licensed AGPLv3-or-later. -- Johan Euphrosine <[email protected]>
Index: pokernetwork/pokerservice.py =================================================================== --- pokernetwork/pokerservice.py (revision 6096) +++ pokernetwork/pokerservice.py (working copy) @@ -3,6 +3,7 @@ # # Copyright (C) 2006, 2007, 2008 Loic Dachary <[email protected]> # Copyright (C) 2008, 2009 Bradley M. Kuhn <[email protected]> +# Copyright (C) 2009 Johan Euphrosine <[email protected]> # Copyright (C) 2004, 2005, 2006 Mekensleep <[email protected]> # 24 rue vieille du temple 75004 Paris # @@ -2576,6 +2577,10 @@ delay = int(self.delays.get('messages', 60)) self.timer['messages'] = reactor.callLater(delay, self.messageCheck) + def chatMessageArchive(self, player_serial, game_id, message): + cursor = self.db.cursor() + cursor.execute("INSERT INTO chat_messages (player_serial, game_id, message) VALUES (%s, %s, %s)", (player_serial, game_id, message)) + if HAS_OPENSSL: class SSLContextFactory: Index: pokernetwork/pokertable.py =================================================================== --- pokernetwork/pokertable.py (revision 6096) +++ pokernetwork/pokertable.py (working copy) @@ -3,6 +3,7 @@ # # Copyright (C) 2006, 2007, 2008 Loic Dachary <[email protected]> # Copyright (C) 2008 Bradley M. Kuhn <[email protected]> +# Copyright (C) 2009 Johan Euphrosine <[email protected]> # Copyright (C) 2004, 2005, 2006 Mekensleep <[email protected]> # 24 rue vieille du temple 75004 Paris # @@ -1238,6 +1239,7 @@ self.broadcast(PacketPokerChat(game_id = self.game.id, serial = serial, message = message + "\n")) + self.factory.chatMessageArchive(serial, self.game.id, message) def autoBlindAnte(self, client, serial, auto): game = self.game Index: tests/test-pokertable.py.in =================================================================== --- tests/test-pokertable.py.in (revision 6096) +++ tests/test-pokertable.py.in (working copy) @@ -3,6 +3,7 @@ # # Copyright (C) 2006, 2007, 2008 Loic Dachary <[email protected]> # Copyright (C) 2008, 2009 Bradley M. Kuhn <[email protected]> +# Copyright (C) 2009 Johan Euphrosine <[email protected]> # # This software's license gives you freedom; you can copy, convey, # propagate, redistribute and/or modify this program under the terms of @@ -149,6 +150,7 @@ self.testObject = None self.joined_count = 0 self.joined_max = 1000 + self.chat_messages = [] def getMissedRoundMax(self): return 5 # if you change this, change it in settings_xml above @@ -307,6 +309,9 @@ def databaseEvent(self, event, param1, param2): if self.testObject: self.testObject.assertEqual(PacketPokerMonitorEvent.HAND, event) + + def chatMessageArchive(self, player_serial, game_id, message): + self.chat_messages.append((player_serial, game_id, message)) if verbose < 0: redirect_messages(MockService) @@ -692,6 +697,9 @@ d = self.table.getPlayerInfo(2) self.failUnlessSubstring("Player2", d.name) self.table.chatPlayer(self.clients[1], 1, "Hi, I am the One.") + self.assertEquals(1, self.service.chat_messages[0][0]) + self.assertEquals(table1ID, self.service.chat_messages[0][1]) + self.assertEquals("Hi, I am the One.", self.service.chat_messages[0][2]) x = p[ii].waitFor(PACKET_POKER_CHAT) def chatCatch(packet): self.assertEqual(serial, 1) Index: tests/test-pokerservice.py.in =================================================================== --- tests/test-pokerservice.py.in (revision 6096) +++ tests/test-pokerservice.py.in (working copy) @@ -4,6 +4,7 @@ # # Copyright (C) 2007, 2008, 2009 Loic Dachary <[email protected]> # Copyright (C) 2008, 2009 Bradley M. Kuhn <[email protected]> +# Copyright (C) 2009 Johan Euphrosine <[email protected]> # Copyright (C) 2006 Mekensleep <[email protected]> # 24 rue vieille du temple 75004 Paris # @@ -1862,6 +1863,21 @@ clear_all_messages() self.service.buyInPlayer(self.user1_serial, table_serial, currency_serial, None) self.assertTrue("*ERROR*" in get_messages()[0]) + # ---------------------------------------------------------------- + def test25_chatMessageArchive(self): + self.service.startService() + player_serial = 10 + game_id = 42 + message = 'yeah' + self.service.chatMessageArchive(player_serial, game_id, message) + cursor = self.service.db.cursor(DictCursor) + cursor.execute("SELECT * FROM chat_messages") + result = cursor.fetchone() + self.assertEquals(player_serial, result['player_serial']) + self.assertEquals(game_id, result['game_id']) + self.assertEquals(message, result['message']) + self.assertNotEquals(0, result['timestamp']) + ############################################################################## class RefillTestCase(unittest.TestCase): Index: database/schema.sql.in =================================================================== --- database/schema.sql.in (revision 6096) +++ database/schema.sql.in (working copy) @@ -1,6 +1,7 @@ -- -*-sql-*- -- -- Copyright (C) 2008, 2009 Loic Dachary <[email protected]> +-- Copyright (C) 2009 Johan Euphrosine <[email protected]> -- Copyright (C) 2004, 2005, 2006 Mekensleep <[email protected]> -- 24 rue vieille du temple, 75004 Paris -- @@ -553,6 +554,19 @@ PRIMARY KEY (serial, send_date, sent) ) ENGINE=InnoDB CHARSET=utf8; + +DROP TABLE IF EXISTS chat_messages; + +CREATE TABLE chat_messages ( + serial INT UNSIGNED NOT NULL AUTO_INCREMENT, + player_serial INT UNSIGNED NOT NULL, + game_id INT UNSIGNED NOT NULL, + message TEXT DEFAULT '', + timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + + PRIMARY KEY (serial) +) ENGINE=InnoDB CHARSET=utf8; + DROP TABLE IF EXISTS monitor; CREATE TABLE monitor ( Index: ChangeLog =================================================================== --- ChangeLog (revision 6096) +++ ChangeLog (working copy) @@ -1,7 +1,16 @@ -2009-07-14 Loic Dachary <[email protected]> +2009-07-17 Johan Euphrosine <[email protected]> * Release 1.7.5 + * database/schema.sql.in: + * pokernetwork/pokerservice.py (PokerService.chatMessageArchive): + * tests/test-pokerservice.py.in (PokerServiceTestCase.test25_chatMessageArchive): + * pokernetwork/pokertable.py (PokerTable.chatPlayer): + * tests/test-pokertable.py.in (PokerTableTestCase.test10_info_and_chat): + add database archiving of chat messages. + +2009-07-14 Loic Dachary <[email protected]> + * pokernetwork/pokertable.py: https://gna.org/bugs/index.php?13950 The max_missed_round variable always ends up being a string if it's specified in XML config because it's not typecast to INT.
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Pokersource-users mailing list [email protected] https://mail.gna.org/listinfo/pokersource-users
