more work on the chat client, it now supports nick changes
This commit is contained in:
parent
d619204d58
commit
f599959efe
@ -12,19 +12,25 @@ if(name==""):
|
|||||||
#fuck. abort?
|
#fuck. abort?
|
||||||
raise SystemExit("please log in!")
|
raise SystemExit("please log in!")
|
||||||
NICK=name+"[tpt]"
|
NICK=name+"[tpt]"
|
||||||
IDENT=name
|
IDENT=name+"[tpt]"
|
||||||
REALNAME=name
|
REALNAME=name
|
||||||
CHANNEL="#powder"
|
CHANNEL="#foobar7"
|
||||||
readbuffer=""
|
readbuffer=""
|
||||||
|
|
||||||
def raw(s,st):
|
def raw(s,st):
|
||||||
s.send("%s\n\r"%st)
|
s.send("%s\n\r"%st)
|
||||||
|
|
||||||
frame=0
|
def init():
|
||||||
s=None
|
global frame,s,rec,readbuffer,namelist
|
||||||
rec=[("connected.",255,0,0,128)]
|
frame=0
|
||||||
readbuffer=""
|
s=None
|
||||||
namelist=[]
|
rec=[("connected.",255,0,0,128)]
|
||||||
|
readbuffer=""
|
||||||
|
namelist=[]
|
||||||
|
|
||||||
|
def exit():
|
||||||
|
raw(s,"QUIT")
|
||||||
|
s.close()
|
||||||
|
|
||||||
def console_handle(txt):
|
def console_handle(txt):
|
||||||
"""
|
"""
|
||||||
@ -77,7 +83,7 @@ def step():
|
|||||||
|
|
||||||
for line in temp:
|
for line in temp:
|
||||||
line=line.strip()
|
line=line.strip()
|
||||||
#print repr(line)
|
print repr(line)
|
||||||
line=line.split()
|
line=line.split()
|
||||||
if(line[1]=="PRIVMSG"):
|
if(line[1]=="PRIVMSG"):
|
||||||
#:doxin!~lieuwe@unaffiliated/lieuwe PRIVMSG doxin[tpt] :some shit
|
#:doxin!~lieuwe@unaffiliated/lieuwe PRIVMSG doxin[tpt] :some shit
|
||||||
@ -111,15 +117,34 @@ def step():
|
|||||||
elif(line[1]=="JOIN"):
|
elif(line[1]=="JOIN"):
|
||||||
#':savask!~savask@95-190-25-195-xdsl-dynamic.kuzbass.net JOIN :#powder'
|
#':savask!~savask@95-190-25-195-xdsl-dynamic.kuzbass.net JOIN :#powder'
|
||||||
tmp=line[0][1:].partition("!")[0]
|
tmp=line[0][1:].partition("!")[0]
|
||||||
namelist.append(tmp)
|
namelist.append((tmp,255,255,255,128))
|
||||||
rec.append(("%s joined"%name,0,255,0,128))
|
rec.append(("%s joined"%name,0,255,0,128))
|
||||||
elif(line[1]=="part"):
|
elif(line[1]=="PART"):
|
||||||
#':savask!~savask@95-190-25-195-xdsl-dynamic.kuzbass.net PART #powder :"Leaving."'
|
#':savask!~savask@95-190-25-195-xdsl-dynamic.kuzbass.net PART #powder :"Leaving."'
|
||||||
tmp=line[0][1:].partition("!")[0]
|
tmp=line[0][1:].partition("!")[0]
|
||||||
msg=' '.join(line[2:])[1:]
|
msg=' '.join(line[2:])[1:]
|
||||||
if(tmp in namelist):
|
rem=None
|
||||||
namelist.remove(tmp)
|
for item in namelist:
|
||||||
rec.append("%s parted: %s"%(name,msg),0,255,0,128)
|
if(item[0]==tmp or item[0]=="@"+tmp):
|
||||||
|
rem=item
|
||||||
|
rec.append(("%s parted: %s"%(name,msg),0,255,0,128))
|
||||||
|
if(rem!=None):
|
||||||
|
namelist.remove(rem)
|
||||||
|
elif(line[1]=="NICK"):
|
||||||
|
#:doxin!~lieuwe@unaffiliated/lieuwe NICK :d0x1n
|
||||||
|
tmp=line[0][1:].partition("!")[0]
|
||||||
|
rem=None
|
||||||
|
for item in namelist:
|
||||||
|
if(item[0]==tmp or item[0]=="@"+tmp):
|
||||||
|
rem=item
|
||||||
|
rec.append(("%s is now known as %s"%(name,line[2]),0,255,0,128))
|
||||||
|
if(rem!=None):
|
||||||
|
if(rem[0][0]=="@"):
|
||||||
|
namelist.append(("@"+line[2][1:],rem[1],rem[2],rem[3],rem[4]))
|
||||||
|
else:
|
||||||
|
namelist.append((line[2][1:],rem[1],rem[2],rem[3],rem[4]))
|
||||||
|
namelist.remove(rem)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -129,6 +154,7 @@ def step():
|
|||||||
for item in rec:
|
for item in rec:
|
||||||
tpt.draw_text(8,yy,item[0],item[1],item[2],item[3],item[4])
|
tpt.draw_text(8,yy,item[0],item[1],item[2],item[3],item[4])
|
||||||
yy+=8
|
yy+=8
|
||||||
|
#print namelist
|
||||||
yy=32
|
yy=32
|
||||||
for item in namelist:
|
for item in namelist:
|
||||||
tpt.draw_text(604-tpt.get_width(item[0]),yy,item[0],item[1],item[2],item[3],item[4])
|
tpt.draw_text(604-tpt.get_width(item[0]),yy,item[0],item[1],item[2],item[3],item[4])
|
||||||
|
File diff suppressed because one or more lines are too long
18
src/main.c
18
src/main.c
@ -1838,6 +1838,17 @@ emb_get_mouse(PyObject *self, PyObject *args)
|
|||||||
return Py_BuildValue("(ii(iii))",x,y,b1,b2,b3);
|
return Py_BuildValue("(ii(iii))",x,y,b1,b2,b3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//svf_name
|
||||||
|
emb_get_name(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
if(!PyArg_ParseTuple(args, ":get_name"))
|
||||||
|
return NULL;
|
||||||
|
if(svf_login)
|
||||||
|
return Py_BuildValue("s",svf_user);
|
||||||
|
else
|
||||||
|
return Py_BuildValue("s","");
|
||||||
|
}
|
||||||
|
|
||||||
static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your function here!
|
static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your function here!
|
||||||
{"create", emb_create, METH_VARARGS|METH_KEYWORDS, "create a particle."},
|
{"create", emb_create, METH_VARARGS|METH_KEYWORDS, "create a particle."},
|
||||||
{"log", emb_log, METH_VARARGS, "logs an error string to the console."},
|
{"log", emb_log, METH_VARARGS, "logs an error string to the console."},
|
||||||
@ -1869,6 +1880,7 @@ static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your fun
|
|||||||
{"draw_fillrect", emb_draw_fillrect, METH_VARARGS, "draw a rect."},
|
{"draw_fillrect", emb_draw_fillrect, METH_VARARGS, "draw a rect."},
|
||||||
{"get_width", emb_get_width, METH_VARARGS, "get string width."},
|
{"get_width", emb_get_width, METH_VARARGS, "get string width."},
|
||||||
{"get_mouse", emb_get_mouse, METH_VARARGS, "get mouse status."},
|
{"get_mouse", emb_get_mouse, METH_VARARGS, "get mouse status."},
|
||||||
|
{"get_name", emb_get_name, METH_VARARGS, "get name of logged in user"},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3546,12 +3558,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
SDL_CloseAudio();
|
SDL_CloseAudio();
|
||||||
http_done();
|
http_done();
|
||||||
//make sure no threads are blocking us
|
|
||||||
//fork_unblock
|
|
||||||
pargs=Py_BuildValue("(s)","fork_unblock()");//this deamonises all threads.
|
|
||||||
pvalue = PyObject_CallObject(pfunc, pargs);
|
|
||||||
Py_DECREF(pargs);
|
|
||||||
pargs=NULL;
|
|
||||||
Py_Finalize();//cleanup any python stuff.
|
Py_Finalize();//cleanup any python stuff.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ element={"none":0,"dust":1,"watr":2,"oil":3,"fire":4,"stne":5,"lava":6,"gunp":7,
|
|||||||
def fork_unblock():
|
def fork_unblock():
|
||||||
pass#i need to implement this some day.
|
pass#i need to implement this some day.
|
||||||
def error(ex):
|
def error(ex):
|
||||||
|
traceback.print_exc()
|
||||||
err=traceback.format_exc()
|
err=traceback.format_exc()
|
||||||
sys.stdout.write(err)
|
sys.stdout.write(err)
|
||||||
|
|
||||||
@ -78,18 +79,34 @@ def _handle(txt):
|
|||||||
|
|
||||||
_extensions=[]
|
_extensions=[]
|
||||||
def loadext(fname):
|
def loadext(fname):
|
||||||
_extensions.append(__import__(fname))
|
ext=__import__(fname)
|
||||||
|
ext.init()
|
||||||
|
_extensions.append(ext)
|
||||||
|
|
||||||
def keypress(key):
|
def keypress(key):
|
||||||
try:
|
unload=[]
|
||||||
for item in _extensions:
|
for item in _extensions:
|
||||||
|
try:
|
||||||
item.key(key)
|
item.key(key)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
error(ex)
|
error(ex)
|
||||||
|
unload.append(item)
|
||||||
|
for item in unload:
|
||||||
|
item.exit()
|
||||||
|
_extensions.remove(item)
|
||||||
|
|
||||||
|
|
||||||
def step():
|
def step():
|
||||||
try:
|
unload=[]
|
||||||
for item in _extensions:
|
for item in _extensions:
|
||||||
|
try:
|
||||||
item.step()
|
item.step()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
error(ex)
|
error(ex)
|
||||||
|
unload.append(item)
|
||||||
|
for item in unload:
|
||||||
|
try:
|
||||||
|
item.exit()
|
||||||
|
except Exception as ex:
|
||||||
|
error(ex)
|
||||||
|
_extensions.remove(item)
|
||||||
|
Loading…
Reference in New Issue
Block a user