diff options
author | B. Watson <yalhcru@gmail.com> | 2021-06-24 04:09:05 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2021-06-24 04:09:05 -0400 |
commit | a5a96cd7ae566bb1ee168cae14e1d1101bcd1797 (patch) | |
tree | 46b7a4bd41d3e577ad08a70a1dc7bd91f995e5d7 /SBoTools | |
parent | 44be4bb654e313344a427f35a527de3e636f4a61 (diff) | |
download | limnoria.slackfacts.plugins-a5a96cd7ae566bb1ee168cae14e1d1101bcd1797.tar.gz |
SBoTools: add maintainer info
Diffstat (limited to 'SBoTools')
-rw-r--r-- | SBoTools/config.py | 10 | ||||
-rw-r--r-- | SBoTools/plugin.py | 33 |
2 files changed, 28 insertions, 15 deletions
diff --git a/SBoTools/config.py b/SBoTools/config.py index b13dc28..d07f840 100644 --- a/SBoTools/config.py +++ b/SBoTools/config.py @@ -33,10 +33,8 @@ conf.registerGlobalValue(SBoTools, 'dbpath', registry.String("/home/slackfacts/supybot/SBoTools.sqlite3", _("""Path to sqite3 database."""))) conf.registerGlobalValue(SBoTools, 'maxresults', - registry.Integer(5, _("""Maximum number of results to send to client."""))) + registry.Integer(5, _("""Maximum number of results for sbosearch command"""))) + +conf.registerGlobalValue(SBoTools, 'maxdeps', + registry.Integer(10, _("""Maximum number of dependencies for sboinfo command"""))) -## conf.registerGlobalValue(SBoTools, 'slackpath', -## registry.String("/data/mirrors/slackware/slackware64-14.2", _("""Filesystem path to Slackware mirror (NO trailing slash!)"""))) -## -## conf.registerGlobalValue(SBoTools, 'baseurl', -## registry.String("https://slackware.uk/slackware/slackware64-14.2", _("""Web URL of Slackware mirror (NO trailing slash!)"""))) diff --git a/SBoTools/plugin.py b/SBoTools/plugin.py index 0e18e9d..24df7ce 100644 --- a/SBoTools/plugin.py +++ b/SBoTools/plugin.py @@ -40,6 +40,13 @@ class SBoTools(callbacks.Plugin): maxresults *= 5 return maxresults + def getMaxDeps(self, msg): + maxdeps = self.registryValue('maxdeps') + if msg.channel is None: + # private message, increase limit + maxdeps *= 10 + return maxdeps + def InitDB(self): if self.db is None: filename = self.registryValue('dbpath') @@ -142,25 +149,33 @@ class SBoTools(callbacks.Plugin): db = self.InitDB(); cursor = db.cursor() - if(category is None): - cursor.execute("select b.id, b.name, c.name, b.descrip, b.version from builds b, categories c where b.category = c.id and b.name = ?", (build,)) - else: - cursor.execute("select b.id, b.name, c.name, b.descrip, b.version from builds b, categories c where c.id = ? and b.category = c.id and b.name = ?", (category, build,)) + + sql = """select b.id, b.name, c.name, b.descrip, b.version, m.name, e.addr + from builds b, categories c, maintainers m, emails e where """ + if(category is not None): + sql += "c.id=" + str(category) + " and " + sql += """b.category = c.id and b.maintainer = m.id and b.email = e.id + and b.name=?""" + cursor.execute(sql, (build,)) result = cursor.fetchall() if(len(result) == 0): irc.reply("no results found") else: lines = [] - for (bid, bname, cname, bdescrip, bversion) in result: - lines.append(cname + "/" + bname + " v" + bversion + ": " + bdescrip) - cursor.execute("select b.name from builds b, deps d where d.build_id=? and b.id=d.depends_on", (bid,)) + for (bid, bname, cname, bdescrip, bversion, maint, email) in result: + lines.append(cname + "/" + bname + " v" + bversion + ": " + bdescrip + + ", " + maint + " <" + email + ">") + maxdeps = self.getMaxDeps(msg) + cursor.execute("select b.name from builds b, deps d where d.build_id=? and b.id=d.depends_on limit ?", (bid,maxdeps+1)) depres = cursor.fetchall() if(len(depres) != 0): deps = "" for (depname) in depres: - deps += depname[0] + " " - lines.append("deps: " + deps) + deps += " " + depname[0] + lines.append("deps:" + deps) + if(len(depres) > maxdeps): + lines.append("[too many deps, only showing " + str(maxdeps) + "]") irc.replies(lines, joiner=' | ') |