소스 검색

Don't greet a user if they leave immediately after joining.

pull/10/merge
Ben Kurtovic 9 년 전
부모
커밋
303de618c3
1개의 변경된 파일17개의 추가작업 그리고 2개의 파일을 삭제
  1. +17
    -2
      commands/welcome.py

+ 17
- 2
commands/welcome.py 파일 보기

@@ -29,7 +29,7 @@ class Welcome(Command):
"""Welcome people who enter certain channels."""
name = "welcome"
commands = ["welcome", "greet"]
hooks = ["join", "msg"]
hooks = ["join", "part", "msg"]

def setup(self):
try:
@@ -40,12 +40,13 @@ class Welcome(Command):

self._throttle = False
self._last_join = 0
self._pending = []

def check(self, data):
if data.is_command and data.command in self.commands:
return True
try:
if data.line[1] != "JOIN":
if data.line[1] != "JOIN" and data.line[1] != "PART":
return False
except IndexError:
pass
@@ -58,6 +59,11 @@ class Welcome(Command):
self.process_command(data)
return

if data.line[1] == "PART":
if (data.chan, data.nick) in self._pending:
self._pending.remove((data.chan, data.nick))
return

this_join = time()
if this_join - self._last_join < 5:
self._throttle = True
@@ -77,11 +83,20 @@ class Welcome(Command):

def _callback(self, data):
"""Internal callback function."""
self._pending.append((data.chan, data.nick))
sleep(2)

if data.chan in self.disabled or self._throttle:
return
if (data.chan, data.nick) not in self._pending:
return
self.say(data.chan, self.channels[data.chan].format(nick=data.nick))

try:
self._pending.remove((data.chan, data.nick))
except ValueError:
pass # Could be a race condition

def process_command(self, data):
"""Handle this when it is an explicit command, not a channel join."""
if data.args:


불러오는 중...
취소
저장