Skip to content

Commit

Permalink
black fmting
Browse files Browse the repository at this point in the history
  • Loading branch information
jrabbit committed Mar 30, 2018
1 parent ac2bb0f commit facc708
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 40 deletions.
3 changes: 2 additions & 1 deletion pyborg/pyborg/mod/mod_discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def _extract_emoji(self, msg: str, server_emojis:List[str]) -> str:
logger.info(incoming_message)
return incoming_message
else:
logger.info("someone did a fucky wucky")
logger.info("_extract_emoji:someone did a fucky wucky")
logger.debug("_extract_emoji:OOPSIE WOOPSIE!! Uwu We made a fucky wucky!! A wittle fucko boingo! The code monkeys at our headquarters are working VEWY HAWD to fix this!")
return msg

async def on_message(self, message: discord.Message) -> None:
Expand Down
3 changes: 1 addition & 2 deletions pyborg/pyborg/pyborg.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def do_commands(self, io_module, body, args, owner):
else:
num_cpw = 0.0
msg = "I know %d words (%d contexts, %.2f per word), %d lines." % (num_w, num_c, num_cpw, num_l)

# Do i know this word
elif command_list[0] == "!known":
if len(command_list) == 2:
Expand Down Expand Up @@ -998,7 +998,6 @@ def reply(self, body):
# if w in self.words:
# logger.debug(self.words[w])
# k = len(self.words[w])

# d[w] = k
# logger.debug("find_known_words: %s", d)
# idx = [x for x,y in d.items() if y > 3]
Expand Down
60 changes: 38 additions & 22 deletions pyborg/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,46 @@
from pyborg import __version__


requires = ["irc>=15.1.1", "toml",
"arrow==0.10.0", "PyTumblr==0.0.6", "requests", "bottle",
"venusian", "click", "humanize", "praw", "Mastodon.py",
"lxml", "attrs", "statsd", "prompt_toolkit"]
requires = [
"irc>=15.1.1",
"toml",
"arrow==0.10.0",
"PyTumblr==0.0.6",
"requests",
"bottle",
"venusian",
"click",
"humanize",
"praw",
"Mastodon.py",
"lxml",
"attrs",
"statsd",
"prompt_toolkit",
]
if sys.version_info >= (3,):
requires.extend(["discord.py", "aeidon"])
setup(name="pyborg",
version=__version__,
packages=["pyborg", "pyborg.util", "pyborg.mod"],
scripts=['pyborg-irc.py',
'pyborg_experimental.py'],
author="Jack Laxson",
author_email="[email protected]",
description="Markov chain bot for irc which generates replies to messages",
license="GPL v3 or later",
install_requires=requires,
entry_points='''
setup(
name="pyborg",
version=__version__,
packages=["pyborg", "pyborg.util", "pyborg.mod"],
scripts=['pyborg-irc.py', 'pyborg_experimental.py'],
author="Jack Laxson",
author_email="[email protected]",
description="Markov chain bot for irc which generates replies to messages",
license="GPL v3 or later",
install_requires=requires,
entry_points='''
[console_scripts]
pyborg=pyborg_experimental:cli_base
''',
url="https://github.com/jrabbit/pyborg-1up/",
classifiers=["License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Topic :: Communications :: Chat :: Internet Relay Chat",
"Topic :: Games/Entertainment",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",])
url="https://github.com/jrabbit/pyborg-1up/",
classifiers=[
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Topic :: Communications :: Chat :: Internet Relay Chat",
"Topic :: Games/Entertainment",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
],
)
39 changes: 24 additions & 15 deletions pyborg/test/test_tumblr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,35 @@
if sys.version_info < (3,):
import mock
import pyborg


class TestBot(unittest.TestCase):
settings = {'auth': {'consumer_key': 'KEY',
'consumer_secret': 'SECRET',
'oauth_secret': 'TOKEN',
'oauth_token': 'TOKEN'},
'pyborg': {'multiplex': False},
'tumblr': {'blog': 'billoreilly.tumblr.com',
'cooldown': 20,
'ignore': [],
'last_look': datetime.datetime(2016, 8, 18, 7, 25, 30, 164769),
'learning': False,
'tags': ['hello bill']}}
settings = {
'auth': {
'consumer_key': 'KEY',
'consumer_secret': 'SECRET',
'oauth_secret': 'TOKEN',
'oauth_token': 'TOKEN',
},
'pyborg': {'multiplex': False},
'tumblr': {
'blog': 'billoreilly.tumblr.com',
'cooldown': 20,
'ignore': [],
'last_look': datetime.datetime(2016, 8, 18, 7, 25, 30, 164769),
'learning': False,
'tags': ['hello bill'],
},
}
with open("pyborg/test/fixtures/tumblr_posts.json") as fixture_f:
posts = json.load(fixture_f)

@mock.patch('pyborg.pyborg.pyborg')
@mock.patch('pyborg.mod.mod_tumblr.logger.info')
@mock.patch('pyborg.pyborg.pyborg.reply')
@mock.patch('toml.load')
def test_handle_post(self, patched_load, patched_pyborg, patched_info, pybpybpyb):
def test_handle_post(
self, patched_load, patched_pyborg, patched_info, pybpybpyb
):
patched_load.return_value = self.settings
mod = pyborg.mod.mod_tumblr.PyborgTumblr("bogus.toml")

Expand All @@ -38,7 +45,8 @@ def test_handle_post(self, patched_load, patched_pyborg, patched_info, pybpybpyb
patched_load.assert_called_once_with("bogus.toml")
patched_pyborg.return_value = "fuck it do it live"
patched_info.assert_any_call("found post: \n%s", self.posts[0]['summary'])
# print(patched_info.mock_calls)

# print(patched_info.mock_calls)

@mock.patch('pytumblr.TumblrRestClient.tagged')
@mock.patch('pyborg.pyborg.pyborg')
Expand All @@ -49,7 +57,8 @@ def test_load_new(self, patched_load, pybpybpyb, patched_tagged):
mod = pyborg.mod.mod_tumblr.PyborgTumblr("bogus.toml")
ret = mod.load_new_from_tag("hello bill")
patched_tagged.assert_called_once_with("hello bill")
# self.assertEqual(ret, )

# self.assertEqual(ret, )

@mock.patch('time.sleep')
@mock.patch('pyborg.mod.mod_tumblr.PyborgTumblr.load_new_from_tag')
Expand Down

0 comments on commit facc708

Please sign in to comment.