Skip to content

Commit e4bc422

Browse files
committed
Plugin: Add command to display the path to a plugin's code
1 parent ddd2eea commit e4bc422

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

plugins/Plugin/plugin.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
# POSSIBILITY OF SUCH DAMAGE.
3030
###
3131

32-
import supybot
32+
import sys
3333

34+
import supybot
3435
import supybot.utils as utils
3536
from supybot.commands import *
3637
import supybot.plugins as plugins
@@ -122,9 +123,21 @@ def plugins(self, irc, msg, args, command):
122123
irc.reply(format(_('The %q command is available in the %L %s.'),
123124
command, L, plugin))
124125
else:
125-
irc.error(format('There is no command %q.', command))
126+
irc.error(format(_('There is no command %q.'), command))
126127
plugins = wrap(plugins, [many('something')])
127128

129+
@internationalizeDocstring
130+
def path(self, irc, msg, args, name):
131+
"""<name>
132+
133+
Returns the path where a plugin is loaded from.
134+
"""
135+
cb = irc.getCallback(name)
136+
if cb is None:
137+
irc.error(format(_('There is no plugin %s'), name), Raise=True)
138+
irc.reply(sys.modules[cb.__module__].__file__)
139+
path = wrap(path, ['owner', 'somethingWithoutSpaces'])
140+
128141
def author(self, irc, msg, args, cb):
129142
"""<plugin>
130143

0 commit comments

Comments
 (0)