Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cruft from modules #1402

Merged
merged 42 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
fc4b726
version: remove unused regex
dgw Oct 27, 2018
51b3b2c
reload: old_callables is orphaned code from 5 years ago
freeboson May 4, 2018
4bde7a4
admin: Operation Cruft Cleanup
dgw Apr 16, 2019
a970772
adminchannel: Operation Cruft Cleanup
dgw Apr 16, 2019
9cc961e
announce: Operation Cruft Cleanup
dgw Apr 16, 2019
537d73c
bugzilla: Operation Cruft Cleanup
dgw Apr 16, 2019
0092a8d
calc: Operation Cruft Cleanup
dgw Apr 16, 2019
b10b3a7
clock: Operation Cruft Cleanup
dgw Apr 16, 2019
07dcdbc
countdown: Operation Cruft Cleanup
dgw Apr 16, 2019
1cfe818
currency: Operation Cruft Cleanup
dgw Apr 16, 2019
fc97d3f
dice: Operation Cruft Cleanup
dgw Apr 16, 2019
3961045
emoticons: Operation Cruft Cleanup
dgw Apr 16, 2019
9e7e4b0
etymology: Operation Cruft Cleanup
dgw Apr 16, 2019
be18464
find: Operation Cruft Cleanup
dgw Apr 16, 2019
df348be
find_updates: Operation Cruft Cleanup
dgw Apr 16, 2019
b5bb441
help: Operation Cruft Cleanup
dgw Apr 16, 2019
4fac190
instagram: Operation Cruft Cleanup
dgw Apr 16, 2019
b8f9461
ip: Operation Cruft Cleanup
dgw Apr 16, 2019
afc694f
ipython: Operation Cruft Cleanup
dgw Apr 16, 2019
99486f7
isup: Operation Cruft Cleanup
dgw Apr 16, 2019
e4b4aa4
lmgtfy: Operation Cruft Cleanup
dgw Apr 16, 2019
db2f013
meetbot: Operation Cruft Cleanup
dgw Apr 16, 2019
a7550d4
ping: Operation Cruft Cleanup
dgw Apr 16, 2019
95054e9
pronouns: Operation Cruft Cleanup
dgw Apr 16, 2019
bc36c15
rand: Operation Cruft Cleanup
dgw Apr 16, 2019
d5506b7
reddit: Operation Cruft Cleanup
dgw Apr 16, 2019
832b944
reload: Operation Cruft Cleanup
dgw Apr 16, 2019
44d08a4
safety: Operation Cruft Cleanup
dgw Apr 16, 2019
4b4dde9
search: Operation Cruft Cleanup
dgw Apr 16, 2019
cb391af
seen: Operation Cruft Cleanup
dgw Apr 16, 2019
91211a4
spellcheck: Operation Cruft Cleanup
dgw Apr 16, 2019
236f15e
tell: Operation Cruft Cleanup
dgw Apr 16, 2019
dac2db9
tld: Operation Cruft Cleanup
dgw Apr 16, 2019
e35d29c
translate: Operation Cruft Cleanup
dgw Apr 16, 2019
2afd7a5
units: Operation Cruft Cleanup
dgw Apr 16, 2019
64219fc
uptime: Operation Cruft Cleanup
dgw Apr 16, 2019
538a3c3
unicode_info: Operation Cruft Cleanup
dgw Apr 16, 2019
afe4d7c
url: Operation Cruft Cleanup
dgw Apr 16, 2019
4b5815d
version: pre-emptively fix import order
dgw Apr 16, 2019
e9159a5
wikipedia: Operation Cruft Cleanup
dgw Apr 16, 2019
12c6744
wiktionary: Operation Cruft Cleanup
dgw Apr 16, 2019
0de6224
xkcd: Operation Cruft Cleanup
dgw Apr 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions sopel/modules/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(yanovich.net)
Copyright © 2012, Elad Alfassa, <elad@fedoraproject.org>
Copyright 2013, Ari Koivula <ari@koivu.la>

Copyright 2019, Florian Strzelecki, https://github.com/Exirel
Licensed under the Eiffel Forum License 2.

https://sopel.chat
Expand Down Expand Up @@ -212,9 +212,7 @@ def me(bot, trigger):
@sopel.module.rule('.*')
@sopel.module.priority('low')
def invite_join(bot, trigger):
"""
Join a channel Sopel is invited to, if the inviter is an admin.
"""
"""Join a channel Sopel is invited to, if the inviter is an admin."""
if trigger.admin or bot.config.admin.auto_accept_invite:
bot.join(trigger.args[1])
return
Expand Down
66 changes: 37 additions & 29 deletions sopel/modules/adminchannel.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# coding=utf-8
# Copyright 2010-2011, Michael Yanovich, Alek Rollyson, and Elsie Powell
# Copyright © 2012, Elad Alfassa <elad@fedoraproject.org>
# Licensed under the Eiffel Forum License 2.
"""
adminchannel.py - Sopel Channel Admin Module
Copyright 2010-2011, Michael Yanovich, Alek Rollyson, and Elsie Powell
Copyright © 2012, Elad Alfassa <elad@fedoraproject.org>
Licensed under the Eiffel Forum License 2.

https://sopel.chat
"""
from __future__ import unicode_literals, absolute_import, print_function, division

import re

from sopel import formatting
from sopel.module import commands, priority, OP, HALFOP, require_privilege, require_chanmsg
from sopel.module import (
commands, example, priority, OP, HALFOP, require_privilege, require_chanmsg
)
from sopel.tools import Identifier


Expand All @@ -24,9 +32,7 @@ def default_mask(trigger):
@commands('kick')
@priority('high')
def kick(bot, trigger):
"""
Kick a user from the channel.
"""
"""Kick a user from the channel."""
if bot.channels[trigger.sender].privileges[bot.nick] < HALFOP:
return bot.reply("I'm not a channel operator!")
text = trigger.group().split()
Expand Down Expand Up @@ -75,9 +81,9 @@ def configureHostMask(mask):
@commands('ban')
@priority('high')
def ban(bot, trigger):
"""
This give admins the ability to ban a user.
The bot must be a Channel Operator for this command to work.
"""Ban a user from the channel

The bot must be a channel operator for this command to work.
"""
if bot.channels[trigger.sender].privileges[bot.nick] < HALFOP:
return bot.reply("I'm not a channel operator!")
Expand All @@ -103,9 +109,9 @@ def ban(bot, trigger):
@require_privilege(OP, 'You are not a channel operator.')
@commands('unban')
def unban(bot, trigger):
"""
This give admins the ability to unban a user.
The bot must be a Channel Operator for this command to work.
"""Unban a user from the channel

The bot must be a channel operator for this command to work.
"""
if bot.channels[trigger.sender].privileges[bot.nick] < HALFOP:
return bot.reply("I'm not a channel operator!")
Expand All @@ -131,9 +137,9 @@ def unban(bot, trigger):
@require_privilege(OP, 'You are not a channel operator.')
@commands('quiet')
def quiet(bot, trigger):
"""
This gives admins the ability to quiet a user.
The bot must be a Channel Operator for this command to work.
"""Quiet a user

The bot must be a channel operator for this command to work.
"""
if bot.channels[trigger.sender].privileges[bot.nick] < OP:
return bot.reply("I'm not a channel operator!")
Expand All @@ -159,9 +165,9 @@ def quiet(bot, trigger):
@require_privilege(OP, 'You are not a channel operator.')
@commands('unquiet')
def unquiet(bot, trigger):
"""
This gives admins the ability to unquiet a user.
The bot must be a Channel Operator for this command to work.
"""Unquiet a user

The bot must be a channel operator for this command to work.
"""
if bot.channels[trigger.sender].privileges[bot.nick] < OP:
return bot.reply("I'm not a channel operator!")
Expand All @@ -186,12 +192,12 @@ def unquiet(bot, trigger):
@require_chanmsg
@require_privilege(OP, 'You are not a channel operator.')
@commands('kickban', 'kb')
@example('.kickban [#chan] user1 user!*@* get out of here')
@priority('high')
def kickban(bot, trigger):
"""
This gives admins the ability to kickban a user.
The bot must be a Channel Operator for this command to work.
.kickban [#chan] user1 user!*@* get out of here
"""Kick and ban a user from the channel

The bot must be a channel operator for this command to work.
"""
if bot.channels[trigger.sender].privileges[bot.nick] < HALFOP:
return bot.reply("I'm not a channel operator!")
Expand Down Expand Up @@ -223,9 +229,9 @@ def kickban(bot, trigger):
@require_privilege(OP, 'You are not a channel operator.')
@commands('topic')
def topic(bot, trigger):
"""
This gives ops the ability to change the topic.
The bot must be a Channel Operator for this command to work.
"""Change the channel topic

The bot must be a channel operator for this command to work.
"""
if bot.channels[trigger.sender].privileges[bot.nick] < HALFOP:
return bot.reply("I'm not a channel operator!")
Expand Down Expand Up @@ -258,9 +264,11 @@ def topic(bot, trigger):
@require_privilege(OP, 'You are not a channel operator.')
@commands('tmask')
def set_mask(bot, trigger):
"""
Set the mask to use for .topic in the current channel. {} is used to allow
substituting in chunks of text.
"""Set the topic mask to use for the current channel

Within the topic mask, {} is used to allow substituting in chunks of text.

This mask is used when running the 'topic' command.
"""
bot.db.set_channel_value(trigger.sender, 'topic_mask', trigger.group(2))
bot.say("Gotcha, " + trigger.nick)
Expand Down
8 changes: 4 additions & 4 deletions sopel/modules/announce.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# coding=utf-8
"""
announce.py - Send a message to all channels
announce.py - Sopel Announcement Module
Sends announcements to all channels the bot has joined.
Copyright © 2013, Elad Alfassa, <elad@fedoraproject.org>
Licensed under the Eiffel Forum License 2.

https://sopel.chat
"""
from __future__ import unicode_literals, absolute_import, print_function, division

Expand All @@ -14,9 +16,7 @@
@example('.announce Some important message here')
@require_admin('Sorry, I can\'t let you do that', reply=True)
def announce(bot, trigger):
"""
Send an announcement to all channels the bot is in
"""
"""Send an announcement to all channels the bot is in"""
for channel in bot.channels:
bot.msg(channel, '[ANNOUNCEMENT] %s' % trigger.group(2))
bot.reply('Announce complete.')
8 changes: 5 additions & 3 deletions sopel/modules/bugzilla.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# coding=utf-8
"""Bugzilla issue reporting module

"""
bugzilla.py - Sopel Bugzilla Module
Copyright 2013-2015, Embolalia, embolalia.com
Licensed under the Eiffel Forum License 2.

https://sopel.chat
"""
from __future__ import unicode_literals, absolute_import, print_function, division

import re
import requests

import requests
import xmltodict

from sopel.config.types import StaticSection, ListAttribute
Expand Down
6 changes: 4 additions & 2 deletions sopel/modules/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
"""
from __future__ import unicode_literals, absolute_import, print_function, division

import sys

from requests import get

from sopel.module import commands, example
from sopel.tools.calculation import eval_equation
from requests import get
import sys

if sys.version_info.major < 3:
from urllib import quote as _quote
Expand Down
45 changes: 22 additions & 23 deletions sopel/modules/clock.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# coding=utf-8
# Copyright 2008-9, Sean B. Palmer, inamidst.com
# Copyright 2012, Elsie Powell, embolalia.com
# Licensed under the Eiffel Forum License 2.
"""
clock.py - Sopel Clock Module
Copyright 2008-9, Sean B. Palmer, inamidst.com
Copyright 2012, Elsie Powell, embolalia.com
Licensed under the Eiffel Forum License 2.

https://sopel.chat
"""
from __future__ import unicode_literals, absolute_import, print_function, division

try:
import pytz
except ImportError:
pytz = None

from sopel.module import commands, example, OP
from sopel.tools.time import (
get_timezone, format_time, validate_format, validate_timezone
)
from sopel.config.types import StaticSection, ValidatedAttribute

try:
import pytz
except ImportError:
pytz = None


class TimeSection(StaticSection):
tz = ValidatedAttribute(
Expand Down Expand Up @@ -97,9 +102,7 @@ def update_user(bot, trigger):
@commands('gettz', 'gettimezone')
@example('.gettz [nick]')
def get_user_tz(bot, trigger):
"""
Gets a user's preferred time zone; will show yours if no user specified.
"""
"""Gets a user's preferred time zone; will show yours if no user specified."""
if not pytz:
bot.reply("Sorry, I don't have timezone support installed.")
else:
Expand All @@ -125,8 +128,8 @@ def update_user_format(bot, trigger):
"""
tformat = trigger.group(2)
if not tformat:
bot.reply("What format do you want me to use? Try using"
" http://strftime.net to make one.")
bot.reply("What format do you want me to use? Try using "
"http://strftime.net to make one.")
return

tz = get_timezone(bot.db, bot.config, None, trigger.nick, trigger.sender)
Expand All @@ -140,8 +143,8 @@ def update_user_format(bot, trigger):
try:
timef = format_time(db=bot.db, zone=tz, nick=trigger.nick)
except Exception: # TODO: Be specific
bot.reply("That format doesn't work. Try using"
" http://strftime.net to make one.")
bot.reply("That format doesn't work. Try using "
"http://strftime.net to make one.")
# New format doesn't work. Revert save in database.
bot.db.set_nick_value(trigger.nick, 'time_format', old_format)
return
Expand All @@ -153,9 +156,7 @@ def update_user_format(bot, trigger):
@commands('gettimeformat', 'gettf')
@example('.gettf [nick]')
def get_user_format(bot, trigger):
"""
Gets a user's preferred time format; will show yours if no user specified.
"""
"""Gets a user's preferred time format; will show yours if no user specified."""
nick = trigger.group(2)
if not nick:
nick = trigger.nick
Expand All @@ -174,9 +175,7 @@ def get_user_format(bot, trigger):
@commands('setchanneltz', 'setctz')
@example('.setctz America/New_York')
def update_channel(bot, trigger):
"""
Set the preferred timezone for the channel.
"""
"""Set the preferred timezone for the channel."""
if bot.channels[trigger.sender].privileges[trigger.nick] < OP:
return
elif not pytz:
Expand Down Expand Up @@ -236,8 +235,8 @@ def update_channel_format(bot, trigger):

tformat = trigger.group(2)
if not tformat:
bot.reply("What format do you want me to use? Try using"
" http://strftime.net to make one.")
bot.reply("What format do you want me to use? Try using "
"http://strftime.net to make one.")

tz = get_timezone(bot.db, bot.config, None, None, trigger.sender)

Expand Down
16 changes: 9 additions & 7 deletions sopel/modules/countdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
"""
from __future__ import unicode_literals, absolute_import, print_function, division

from sopel.module import commands, NOLIMIT
import datetime

from sopel.module import commands, NOLIMIT


@commands('countdown')
def generic_countdown(bot, trigger):
"""
.countdown <year> <month> <day> - displays a countdown to a given date.
"""
""".countdown <year> <month> <day> - displays a countdown to a given date."""
text = trigger.group(2)
if not text:
bot.say("Please use correct format: .countdown 2012 12 21")
bot.say("Please use correct format: {}countdown 2012 12 21"
.format(bot.config.core.help_prefix))
return NOLIMIT
text = trigger.group(2).split()
if text and (len(text) == 3 and text[0].isdigit() and
Expand All @@ -28,11 +28,13 @@ def generic_countdown(bot, trigger):
diff = (datetime.datetime(int(text[0]), int(text[1]),
int(text[2])) - datetime.datetime.today())
except Exception: # TODO: Be specific
bot.say("Please use correct format: .countdown 2012 12 21")
bot.say("Please use correct format: {}countdown 2012 12 21"
.format(bot.config.core.help_prefix))
return NOLIMIT
bot.say(str(diff.days) + " days, " + str(diff.seconds // 3600) +
" hours and " + str(diff.seconds % 3600 // 60) +
" minutes until " + text[0] + " " + text[1] + " " + text[2])
else:
bot.say("Please use correct format: .countdown 2012 12 21")
bot.say("Please use correct format: {}countdown 2012 12 21"
.format(bot.config.core.help_prefix))
return NOLIMIT
12 changes: 10 additions & 2 deletions sopel/modules/currency.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# coding=utf-8
# Copyright 2013 Elsie Powell, embolalia.com
# Licensed under the Eiffel Forum License 2
"""
currency.py - Sopel Currency Conversion Module
Copyright 2013, Elsie Powell, embolalia.com
Licensed under the Eiffel Forum License 2.

https://sopel.chat
"""
from __future__ import unicode_literals, absolute_import, print_function, division

import re

from requests import get

from sopel.module import commands, example, NOLIMIT


# The Canadian central bank has better exchange rate data than the Fed, the
# Bank of England, or the European Central Bank. Who knew?
base_url = 'https://www.bankofcanada.ca/valet/observations/FX{}CAD/json'
Expand Down Expand Up @@ -83,6 +90,7 @@ def display(bot, amount, of, to):
@commands('btc', 'bitcoin')
@example('.btc 20 EUR')
def bitcoin(bot, trigger):
"""Convert between Bitcoin and a fiat currency"""
# if 2 args, 1st is number and 2nd is currency. If 1 arg, it's either the number or the currency.
to = trigger.group(4)
amount = trigger.group(3)
Expand Down
Loading