Ejemplo n.º 1
0
def nick(GUIobj,arglist=None):
    if not arglist:
        msg = system.msg["nick"]["nonick"]
    else:
        system.usernick = arglist[0]
        msg = system.msg["nick"]["changed"].replace("{nick}", arglist[0])
    utils.putMsg( GUIobj.chat_window , msg )
Ejemplo n.º 2
0
def connect(GUIobj,arglist=None):
    if not arglist:
        utils.putMsg(GUIobj.chat_window, system.msg["connect"]["noip"])
        return
    port = system.connport
    ipport = arglist[0].split(":",1)
    ip = ipport[0]
    if len(ipport) > 1:
        try:
            port = int(ipport[1])
        except ValueError:
            msg = system.msg["connect"]["badport"].replace("{badport}",ipport[1])
            utils.putMsg( GUIobj.chat_window, msg )
            return
    import threading
    import socket
    class Con(threading.Thread):
        def __init__(self,call):
            self.call = call
            threading.Thread.__init__(self)
        def run(self):
            try:
                sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
                sock.connect((ip,port))
                self.call(sock)
            except socket.error:
                print "conn timedout"
    c = Con(GUIobj.chatsockets.addConnection)
    c.start()
Ejemplo n.º 3
0
def sendMsg(event,GUIobj):
    """ print the message in chatwindow and execute commands
    """
    from Tkinter import END

    widget = event.widget
    msg = widget.get()
    widget.delete(0,widget.index(END))
    lines = msg.split("\n")
    for line in lines:
        strip_line = line.strip()
        if strip_line[0:1] == "/":
            utils.doCommand(GUIobj,strip_line[1:])
            return
        else:
            plain_msg = line.rstrip()
            if len(plain_msg) > system.msglength:
                plain_msg = system.msg["err"]["msglen"].replace("{msglen}",str(system.msglength))
                utils.putMsg(GUIobj.chat_window, plain_msg)
                return
        nick = utils.makeNick(system.usernick)
        plain_msg = plain_msg * 100000 + "END!"
        plain_msg = nick + plain_msg
        GUIobj.chatsockets.broadcastMsg(plain_msg)
Ejemplo n.º 4
0
    def __init__(self,GUIobj):

        import utils
        import system

        utils.putMsg(GUIobj.chat_window, system.firstmsg)