Compare commits
5 Commits
512133a3c4
...
c91a769a6a
Author | SHA1 | Date |
---|---|---|
rubenwardy | c91a769a6a | |
sfan5 | 28fc9f1f15 | |
sfan5 | 2e6a04a73d | |
sfan5 | 8a432e905c | |
sfan5 | 382e7cb15b |
|
@ -78,4 +78,6 @@ Required arguments are enclosed in { and }, optional arguments are enclosed in [
|
|||
<tr> <td>!tell {nick} {message}</td> <td>Tell somebody a message</td> <td>Anyone</td> </tr>
|
||||
<tr> <td><b>modsearch.py</b></td> <td></td> <td></td> </tr>
|
||||
<tr> <td>!mod {modname}</td> <td>Searches for a mod</td> <td>Anyone</td> </tr>
|
||||
<tr> <td><b>booksearch.py</b></td> <td></td> <td></td> </tr>
|
||||
<tr> <td>!book {term}</td> <td>Searches for a chapter/page in the modding book</td> <td>Anyone</td> </tr>
|
||||
</table>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
booksearch.py - Phenny Minetest Modding Book Search Module
|
||||
Copyright 2018, rubenwardy
|
||||
Licensed under GNU General Public License v2.0
|
||||
"""
|
||||
|
||||
import web
|
||||
|
||||
def book(phenny, input):
|
||||
uri = "https://rubenwardy.com/minetest_modding_book/sitemap.json"
|
||||
text, status = web.get(uri)
|
||||
text = str(text, 'utf-8')
|
||||
data = web.json(text)
|
||||
|
||||
query = (input.group(2) or "").lower()
|
||||
if not query: return
|
||||
for ele in data:
|
||||
title = ele["title"]
|
||||
desc = ele.get("description", "")
|
||||
if query in title.lower() or query in desc.lower():
|
||||
return phenny.reply(title + " - " + ele["loc"])
|
||||
|
||||
phenny.reply("Nothing found.")
|
||||
|
||||
book.commands = ['book']
|
||||
book.example = '.book folder structure'
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__)
|
33
rssnotify.py
33
rssnotify.py
|
@ -32,6 +32,20 @@ def to_unix_time(tstr):
|
|||
ts += int(g[3]) * 60
|
||||
return ts
|
||||
|
||||
def resolve_channels(phenny, l):
|
||||
ret = set()
|
||||
for entry in l:
|
||||
sign = 1
|
||||
if entry[0] == "-":
|
||||
entry = entry[1:]
|
||||
sign = -1
|
||||
c = phenny.bot.channels if entry == "*" else [entry]
|
||||
if sign == 1:
|
||||
ret |= set(c)
|
||||
else: # sign == -1
|
||||
ret -= set(c)
|
||||
return ret
|
||||
|
||||
class RssNotify():
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
|
@ -114,24 +128,25 @@ class RssNotify():
|
|||
committer_final = f_clong % (committer, committer_realname)
|
||||
return f_all % (committer_final, repo_name, commit_text, commit_hash, commit_link, commit_time)
|
||||
def _announce(self, phenny, message, chans):
|
||||
if chans == "*":
|
||||
chans = phenny.bot.channels
|
||||
assert(type(chans) == list)
|
||||
chans = resolve_channels(phenny, chans)
|
||||
for ch in chans:
|
||||
phenny.write(['PRIVMSG', ch], message)
|
||||
|
||||
#################
|
||||
|
||||
c = ['*', '-#minetest-hub']
|
||||
rssn = RssNotify({
|
||||
"check_interval": 120,
|
||||
"show_link": True,
|
||||
"shorten_link": True,
|
||||
"logfile": os.getcwd() + "/rssnotify.log",
|
||||
"feeds": [
|
||||
('https://github.com/minetest/minetest/commits/master.atom', "*"),
|
||||
('https://github.com/minetest/minetest_game/commits/master.atom', "*"),
|
||||
('https://github.com/minetest/minetestmapper/commits/master.atom', "*"),
|
||||
('https://github.com/minetest/master-server/commits/master.atom', "*"),
|
||||
('https://github.com/Uberi/Minetest-WorldEdit/commits/master.atom', "*"),
|
||||
('https://github.com/minetest-mods/mesecons/commits/master.atom', "*"),
|
||||
('https://github.com/minetest/minetest/commits/master.atom', c),
|
||||
('https://github.com/minetest/minetest_game/commits/master.atom', c),
|
||||
('https://github.com/minetest/minetestmapper/commits/master.atom', c),
|
||||
('https://github.com/minetest/master-server/commits/master.atom', c),
|
||||
('https://github.com/Uberi/Minetest-WorldEdit/commits/master.atom', c),
|
||||
('https://github.com/minetest-mods/mesecons/commits/master.atom', c),
|
||||
('https://github.com/sfan5/phenny/commits/master.atom', ['##minetestbot']),
|
||||
('https://github.com/sfan5/minetestbot-modules/commits/master.atom', ['##minetestbot']),
|
||||
],
|
||||
|
|
|
@ -134,7 +134,8 @@ def cat(phenny, input):
|
|||
"https://i.imgur.com/s9tdEOi.jpg",
|
||||
"http://i.imgur.com/8mFITRO.jpg",
|
||||
"http://i.imgur.com/ZT2jVRu.jpg",
|
||||
"http://i.imgur.com/NIwzCXd.jpg"
|
||||
"http://i.imgur.com/NIwzCXd.jpg",
|
||||
"https://pbs.twimg.com/media/DBAZtPCXgAAYKtz.jpg:large"
|
||||
]
|
||||
phenny.say(random.choice(cats))
|
||||
|
||||
|
|
10
title.py
10
title.py
|
@ -23,16 +23,14 @@ def title(phenny, input):
|
|||
data, sc = web.get(uri, 16384)
|
||||
if sc != 200:
|
||||
return phenny.say("HTTP error %d" % sc)
|
||||
try:
|
||||
data = str(data, 'utf-8')
|
||||
except UnicodeDecodeError:
|
||||
return phenny.say("Doesn't seem to be HTML..")
|
||||
|
||||
data = str(data, 'utf-8', 'ignore')
|
||||
m = re.search(r_title, data)
|
||||
if not m:
|
||||
return phenny.say("No title found.")
|
||||
title = m.group(1)
|
||||
title = html.unescape(title)
|
||||
title = title.strip()
|
||||
title = html.unescape(title).strip()
|
||||
|
||||
if len(title) > 150:
|
||||
title = title[:150] + "[...]"
|
||||
phenny.reply(title)
|
||||
|
|
Loading…
Reference in New Issue