Add join and part built-ins
Nemubot kernel working
This commit is contained in:
parent
716fa5675a
commit
1bb3617049
4 changed files with 62 additions and 10 deletions
32
prompt.py
32
prompt.py
|
|
@ -115,6 +115,12 @@ def liste(cmds, servers):
|
|||
if l == "server" or l == "servers":
|
||||
for srv in servers.keys():
|
||||
print (" - %s ;" % srv)
|
||||
elif l == "chan" or l == "channel" or l == "channels":
|
||||
if selectedServer is not None:
|
||||
for chn in selectedServer.channels:
|
||||
print (" - %s ;" % chn)
|
||||
else:
|
||||
print (" Please SELECT a server before ask for channels list.")
|
||||
else:
|
||||
print (" Unknown list `%s'" % l)
|
||||
else:
|
||||
|
|
@ -133,6 +139,30 @@ def connect(cmds, servers):
|
|||
else:
|
||||
print (" Please SELECT a server or give its name in argument.")
|
||||
|
||||
def join(cmds, servers):
|
||||
rd = 1
|
||||
if len(cmds) <= rd:
|
||||
print ("%s: not enough arguments." % cmds[0])
|
||||
return
|
||||
|
||||
if cmds[rd] in servers:
|
||||
srv = servers[cmds[rd]]
|
||||
rd += 1
|
||||
elif selectedServer is not None:
|
||||
srv = selectedServer
|
||||
else:
|
||||
print (" Please SELECT a server or give its name in argument.")
|
||||
return
|
||||
|
||||
if len(cmds) <= rd:
|
||||
print ("%s: not enough arguments." % cmds[0])
|
||||
return
|
||||
|
||||
if cmds[0] == "join":
|
||||
srv.join(cmds[rd])
|
||||
elif cmds[0] == "leave" or cmds[0] == "part":
|
||||
srv.leave(cmds[rd])
|
||||
|
||||
def send(cmds, servers):
|
||||
rd = 1
|
||||
if len(cmds) <= rd:
|
||||
|
|
@ -215,6 +245,8 @@ CAPS = {
|
|||
'select': select, #Select a server
|
||||
'list': liste, #Show lists
|
||||
'connect': connect, #Connect to a server
|
||||
'join': join, #Join a new channel
|
||||
'leave': join, #Leave a channel
|
||||
'send': send, #Send a message on a channel
|
||||
'disconnect': disconnect, #Disconnect from a server
|
||||
'zap': zap, #Reverse internal connection state without check
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue