|
@@ -1,4 +1,4 @@
|
|
|
-import datetime
|
|
|
|
|
|
|
+import datetime, pytz
|
|
|
from common import log, queries, font, userstatus
|
|
from common import log, queries, font, userstatus
|
|
|
|
|
|
|
|
def process_event(self, connection, event):
|
|
def process_event(self, connection, event):
|
|
@@ -10,7 +10,6 @@ def process_event(self, connection, event):
|
|
|
queries.increment_join(self, channel.id, user.id)
|
|
queries.increment_join(self, channel.id, user.id)
|
|
|
|
|
|
|
|
if event.source.nick == connection.get_nickname(): # The bot joined a channel.
|
|
if event.source.nick == connection.get_nickname(): # The bot joined a channel.
|
|
|
- log.info('Joined %s' % event.target)
|
|
|
|
|
if self.channels[event.target].has_key(): # Passworded channel.
|
|
if self.channels[event.target].has_key(): # Passworded channel.
|
|
|
if event.target in self.channelkeys: # New key used to join channel.
|
|
if event.target in self.channelkeys: # New key used to join channel.
|
|
|
log.info('Saving channel key for %s.' %s)
|
|
log.info('Saving channel key for %s.' %s)
|
|
@@ -24,15 +23,19 @@ def process_event(self, connection, event):
|
|
|
user_lastgreet = queries.get_user_last_greet(self, user.id)
|
|
user_lastgreet = queries.get_user_last_greet(self, user.id)
|
|
|
greet = False
|
|
greet = False
|
|
|
amount_greet = False
|
|
amount_greet = False
|
|
|
|
|
+ cet = pytz.timezone('Europe/Amsterdam')
|
|
|
|
|
+
|
|
|
if not chan_lastgreet:
|
|
if not chan_lastgreet:
|
|
|
- chan_lastgreet = datetime.datetime.now() - datetime.timedelta(minutes=timeout+1)
|
|
|
|
|
|
|
+ chan_lastgreet = cet.localize(datetime.datetime.now()) - datetime.timedelta(minutes=timeout+1)
|
|
|
if not user_lastgreet:
|
|
if not user_lastgreet:
|
|
|
- user_lastgreet = datetime.datetime.now() - datetime.timedelta(minutes=timeout+1)
|
|
|
|
|
- if chan_lastgreet < datetime.datetime.now() - datetime.timedelta(minutes=timeout) and user_lastgreet < datetime.datetime.now() - datetime.timedelta(minutes=timeout): # User or channel have not had greet message in the last timeout minutes, there is a curse available
|
|
|
|
|
|
|
+ user_lastgreet = cet.localize(datetime.datetime.now()) - datetime.timedelta(minutes=timeout+1)
|
|
|
|
|
+ if chan_lastgreet < cet.localize(datetime.datetime.now()) - datetime.timedelta(minutes=timeout) and user_lastgreet < cet.localize(datetime.datetime.now()) - datetime.timedelta(minutes=timeout): # User or channel have not had greet message in the last timeout minutes, there is a curse available
|
|
|
if joins % 200 == 0: # Has joined 200, or a multiple of 200 times. (Also 0 but the join has already been saved.)
|
|
if joins % 200 == 0: # Has joined 200, or a multiple of 200 times. (Also 0 but the join has already been saved.)
|
|
|
amount_greet = True
|
|
amount_greet = True
|
|
|
elif userstatus.atleast_voiced(self, event.source.nick, self.network.home_channel): # User has atleast voice in home channel.
|
|
elif userstatus.atleast_voiced(self, event.source.nick, self.network.home_channel): # User has atleast voice in home channel.
|
|
|
- greet = True
|
|
|
|
|
|
|
+ curse = queries.random_curse(self)
|
|
|
|
|
+ if curse:
|
|
|
|
|
+ greet = True
|
|
|
|
|
|
|
|
# Promotion conditions.
|
|
# Promotion conditions.
|
|
|
promote = False
|
|
promote = False
|
|
@@ -48,10 +51,6 @@ def process_event(self, connection, event):
|
|
|
connection.mode(event.target, "+aohv %s %s %s %s" % (event.source.nick, event.source.nick, event.source.nick, event.source.nick))
|
|
connection.mode(event.target, "+aohv %s %s %s %s" % (event.source.nick, event.source.nick, event.source.nick, event.source.nick))
|
|
|
|
|
|
|
|
# Greet.
|
|
# Greet.
|
|
|
- if greet or amount_greet:
|
|
|
|
|
- curse = queries.random_curse(self)
|
|
|
|
|
- if not curse:
|
|
|
|
|
- return
|
|
|
|
|
if amount_greet:
|
|
if amount_greet:
|
|
|
log.info('Greeting %s in %s' % (event.source.nick, event.target))
|
|
log.info('Greeting %s in %s' % (event.source.nick, event.target))
|
|
|
adjective = queries.random_adjective(self)
|
|
adjective = queries.random_adjective(self)
|