1
0
mirror of http://aero2k.de/t/repos/urlbot-native.git synced 2017-09-06 15:25:38 +02:00

whitespace and import fixes

This commit is contained in:
Thorsten
2016-04-05 18:40:31 +02:00
parent c6baf3cf60
commit 550fa44f42
15 changed files with 43 additions and 37 deletions

View File

@@ -10,6 +10,7 @@ BUFSIZ = 8192
USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:31.0) ' \
'Gecko/20100101 Firefox/31.0 Iceweasel/31.0'
def get_version_git():
import subprocess

View File

@@ -7,6 +7,7 @@ EVENTLOOP_DELAY = 0.100 # seconds
event_list = sched.scheduler(time.time, time.sleep)
def register_active_event(t, callback, args, action_runner, plugin, msg_obj):
"""
Execute a callback at a given time and react on the output
@@ -31,9 +32,6 @@ def register_event(t, callback, args):
class EventLoop(threading.Thread):
#def __init__(self):
# threading.Thread.__init__(self)
def run(self):
while 1:
event_list.run(False)

View File

@@ -1,15 +1,17 @@
# -*- coding: utf-8 -*-
from enum import Enum
import config
from rate_limit import RATE_GLOBAL
class ptypes(Enum):
PARSE = 1
COMMAND = 2
MUC_ONLINE = 3
plugin_storage = { ptype: [] for ptype in ptypes }
plugin_storage = {ptype: [] for ptype in ptypes}
def pluginfunction(name, desc, plugin_type, ratelimit_class=RATE_GLOBAL, enabled=True):
"""A decorator to make a plugin out of a function
@@ -35,7 +37,7 @@ def pluginfunction(name, desc, plugin_type, ratelimit_class=RATE_GLOBAL, enabled
return decorate
#def plugin_alias(name):
# def plugin_alias(name):
# """A decorator to add an alias to a plugin function"""
#
# def decorate(f):
@@ -55,11 +57,8 @@ def plugin_enabled_get(urlbot_plugin):
@config.config_locked
def plugin_enabled_set(plugin, enabled):
if plugin.plugin_name not in config.runtime_config_store['plugins']:
config.runtime_config_store['plugins'][plugin.plugin_name] = {}
config.runtime_config_store['plugins'][plugin.plugin_name]['enabled'] = enabled
config.runtimeconf_persist()

View File

@@ -3,7 +3,7 @@
from os.path import dirname, basename, isfile
from glob import glob
__all__ = [ ]
__all__ = []
for f in glob(dirname(__file__) + "/*.py"):
if not basename(f).startswith('_') and isfile(f):

View File

@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
import random
from common import giphy
from plugin_system import pluginfunction, ptypes
from rate_limit import RATE_FUN, RATE_GLOBAL
@pluginfunction('cake', 'displays a cake ASCII art', ptypes.COMMAND, ratelimit_class=RATE_FUN | RATE_GLOBAL)
def command_cake(argv, **args):
if {'please', 'bitte'}.intersection(set(argv)):

View File

@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import logging
log = logging.getLogger(__name__)
import events
import json
@@ -13,9 +12,11 @@ import requests
from lxml import etree
import config
from common import VERSION, giphy, get_nick_from_object
from common import VERSION
from rate_limit import RATE_FUN, RATE_GLOBAL, RATE_INTERACTIVE, RATE_NO_SILENCE, RATE_NO_LIMIT
from plugin_system import pluginfunction, ptypes, plugin_storage
from plugin_system import pluginfunction, ptypes, plugin_storage, plugin_enabled_get, plugin_enabled_set
log = logging.getLogger(__name__)
@pluginfunction('help', 'print help for a command or all known commands', ptypes.COMMAND)
def command_help(argv, **args):
@@ -779,6 +780,7 @@ def repeat_message(argv, **args):
'msg': args['stack'][-1]['body']
}
@pluginfunction('isdown', 'check if a website is reachable', ptypes.COMMAND)
def isdown(argv, **args):
if not argv:
@@ -850,4 +852,3 @@ def poll(argv, **args):
@pluginfunction('vote', 'alias for poll', ptypes.COMMAND)
def vote(argv, **args):
return poll(argv, **args)

View File

@@ -1,17 +1,18 @@
# -*- coding: utf-8 -*-
import logging
log = logging.getLogger(__name__)
import time
import random
import config
from plugin_system import pluginfunction, ptypes
log = logging.getLogger(__name__)
comment_joins_strings = [
"%s: please consider to fix your internet connection"
]
@pluginfunction('comment_joins', 'comments frequent joins', ptypes.MUC_ONLINE)
@config.config_locked
def comment_joins(**args):
@@ -46,4 +47,3 @@ def comment_joins(**args):
user_joins.append(current_timestamp)
config.runtime_config_store['user_joins'][arg_user_key] = user_joins
config.runtimeconf_persist()

View File

@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
import logging
log = logging.getLogger(__name__)
import random
from plugin_system import pluginfunction, ptypes
log = logging.getLogger(__name__)
@pluginfunction('excuse', 'prints BOFH style excuses', ptypes.COMMAND)
def command_excuse(argv, **args):

View File

@@ -1,9 +1,12 @@
# -*- coding: utf-8 -*-
import logging
log = logging.getLogger(__name__)
import re
import random
import config
from plugin_system import pluginfunction, ptypes
log = logging.getLogger(__name__)
moin_strings_hi = [
'Hi',
@@ -19,6 +22,7 @@ moin_strings_bye = [
'bye',
]
@pluginfunction('moin', 'parse hi/bye', ptypes.PARSE, enabled=False)
def parse_moin(**args):
for direction in [moin_strings_hi, moin_strings_bye]:
@@ -73,5 +77,3 @@ def command_show_moinlist(argv, **args):
])
)
}

View File

@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import logging
log = logging.getLogger(__name__)
import random
import re
@@ -11,6 +10,8 @@ from common import extract_title
from rate_limit import RATE_NO_SILENCE, RATE_GLOBAL, RATE_FUN, RATE_URL
from config import runtimeconf_get
from plugin_system import pluginfunction, ptypes
log = logging.getLogger(__name__)
@pluginfunction('mental_ill', 'parse mental illness', ptypes.PARSE, ratelimit_class=RATE_NO_SILENCE | RATE_GLOBAL)
def parse_mental_ill(**args):

View File

@@ -9,6 +9,7 @@ import time
import config
from plugin_system import pluginfunction, ptypes
@pluginfunction('quiz', 'play quiz', ptypes.COMMAND)
def quiz_control(argv, **args):
usage = """quiz mode usage: "quiz start [secs interval:default 30]", "quiz stop", "quiz rules;

View File

@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
import logging
import time
import config
from common import get_nick_from_object
from plugin_system import pluginfunction, ptypes
log = logging.getLogger(__name__)
import time
import config
from plugin_system import pluginfunction, ptypes
@pluginfunction('send_record', 'delivers previously saved message to user', ptypes.MUC_ONLINE)
@config.config_locked
@@ -21,13 +21,13 @@ def send_record(**args):
return None
response = {
'msg': '%s, there %s %d message%s for you:\n%s' % (
arg_user,
'is' if len(records) == 1 else 'are',
len(records),
'' if len(records) == 1 else 's',
'\n'.join(records)
)
'msg': '%s, there %s %d message%s for you:\n%s' % (
arg_user,
'is' if len(records) == 1 else 'are',
len(records),
'' if len(records) == 1 else 's',
'\n'.join(records)
)
}
user_records.pop(arg_user_key)
@@ -35,6 +35,7 @@ def send_record(**args):
return response
@pluginfunction(
'record', 'record a message for a now offline user (usage: record {user} {some message};'
' {some message} == "previous" to use the last channel message)', ptypes.COMMAND)
@@ -85,4 +86,3 @@ def command_show_recordlist(argv, **args):
)
)
}

View File

@@ -2,12 +2,12 @@
import re
import shlex
import json
import requests
import config
from plugin_system import pluginfunction, ptypes
@pluginfunction('translate', 'translate text fragments, use "translate show" to get a list of languages'
'or "translate that" to get the last message translated (to german)', ptypes.COMMAND)
def translate(argv, **args):

View File

@@ -33,6 +33,7 @@ buckets = {
rate_limit_classes = buckets.keys()
def rate_limit(rate_class=RATE_GLOBAL):
"""
Remember N timestamps,

View File

@@ -8,7 +8,7 @@ import time
import unittest
from collections import namedtuple
from common import buckets, rate_limit, RATE_GLOBAL
from rate_limit import RATE_GLOBAL, rate_limit, buckets
class TestEventlooper(unittest.TestCase):