This repository was archived by the owner on Apr 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.py
More file actions
69 lines (51 loc) · 1.98 KB
/
Copy pathplugin.py
File metadata and controls
69 lines (51 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from time import time
import supybot.utils as utils
from supybot.commands import *
import supybot.plugins as plugins
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
import supybot.ircmsgs as ircmsgs
import supybot.schedule as schedule
class Greet(callbacks.Plugin):
"""
This plugin greets users with a defined message when they join the
channel. In order to use this plugin, supybot.plugins.Greet.enable
must be True, and supybot.plugins.Greet.message must be set to the
message you wish to send to users when they join.
"""
_ignore = set([])
def __init__(self, irc):
self.__parent = super(Greet, self)
self.__parent.__init__(irc)
def _rememberNick(nick):
if nick in self._ignore:
self._ignore.remove()
def _ignoreNick(self, irc, msg):
channel = msg.args[0]
if not self.registryValue('enable', channel):
return
delay = self.registryValue('grace', channel)
if not msg.nick in self._ignore:
self._ignore.add(msg.nick)
schedule.addEvent(self._rememberNick, time() + delay,
args=(msg.nick,))
def doJoin(self, irc, msg):
channel = msg.args[0]
if not self.registryValue('enable', channel):
return
greeting = self.registryValue('message', channel)
delay = self.registryValue('grace', channel)
if len(greeting.strip()) == 0:
self.log.warn('Greeting empty for %s' % channel)
return
if (not ircutils.strEqual(msg.nick, irc.nick)
and msg.nick not in self._ignore):
self._ignore.add(msg.nick)
irc = callbacks.SimpleProxy(irc, msg)
irc.queueMsg(ircmsgs.privmsg(msg.nick, greeting))
schedule.addEvent(self._rememberNick, time() + delay,
args=(msg.nick,))
doPart = _ignoreNick
doKick = _ignoreNick
doQuit = _ignoreNick
Class = Greet