white space fixes, reformat; update url_blacklist
This commit is contained in:
@@ -34,8 +34,11 @@ config = {
|
|||||||
'persistent_locked': False,
|
'persistent_locked': False,
|
||||||
|
|
||||||
'url_blacklist': [
|
'url_blacklist': [
|
||||||
r'^.*heise\.de/[^/]+/meldung/.*$',
|
r'^.*heise\.de/.*-[0-9]+\.html$',
|
||||||
r'^.*wikipedia\.org/wiki/.*$'
|
r'^.*wikipedia\.org/wiki/.*$',
|
||||||
|
r'^.*blog\.fefe\.de/\?ts=[0-9a-f]+$',
|
||||||
|
r'^.*ibash\.de/zitat.*$',
|
||||||
|
r'^.*golem\.de/news/.*$'
|
||||||
],
|
],
|
||||||
|
|
||||||
# the "dice" feature will use more efficient random data (0) for given users
|
# the "dice" feature will use more efficient random data (0) for given users
|
||||||
|
|||||||
44
plugins.py
44
plugins.py
@@ -93,7 +93,7 @@ def parse_cve(**args):
|
|||||||
'msg': 'https://security-tracker.debian.org/tracker/%s' % cves[0]
|
'msg': 'https://security-tracker.debian.org/tracker/%s' % cves[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
@pluginfunction("skynet", "parse skynet", ptypes.PARSE)
|
@pluginfunction("skynet", "parse skynet", ptypes.PARSE)
|
||||||
def parse_skynet(**args):
|
def parse_skynet(**args):
|
||||||
if 'skynet' in args['data'].lower():
|
if 'skynet' in args['data'].lower():
|
||||||
logger('plugin', 'sent skynet reply')
|
logger('plugin', 'sent skynet reply')
|
||||||
@@ -116,7 +116,7 @@ def data_parse_other(msg_obj):
|
|||||||
ratelimit_touch(RATE_CHAT)
|
ratelimit_touch(RATE_CHAT)
|
||||||
send_reply(ret['msg'], msg_obj)
|
send_reply(ret['msg'], msg_obj)
|
||||||
|
|
||||||
@pluginfunction("help", "print help for a command or all known commands", ptypes.COMMAND)
|
@pluginfunction("help", "print help for a command or all known commands", ptypes.COMMAND)
|
||||||
def command_help(argv,**args):
|
def command_help(argv,**args):
|
||||||
command = argv[0]
|
command = argv[0]
|
||||||
what = argv[1] if len(argv) > 1 else None
|
what = argv[1] if len(argv) > 1 else None
|
||||||
@@ -440,12 +440,12 @@ def command_cake(argv, **args):
|
|||||||
if 'cake' != argv[0]:
|
if 'cake' != argv[0]:
|
||||||
return
|
return
|
||||||
|
|
||||||
cakes = [ "No cake for you!",
|
cakes = [ "No cake for you!",
|
||||||
("The Enrichment Center is required to remind you "
|
("The Enrichment Center is required to remind you "
|
||||||
"that you will be baked, and then there will be cake."),
|
"that you will be baked, and then there will be cake."),
|
||||||
"The cake is a lie!",
|
"The cake is a lie!",
|
||||||
("This is your fault. I'm going to kill you. "
|
("This is your fault. I'm going to kill you. "
|
||||||
"And all the cake is gone. You don't even care, do you? "),
|
"And all the cake is gone. You don't even care, do you?"),
|
||||||
"Quit now and cake will be served immediately.",
|
"Quit now and cake will be served immediately.",
|
||||||
("Enrichment Center regulations require both hands to be "
|
("Enrichment Center regulations require both hands to be "
|
||||||
"empty before any cake..."),
|
"empty before any cake..."),
|
||||||
@@ -512,7 +512,7 @@ def command_plugin_activation(argv,**args):
|
|||||||
|
|
||||||
for c in plugins[ptypes.COMMAND]:
|
for c in plugins[ptypes.COMMAND]:
|
||||||
if c.plugin_name == plugin:
|
if c.plugin_name == plugin:
|
||||||
c.is_enabled = 'enable' == command
|
c.is_enabled = 'enable' == command
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'msg': args['reply_user'] + ': %sd %s' %(
|
'msg': args['reply_user'] + ': %sd %s' %(
|
||||||
@@ -545,12 +545,12 @@ def command_wp(argv,lang="de",**args):
|
|||||||
|
|
||||||
if query == "":
|
if query == "":
|
||||||
return {
|
return {
|
||||||
'msg': args['reply_user'] + ": You must enter a query"
|
'msg': args['reply_user'] + ": You must enter a query"
|
||||||
}
|
}
|
||||||
|
|
||||||
api = { "action" : "query", "prop" : "extracts", "explaintext": "" , "redirects": "",
|
api = { "action" : "query", "prop" : "extracts", "explaintext": "" , "redirects": "",
|
||||||
"exsentences" : 2, "continue" : "", "format" : "json", "titles" : query }
|
"exsentences" : 2, "continue" : "", "format" : "json", "titles" : query }
|
||||||
apiurl = "https://%s.wikipedia.org/w/api.php?%s" % (lang, urllib.parse.urlencode(api))
|
apiurl = "https://%s.wikipedia.org/w/api.php?%s" % (lang, urllib.parse.urlencode(api))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = urllib.request.urlopen(apiurl)
|
response = urllib.request.urlopen(apiurl)
|
||||||
@@ -569,13 +569,13 @@ def command_wp(argv,lang="de",**args):
|
|||||||
|
|
||||||
if short is not None:
|
if short is not None:
|
||||||
return {
|
return {
|
||||||
'msg': args['reply_user'] + ': %s (<%s>)' % (
|
'msg': args['reply_user'] + ': %s (<%s>)' % (
|
||||||
short if short.strip() else "(nix)", link
|
short if short.strip() else "(nix)", link
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
elif "missing" in page:
|
elif "missing" in page:
|
||||||
return { 'msg': 'Article "%s" not found' % page.get("title", query) }
|
return { 'msg': 'Article "%s" not found' % page.get("title", query) }
|
||||||
else:
|
else:
|
||||||
return { 'msg': "Something seems wrong with the json" }
|
return { 'msg': "Something seems wrong with the json" }
|
||||||
|
|
||||||
#def command_dummy(args):
|
#def command_dummy(args):
|
||||||
@@ -628,11 +628,13 @@ def data_parse_commands(msg_obj):
|
|||||||
if not p.is_enabled:
|
if not p.is_enabled:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ret = p(data = data,
|
ret = p(
|
||||||
cmd_list = [pl.plugin_name for pl in plugins[ptypes.COMMAND]],
|
data = data,
|
||||||
reply_user = reply_user,
|
cmd_list = [pl.plugin_name for pl in plugins[ptypes.COMMAND]],
|
||||||
msg_obj = msg_obj,
|
reply_user = reply_user,
|
||||||
argv = words[1:])
|
msg_obj = msg_obj,
|
||||||
|
argv = words[1:]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if None != ret:
|
if None != ret:
|
||||||
@@ -691,15 +693,15 @@ if debug_enabled():
|
|||||||
def register(func_type):
|
def register(func_type):
|
||||||
"""
|
"""
|
||||||
Register plugins.
|
Register plugins.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
func_type -- plugin functions with this type (ptypes) will be loaded
|
func_type -- plugin functions with this type (ptypes) will be loaded
|
||||||
"""
|
"""
|
||||||
|
|
||||||
functions = [f for n,f in globals().items() if type(f) == types.FunctionType
|
functions = [f for n,f in globals().items() if type(f) == types.FunctionType
|
||||||
and f.__dict__.get('is_plugin', False)
|
and f.__dict__.get('is_plugin', False)
|
||||||
and f.plugin_type == func_type]
|
and f.plugin_type == func_type]
|
||||||
|
|
||||||
logger('info', 'auto registering plugins: %s' % (", ".join(f.plugin_name for f in functions)))
|
logger('info', 'auto registering plugins: %s' % (", ".join(f.plugin_name for f in functions)))
|
||||||
|
|
||||||
for f in functions:
|
for f in functions:
|
||||||
@@ -709,7 +711,7 @@ def register_plugin(function, func_type):
|
|||||||
try:
|
try:
|
||||||
plugins[func_type].append(function)
|
plugins[func_type].append(function)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger('warn', 'registering %s failed: %s, %s' %
|
logger('warn', 'registering %s failed: %s, %s' %
|
||||||
(function, e, traceback.format_exc()))
|
(function, e, traceback.format_exc()))
|
||||||
|
|
||||||
def register_all():
|
def register_all():
|
||||||
|
|||||||
Reference in New Issue
Block a user