Skip to content

Commit

Permalink
Merge pull request esi#34 from esi/fixes
Browse files Browse the repository at this point in the history
Fixes for stuff broken with latest merge
  • Loading branch information
mateuszkrasucki committed Feb 11, 2020
2 parents 51a9122 + 9c001a8 commit 2139b50
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ include-naming-hint=yes
[FORMAT]

expected-line-ending-format=LF
max-line-length=79
max-line-length=120


[MISCELLANEOUS]
Expand Down
7 changes: 3 additions & 4 deletions esi_bot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""ESI Slack bot."""


# pylint: disable=unused-argument,wrong-import-position,wrong-import-order
from gevent import monkey
monkey.patch_all()
Expand All @@ -16,11 +15,11 @@
import requests # noqa E402
from requests.adapters import HTTPAdapter # noqa E402


LOG = logging.getLogger(__name__)
LOG.setLevel(getattr(logging, os.environ.get("ESI_BOT_LOG_LEVEL", "INFO")))
LOG_LEVEL = getattr(logging, os.environ.get("ESI_BOT_LOG_LEVEL", "INFO"))
LOG.setLevel(LOG_LEVEL)
logging.basicConfig(
level=logging.INFO,
level=LOG_LEVEL,
format="%(asctime)s:%(name)s:%(levelname)s: %(message)s",
)

Expand Down
13 changes: 2 additions & 11 deletions esi_bot/bot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""ESI slack bot for tweetfleet."""


import os
import time

Expand All @@ -11,16 +10,8 @@
from esi_bot import LOG
from esi_bot import request
from esi_bot.processor import Processor
from esi_bot.commands import ( # pylint: disable=unused-import; # noqa F401
get_help,
issue_details,
issue_new,
links,
misc,
status_esi,
status_server,
type_info
)
from esi_bot.commands import ( # noqa: F401; # pylint: disable=unused-import
get_help, issue_details, issue_new, status_esi, status_server, type_info)


def main():
Expand Down
1 change: 1 addition & 0 deletions esi_bot/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""ESI Slack bot commands."""
14 changes: 6 additions & 8 deletions esi_bot/processor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Message processing for ESI-bot."""


import os
import re
import time
Expand All @@ -17,7 +16,6 @@
from esi_bot.users import Users
from esi_bot.channels import Channels


STARTUP_MSGS = (
"hello, world",
"how did I wake up here?",
Expand Down Expand Up @@ -45,17 +43,17 @@
)

REACTION_TRIGGERS = {
re.compile(r"(?:^|[\W_])crest(?:$|[\W_])", re.IGNORECASE): "rip",
re.compile(r"(?:^|[\W_])xml(?:[\W_]?api)?(?:$|[\W_])",
re.IGNORECASE): "wreck",
re.compile(r"(?:^|[\W_])crest(?:$|[\W_])", re.IGNORECASE):
"rip",
re.compile(r"(?:^|[\W_])xml(?:[\W_]?api)?(?:$|[\W_])", re.IGNORECASE):
"wreck",
}

UNMATCHED = object()


class Processor:
"""Execute ESI-bot commands based on incoming messages."""

def __init__(self, slack):
"""Create a new processor instance."""

Expand Down Expand Up @@ -117,7 +115,7 @@ def _send_snippet(self, reply, channel=None):
"""Send a snippet to the channel, or the primary channel."""

# There is a 1 megabyte file size limit for files uploaded as snippets.
megb = 1024 ** 2
megb = 1024**2
if len(reply.content) > megb:
snip = "<snipped>"
content = "{}{}".format(reply.content[:megb - len(snip)], snip)
Expand Down Expand Up @@ -230,7 +228,7 @@ def _process_event(self, timestamp, channel, user, text):
return False

user_name = self._users.get_name(user)
LOG.info(
LOG.debug(
"[%s] @%s: %s",
datetime.utcfromtimestamp(int(float(timestamp))),
user_name,
Expand Down
2 changes: 1 addition & 1 deletion esi_bot/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def request(match, msg):
except ValueError:
status = str(res.status_code)
else:
status = "{} {}".format(status.value, status.name)
status = "{} {}".format(status.value, status.name) # pylint: disable=E1101

if "--headers" in msg.args:
res = {"response": content, "headers": dict(res.headers)}
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
slackclient>=1.2.1
slackclient==1.3.2
requests>=2.18.4
setuphelpers>=0.1.2
gevent>=1.2.2
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
"""ESI slack bot."""


import os
from setuptools import setup
from setuptools import find_packages
from setuphelpers import git_version
from setuphelpers import test_command
from setuphelpers import long_description


setup(
name="esi-bot",
version=git_version(),
Expand All @@ -22,7 +20,7 @@
download_url="https://github.com/esi/esi-bot/",
install_requires=[
"requests >= 2.18.4",
"slackclient >= 1.2.1",
"slackclient == 1.3.2",
"gevent >= 1.2.2",
],
setup_requires=["setuphelpers >= 0.1.2"],
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ addopts = -rx -rs -v --cov-report term-missing
[flake8]
exclude = *.pyc,.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.ropeproject,.idea,.venv*,.pypy
ignore = E123,D202,D203,D413
max-line-length = 120

0 comments on commit 2139b50

Please sign in to comment.