X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/10e2a6b9de8d05cd2fa3b4c9a76b2c32fddbbf48..a62d0d18bbb5926d22df18db5eba53eb21a10817:/modules/resources.py diff --git a/modules/resources.py b/modules/resources.py index 27cc7da..016e4bd 100644 --- a/modules/resources.py +++ b/modules/resources.py @@ -1,13 +1,14 @@ # Erebus IRC bot - Author: Erebus Team -# simple module example +# resource-usage module # This file is released into the public domain; see http://unlicense.org/ # module info modinfo = { 'author': 'Erebus Team', 'license': 'public domain', - 'compatible': [1], # compatible module API versions - 'depends': [], # other modules required to work properly? + 'compatible': [1,2], + 'depends': [], + 'softdeps': ['help'], } # preamble @@ -20,6 +21,7 @@ modstop = lib.modstop import resource @lib.hook(needchan=False, glevel=lib.MANAGER) +@lib.help(None, "show RAM usage") def ram(bot, user, chan, realtarget, *args): if chan is not None and realtarget == chan.name: replyto = chan else: replyto = user @@ -29,9 +31,10 @@ def ram(bot, user, chan, realtarget, *args): except: res = resource.getrusage(resource.RUSAGE_SELF) - bot.msg(replyto, "Memory usage (MiB): %r" % (res.ru_maxrss/1024.0)) + bot.fastmsg(replyto, "Memory usage (MiB): %r" % (res.ru_maxrss/1024.0)) @lib.hook(needchan=False, glevel=lib.MANAGER) +@lib.help(None, "show resource usage") def resources(bot, user, chan, realtarget, *args): if chan is not None and realtarget == chan.name: replyto = chan else: replyto = user @@ -41,7 +44,7 @@ def resources(bot, user, chan, realtarget, *args): except: res = resource.getrusage(resource.RUSAGE_SELF) - bot.msg(replyto, "Resource usage:") + bot.slowmsg(replyto, "Resource usage:") for i, v in ( ('utime (s)', res.ru_utime), ('stime (s)', res.ru_stime), @@ -52,5 +55,5 @@ def resources(bot, user, chan, realtarget, *args): ('context switches (voluntary)', res.ru_nvcsw), ('context switches (involuntary)', res.ru_nivcsw), ): - bot.msg(replyto, "- %s: %r" % (i, v)) - bot.msg(replyto, "EOL.") + bot.slowmsg(replyto, "- %s: %r" % (i, v)) + bot.slowmsg(replyto, "EOL.")