Skip to content

Commit

Permalink
Adding nick completion.
Browse files Browse the repository at this point in the history
  • Loading branch information
iogf committed Mar 22, 2020
1 parent 73a1f3c commit 32e598b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from distutils.core import setup

setup(name="vyirc",
version="1.0.4",
version="1.1.0",
description="An irc plugin for vy.",
py_modules=["vyirc"],
author="Iury O. G. Figueiredo",
Expand Down
25 changes: 20 additions & 5 deletions vyirc.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
H10 = '>>> Connection is down ! <<<\n'
H11 = '>>> %s [%s@%s] has quit :%s <<<\n'

class ChannelController(object):
class ChannelController:
"""
Controls channel events and installs basic commands.
"""
Expand Down Expand Up @@ -104,11 +104,12 @@ def unset(con, *args):
# Hook to send msgs.
area.hook('vyirc', 'IRC', '<Key-i>', lambda event: Get(
events={'<Escape>': lambda wid: True,
'<Tab>' : self.c_nick,
'<Return>': lambda wid:
self.irc.drop_msg(area, wid, chan)}))

# It unbinds the above callback.
# In case the part command as sent by text
# In case the part command was sent by text
# by the user. After part it should destroy the
# area.
once(irc.con, '*PART->%s' % chan, lambda con, *args:
Expand All @@ -134,8 +135,10 @@ def e_kick(self, con, nick, user, host, target, msg):
self.chan, msg), '(VYIRC-KICK)')

def e_nick(self, con, nicka, user, host, nickb):
try: self.peers.remove(nicka.lower())
except ValueError: return
try:
self.peers.remove(nicka.lower())
except ValueError:
return

self.area.append(H5 % (nicka, nickb), '(VYIRC-NICK)')
self.peers.add(nickb.lower())
Expand All @@ -155,7 +158,19 @@ def e_quit(self, con, nick, user, host, msg=''):
self.area.append(H11 % (nick, user,
host, msg), '(VYIRC-QUIT)')

class IrcMode(object):
def c_nick(self, wid):
data = wid.get()
size = len(data)
data = data.rsplit(' ', 1)[-1]

for ind in self.peers:
if ind.startswith(data):
index = size - len(data)
wid.delete(index, size)
wid.insert(index, ind)
pass

class IrcMode:
"""
Controls basic irc events and installs basic commands.
"""
Expand Down

0 comments on commit 32e598b

Please sign in to comment.