diff --git a/games/GGSChat/chat.py b/games/GGSChat/chat.py index 0e2aeb7..a56f915 100644 --- a/games/GGSChat/chat.py +++ b/games/GGSChat/chat.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import sys, socket, thread, gobject, getpass +import sys, socket, thread, gobject, getpass, time try: import pygtk pygtk.require("2.16") @@ -16,12 +16,14 @@ class GGSChat: def __init__(self,host, port): #Set the Glade file + self.nicksListStore = gtk.ListStore(str) self.gladefile = "ggschat.glade" self.wTree = gtk.glade.XML(self.gladefile, "window1") self.setStatus("Not connected") self.connect(host, port) thread.start_new_thread(self.listenChat, ()) + thread.start_new_thread(self.luserCheck, ()) #Create our dictionay and connect it dic = {"on_window1_destroy_event" : gtk.main_quit , "on_sendButton_clicked" : lambda x: self.chat() @@ -35,7 +37,15 @@ class GGSChat: self.wTree.get_widget("nickBox").set_text(getpass.getuser()) self.wTree.get_widget("window1").show() self.wTree.get_widget("entry").grab_focus() + nicksList = self.wTree.get_widget("nicksList") self.changeNick() + nicksList.set_model(self.nicksListStore) +# self.nicksListStore.append(["Test!"]) + + rendererText = gtk.CellRendererText() + column = gtk.TreeViewColumn("Participants", rendererText, text=0) + column.set_sort_column_id(0) + nicksList.append_column(column) def setStatus(self, msg): self.wTree.get_widget("statusbar").push(0, msg) @@ -90,10 +100,30 @@ class GGSChat: while True: line = fs.readline() print "Received: ", line - gobject.idle_add(self.updateChatText, line) + if line.split(" ")[0] == "LUSERS": + gobject.idle_add(self.updateUsers, line) + else: + gobject.idle_add(self.updateChatText, line) def updateChatText(self, text): self.wTree.get_widget("chatBox").get_buffer().insert_at_cursor(text) + + def luserCheck(self): + while True: + self.s.send("Game-Command: lusers\n" + + "Token: %s\n" % self.token + + "Content-Type: text\n" + + "Content-Length: 0\n"+ + "\n") + time.sleep(2) + + def updateUsers(self, text): + nicks = ' '.join(text.split(" ")[1:]) + evalNicks = eval(nicks) + self.nicksListStore.clear() + for nick in evalNicks: + self.nicksListStore.append([nick]) + if __name__ == "__main__": host = "localhost" port = 9000 diff --git a/games/GGSChat/ggschat.glade b/games/GGSChat/ggschat.glade index e4482da..ed39607 100644 --- a/games/GGSChat/ggschat.glade +++ b/games/GGSChat/ggschat.glade @@ -10,22 +10,115 @@ True - + True + True - + + True + _File + True + + + True + True + + + Connect to ... + True + True + False + + + True + gtk-missing-image + + + + + + + True + + + + + gtk-quit + True + True + True + + + + + + + + + True + _Help + True + + + True + True + + + gtk-about + True + True + True + + + + + + + + + False + 0 + + + + + True + True + + True True - False - + automatic + automatic + + + 412 + True + True + False + + + - 0 + True + False + + + + + True + True + 1 + + + False + True - 0 + 1 @@ -74,7 +167,7 @@ False False - 1 + 2 @@ -84,7 +177,7 @@ False - 2 + 3 diff --git a/src/ggs_gamevm_e.erl b/src/ggs_gamevm_e.erl index c8c5f2a..08f9855 100644 --- a/src/ggs_gamevm_e.erl +++ b/src/ggs_gamevm_e.erl @@ -54,7 +54,7 @@ do_stuff(Command, Args, Player, Table) -> "lusers" -> {ok, Players} = ggs_table:get_player_list(Table), Nicks = lists:map(fun (P) -> ggs_db:getItem(Table, nicks, P) end, Players), - ggs_player:notify(Player, server,io_lib:format("~p\n",[Nicks])); + ggs_player:notify(Player, server,io_lib:format("LUSERS ~p\n",[Nicks])); "nick" -> ggs_db:setItem(Table,nicks,Player,Args), io:format("Changing nickname of ~p to ~p.", [Player, Args]);