-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revamp old slap plugin from extras so it can be installed as a package
- Loading branch information
0 parents
commit 1c6801e
Showing
8 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
Eiffel Forum License, version 2 | ||
|
||
1. Permission is hereby granted to use, copy, modify and/or | ||
distribute this package, provided that: | ||
* copyright notices are retained unchanged, | ||
* any distribution of this package, whether modified or not, | ||
includes this license text. | ||
2. Permission is hereby also granted to distribute binary programs | ||
which depend on this package. If the binary program depends on a | ||
modified version of this package, you are encouraged to publicly | ||
release the modified version of this package. | ||
|
||
*********************** | ||
|
||
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT WARRANTY. ANY EXPRESS OR | ||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY PARTY FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS PACKAGE. | ||
|
||
*********************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include NEWS | ||
include COPYING | ||
include README.md | ||
|
||
recursive-exclude * __pycache__ | ||
recursive-exclude * *.py[co] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# sopel-slap | ||
|
||
Plugin for Sopel that lets users slap each other in fun ways | ||
|
||
## Installation | ||
|
||
```sh | ||
pip install sopel-slap | ||
``` | ||
|
||
_Substitute the appropriate `pip` command based on your environment (e.g. | ||
`pip3` or `pip3.10` on systems with multiple Python versions available)._ | ||
|
||
_If your Sopel configuration requires it, run `sopel-plugins enable slap`, | ||
passing the appropriate config name to `-c` if you have multiple bots._ | ||
|
||
## Commands | ||
|
||
* **.slap** — Make the bot slap you | ||
* **.slap nickname [reason]** — Slap someone else, with an optional reason | ||
|
||
_If your bot has a non-default `prefix`, substitute it for `.` above._ | ||
|
||
## Credits | ||
|
||
This is based on the original `slap.py` from | ||
[sopel-extras](https://github.com/sopel-irc/sopel-extras) by Michael Yanovich, | ||
dating back to the late '00s/early '10s. It's been rewritten more or less from | ||
scratch to do things in the modern Sopel way. The only meaningful behavior | ||
change was dropping substitution of the caller's nick for `me` and `myself`, | ||
as it's quite possible for a real person to use either of those as a nick and | ||
_no one_\* should be safe from slaps! | ||
|
||
\* — No one except the bot and its admins, that is. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[metadata] | ||
name = sopel-slap | ||
version = 0.1.0 | ||
description = Plugin for Sopel that lets users slap each other in fun ways | ||
author = dgw | ||
author_email = [email protected] | ||
url = https://github.com/sopel-irc/sopel-slap | ||
license = Eiffel Forum License, version 2 | ||
classifiers = | ||
Intended Audience :: Developers | ||
Intended Audience :: System Administrators | ||
License :: Eiffel Forum License (EFL) | ||
License :: OSI Approved :: Eiffel Forum License | ||
Topic :: Communications :: Chat :: Internet Relay Chat | ||
|
||
[options] | ||
packages = find: | ||
zip_safe = false | ||
include_package_data = true | ||
install_requires = | ||
sopel>=7.0,<8 | ||
|
||
[options.entry_points] | ||
sopel.plugins = | ||
slap = sopel_slap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import print_function | ||
import os | ||
import sys | ||
from setuptools import setup, find_packages | ||
|
||
|
||
if __name__ == '__main__': | ||
print('Sopel does not correctly load plugins installed with setup.py ' | ||
'directly. Please use "pip install .", or add ' | ||
'{}/sopel_slap to core.extra in your config.' | ||
.format(os.path.dirname(os.path.abspath(__file__))), | ||
file=sys.stderr) | ||
|
||
with open('README.md') as readme_file: | ||
readme = readme_file.read() | ||
|
||
with open('NEWS') as history_file: | ||
history = history_file.read() | ||
|
||
|
||
setup( | ||
long_description=readme + '\n\n' + history, | ||
long_description_content_type='text/markdown', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# coding=utf8 | ||
"""sopel-slap | ||
Plugin for Sopel that lets users slap each other in fun ways | ||
Original slap.py copyright 2009, Michael Yanovich, yanovich.net | ||
This rewritten & packaged version for Sopel 7+ copyright 2023, dgw, technobabbl.es | ||
https://sopel.chat | ||
""" | ||
import random | ||
|
||
from sopel import formatting, plugin, tools | ||
|
||
|
||
VERBS = ( | ||
'annihilates', | ||
'destroys', | ||
'kicks', | ||
'owns', | ||
'punches', | ||
'pwns', | ||
'roundhouse kicks', | ||
'slaps', | ||
) | ||
|
||
|
||
@plugin.commands('slap', 'slaps') | ||
def slap(bot, trigger): | ||
"""Slap a <target> (e.g. nickname)""" | ||
target = trigger.group(3) | ||
|
||
if target is None: | ||
target = trigger.nick | ||
else: | ||
target = formatting.plain(target) | ||
|
||
if not isinstance(target, tools.Identifier): | ||
# TODO: For Sopel 8.0+ release, switch to new bot.make_identifier() method | ||
# will increase reliability of below "is nick" check | ||
target = tools.Identifier(target) | ||
|
||
if not target.is_nick(): | ||
bot.reply("You can't slap the whole channel!") | ||
return | ||
|
||
if target not in bot.channels[trigger.sender].users: | ||
bot.reply("You can't slap someone who isn't here!") | ||
return | ||
|
||
if target == bot.nick: | ||
if not trigger.admin: | ||
target = trigger.nick | ||
else: | ||
target = 'itself' | ||
|
||
if target in bot.config.core.admins and not trigger.admin: | ||
target = trigger.nick | ||
|
||
verb = random.choice(VERBS) | ||
|
||
bot.action("{} {}".format(verb, target)) |