mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
changes in plugin comment_joins
This commit is contained in:
@@ -8,6 +8,10 @@ import random
|
|||||||
import config
|
import config
|
||||||
from plugin_system import pluginfunction, ptypes
|
from plugin_system import pluginfunction, ptypes
|
||||||
|
|
||||||
|
comment_joins_strings = [
|
||||||
|
"%s: please consider to fix your internet connection"
|
||||||
|
]
|
||||||
|
|
||||||
@pluginfunction('comment_joins', 'comments frequent joins', ptypes.MUC_ONLINE)
|
@pluginfunction('comment_joins', 'comments frequent joins', ptypes.MUC_ONLINE)
|
||||||
@config.config_locked
|
@config.config_locked
|
||||||
def comment_joins(**args):
|
def comment_joins(**args):
|
||||||
@@ -15,10 +19,6 @@ def comment_joins(**args):
|
|||||||
timespan = 120
|
timespan = 120
|
||||||
max_joins = 6
|
max_joins = 6
|
||||||
|
|
||||||
comment_joins_strings = [
|
|
||||||
"%s: please consider to fix your internet connection"
|
|
||||||
]
|
|
||||||
|
|
||||||
current_timestamp = int(time.time())
|
current_timestamp = int(time.time())
|
||||||
|
|
||||||
arg_user = args['reply_user']
|
arg_user = args['reply_user']
|
||||||
@@ -29,16 +29,21 @@ def comment_joins(**args):
|
|||||||
config.runtimeconf_persist()
|
config.runtimeconf_persist()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
user_joins = config.runtime_config_store['user_joins'][arg_user_key]
|
user_joins = []
|
||||||
|
|
||||||
|
for ts in config.runtime_config_store['user_joins'][arg_user_key]:
|
||||||
|
if current_timestamp - int(ts) <= timespan:
|
||||||
|
user_joins.append(ts)
|
||||||
|
|
||||||
user_joins = [
|
print(user_joins)
|
||||||
ts if current_timestamp - int(ts) <= timespan else [] for ts in user_joins
|
|
||||||
]
|
|
||||||
user_joins.append(current_timestamp)
|
|
||||||
|
|
||||||
if len(user_joins) >= max_joins:
|
if len(user_joins) >= max_joins:
|
||||||
config.runtime_config_store['user_joins'].pop(arg_user_key)
|
config.runtime_config_store['user_joins'].pop(arg_user_key)
|
||||||
config.runtimeconf_persist()
|
config.runtimeconf_persist()
|
||||||
|
log.info("send comment on join")
|
||||||
return { 'msg': random.choice(comment_joins_strings) % arg_user }
|
return { 'msg': random.choice(comment_joins_strings) % arg_user }
|
||||||
else:
|
else:
|
||||||
|
user_joins.append(current_timestamp)
|
||||||
|
config.runtime_config_store['user_joins'][arg_user_key] = user_joins
|
||||||
config.runtimeconf_persist()
|
config.runtimeconf_persist()
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
import config
|
||||||
from plugin_system import pluginfunction, ptypes
|
from plugin_system import pluginfunction, ptypes
|
||||||
|
|
||||||
moin_strings_hi = [
|
moin_strings_hi = [
|
||||||
|
|||||||
Reference in New Issue
Block a user