Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -13,9 +13,7 @@ def join(phenny, input):
|
||||
if input.sender.startswith('#'): return
|
||||
if input.admin:
|
||||
channel, key = input.group(1), input.group(2)
|
||||
if not key:
|
||||
phenny.write(['JOIN'], channel)
|
||||
else: phenny.write(['JOIN', channel, key])
|
||||
phenny.proto.join(channel, key)
|
||||
join.rule = r'\.join (#\S+)(?: *(\S+))?'
|
||||
join.priority = 'low'
|
||||
join.example = '.join #example or .join #example key'
|
||||
@@ -24,7 +22,7 @@ def autojoin(phenny, input):
|
||||
"""Join the specified channel when invited by an admin."""
|
||||
if input.admin:
|
||||
channel = input.group(1)
|
||||
phenny.write(['JOIN'], channel)
|
||||
phenny.proto.join(channel)
|
||||
autojoin.event = 'INVITE'
|
||||
autojoin.rule = r'(.*)'
|
||||
|
||||
@@ -33,7 +31,7 @@ def part(phenny, input):
|
||||
# Can only be done in privmsg by an admin
|
||||
if input.sender.startswith('#'): return
|
||||
if input.admin:
|
||||
phenny.write(['PART'], input.group(2))
|
||||
phenny.proto.part(input.group(2))
|
||||
part.rule = (['part'], r'(#\S+)')
|
||||
part.priority = 'low'
|
||||
part.example = '.part #example'
|
||||
@@ -43,7 +41,7 @@ def quit(phenny, input):
|
||||
# Can only be done in privmsg by the owner
|
||||
if input.sender.startswith('#'): return
|
||||
if input.owner:
|
||||
phenny.write(['QUIT'])
|
||||
phenny.proto.quit()
|
||||
__import__('os')._exit(0)
|
||||
quit.commands = ['quit']
|
||||
quit.priority = 'low'
|
||||
|
||||
@@ -10,36 +10,33 @@ modified from Wikipedia module
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
import re
|
||||
import web
|
||||
import wiki
|
||||
|
||||
wikiapi = 'https://wiki.archlinux.org/api.php?action=query&list=search&srsearch={0}&limit=1&prop=snippet&format=json'
|
||||
wikiuri = 'https://wiki.archlinux.org/index.php/{0}'
|
||||
wikisearch = 'https://wiki.archlinux.org/index.php/Special:Search?' \
|
||||
+ 'search={0}&fulltext=Search'
|
||||
endpoints = {
|
||||
'api': 'https://wiki.archlinux.org/api.php?action=query&list=search&srsearch={0}&limit=1&format=json',
|
||||
'url': 'https://wiki.archlinux.org/index.php/{0}',
|
||||
'search': 'https://wiki.archlinux.org/index.php/Special:Search?search={0}&fulltext=Search',
|
||||
}
|
||||
|
||||
def awik(phenny, input):
|
||||
origterm = input.groups()[1]
|
||||
if not origterm:
|
||||
""".awik <term> - Look up something on the ArchWiki."""
|
||||
|
||||
origterm = input.group(1)
|
||||
if not origterm:
|
||||
return phenny.say('Perhaps you meant ".awik dwm"?')
|
||||
|
||||
term = web.unquote(origterm)
|
||||
term = term[0].upper() + term[1:]
|
||||
term = term.replace(' ', '_')
|
||||
term, section = wiki.parse_term(origterm)
|
||||
|
||||
w = wiki.Wiki(wikiapi, wikiuri, wikisearch)
|
||||
w = wiki.Wiki(endpoints)
|
||||
match = w.search(term)
|
||||
|
||||
try:
|
||||
result = w.search(term)
|
||||
except web.ConnectionError:
|
||||
error = "Can't connect to wiki.archlinux.org ({0})".format(wikiuri.format(term))
|
||||
return phenny.say(error)
|
||||
if not match:
|
||||
phenny.say('Can\'t find anything in the ArchWiki for "{0}".'.format(term))
|
||||
return
|
||||
|
||||
if result is not None:
|
||||
phenny.say(result)
|
||||
else:
|
||||
phenny.say('Can\'t find anything in the ArchWiki for "{0}".'.format(origterm))
|
||||
snippet, url = wiki.extract_snippet(match, section)
|
||||
|
||||
phenny.say('"{0}" - {1}'.format(snippet, url))
|
||||
|
||||
awik.commands = ['awik']
|
||||
awik.priority = 'high'
|
||||
|
||||
@@ -27,13 +27,11 @@ def setup(phenny):
|
||||
timer = threading.Timer(refresh_delay, close, ())
|
||||
phenny.data['startup.setup.timer'] = timer
|
||||
phenny.data['startup.setup.timer'].start()
|
||||
# print "PING!"
|
||||
phenny.write(('PING', phenny.config.host))
|
||||
phenny.proto.ping(phenny.config.host)
|
||||
phenny.data['startup.setup.pingloop'] = pingloop
|
||||
|
||||
def pong(phenny, input):
|
||||
try:
|
||||
# print "PONG!"
|
||||
phenny.data['startup.setup.timer'].cancel()
|
||||
time.sleep(refresh_delay + 60.0)
|
||||
pingloop()
|
||||
@@ -50,16 +48,16 @@ def startup(phenny, input):
|
||||
if phenny.data.get('startup.setup.pingloop'):
|
||||
phenny.data['startup.setup.pingloop']()
|
||||
|
||||
if hasattr(phenny.config, 'serverpass'):
|
||||
phenny.write(('PASS', phenny.config.serverpass))
|
||||
if hasattr(phenny.config, 'serverpass'):
|
||||
phenny.proto.pass_(phenny.config.serverpass)
|
||||
|
||||
if hasattr(phenny.config, 'password'):
|
||||
phenny.msg('NickServ', 'IDENTIFY %s' % phenny.config.password)
|
||||
time.sleep(5)
|
||||
|
||||
# Cf. http://swhack.com/logs/2005-12-05#T19-32-36
|
||||
for channel in phenny.channels:
|
||||
phenny.write(('JOIN', channel))
|
||||
for channel in phenny.channels:
|
||||
phenny.proto.join(channel)
|
||||
time.sleep(0.5)
|
||||
startup.rule = r'(.*)'
|
||||
startup.event = '251'
|
||||
|
||||
@@ -2,38 +2,76 @@
|
||||
test_archwiki.py - tests for the arch wiki module
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
import re
|
||||
import unittest
|
||||
from mock import MagicMock, Mock
|
||||
from mock import MagicMock
|
||||
from modules import archwiki
|
||||
import wiki
|
||||
|
||||
|
||||
class TestArchwiki(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.phenny = MagicMock()
|
||||
self.input = MagicMock()
|
||||
|
||||
self.term = None
|
||||
self.section = None
|
||||
|
||||
def prepare(self):
|
||||
if self.section:
|
||||
self.text = self.term + '#' + self.section
|
||||
url_text = wiki.format_term(self.term) +\
|
||||
'#' + wiki.format_section(self.section)
|
||||
else:
|
||||
self.text = self.term
|
||||
url_text = wiki.format_term(self.term)
|
||||
|
||||
self.input.group = lambda x: [None, self.text][x]
|
||||
self.url = 'https://wiki.archlinux.org/index.php/{0}'.format(url_text)
|
||||
|
||||
def check_snippet(self, output):
|
||||
self.assertIn(self.url, output)
|
||||
|
||||
for keyword in self.keywords:
|
||||
self.assertIn(keyword, output)
|
||||
|
||||
def test_awik(self):
|
||||
input = Mock(groups=lambda: ['', "KVM"])
|
||||
archwiki.awik(self.phenny, input)
|
||||
self.term = "OpenDMARC"
|
||||
self.prepare()
|
||||
|
||||
archwiki.awik(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
m = re.match('^.* - https:\/\/wiki\.archlinux\.org\/index\.php\/KVM$',
|
||||
out, flags=re.UNICODE)
|
||||
self.assertTrue(m)
|
||||
|
||||
self.keywords = ['DMARC', 'implementation', 'specification']
|
||||
self.check_snippet(out)
|
||||
|
||||
def test_awik_fragment(self):
|
||||
self.term = "KVM"
|
||||
self.section = "Kernel support"
|
||||
self.prepare()
|
||||
|
||||
archwiki.awik(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
|
||||
self.keywords = ['kernel', 'modules', 'KVM', 'VIRTIO']
|
||||
self.check_snippet(out)
|
||||
|
||||
def test_awik_invalid(self):
|
||||
term = "KVM#Enabling_KSM"
|
||||
input = Mock(groups=lambda: ['', term])
|
||||
archwiki.awik(self.phenny, input)
|
||||
self.term = "KVM"
|
||||
self.section = "Enabling KSM"
|
||||
self.prepare()
|
||||
|
||||
self.phenny.say.assert_called_once_with( "Can't find anything in "\
|
||||
"the ArchWiki for \"{0}\".".format(term))
|
||||
archwiki.awik(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
|
||||
message = "No '{0}' section found.".format(self.section)
|
||||
self.assertEqual(out, '"{0}" - {1}'.format(message, self.url))
|
||||
|
||||
def test_awik_none(self):
|
||||
term = "Ajgoajh"
|
||||
input = Mock(groups=lambda: ['', term])
|
||||
archwiki.awik(self.phenny, input)
|
||||
self.term = "Ajgoajh"
|
||||
self.prepare()
|
||||
|
||||
self.phenny.say.assert_called_once_with( "Can't find anything in "\
|
||||
"the ArchWiki for \"{0}\".".format(term))
|
||||
archwiki.awik(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
|
||||
expected = "Can't find anything in the ArchWiki for \"{0}\"."
|
||||
self.assertEqual(out, expected.format(self.text))
|
||||
|
||||
@@ -20,7 +20,7 @@ class TestTfw(unittest.TestCase):
|
||||
tfw.tfw(self.phenny, input)
|
||||
|
||||
self.phenny.say.assert_called_once_with(
|
||||
"WHERE THE FUCK IS THAT? Try another location.")
|
||||
"WHERE THE FUCK IS THAT? I guess you might think it's a place, but no one else does. Try again.")
|
||||
|
||||
def test_celsius(self):
|
||||
input = Mock(group=lambda x: '24060')
|
||||
|
||||
@@ -2,38 +2,77 @@
|
||||
test_vtluugwiki.py - tests for the VTLUUG wiki module
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
import re
|
||||
import unittest
|
||||
from mock import MagicMock, Mock
|
||||
from mock import MagicMock
|
||||
from modules import vtluugwiki
|
||||
import wiki
|
||||
|
||||
|
||||
class TestVtluugwiki(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.phenny = MagicMock()
|
||||
self.input = MagicMock()
|
||||
|
||||
self.term = None
|
||||
self.section = None
|
||||
|
||||
def prepare(self):
|
||||
if self.section:
|
||||
self.text = self.term + '#' + self.section
|
||||
url_text = wiki.format_term(self.term) +\
|
||||
'#' + wiki.format_section(self.section)
|
||||
else:
|
||||
self.text = self.term
|
||||
url_text = wiki.format_term(self.term)
|
||||
|
||||
self.input.groups.return_value = [None, self.text]
|
||||
self.url = 'https://vtluug.org/wiki/{0}'.format(url_text)
|
||||
|
||||
def check_snippet(self, output):
|
||||
self.assertIn(self.url, output)
|
||||
|
||||
for keyword in self.keywords:
|
||||
self.assertIn(keyword, output)
|
||||
|
||||
def test_vtluug(self):
|
||||
input = Mock(groups=lambda: ['', "VT-Wireless"])
|
||||
vtluugwiki.vtluug(self.phenny, input)
|
||||
self.term = "VT-Wireless"
|
||||
self.prepare()
|
||||
|
||||
vtluugwiki.vtluug(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
m = re.match('^.* - https:\/\/vtluug\.org\/wiki\/VT-Wireless$',
|
||||
out, flags=re.UNICODE)
|
||||
self.assertTrue(m)
|
||||
|
||||
self.keywords = ['campus', 'wireless', 'networks']
|
||||
self.check_snippet(out)
|
||||
|
||||
def test_vtluug_fragment(self):
|
||||
self.term = "EAP-TLS"
|
||||
self.section = "netctl"
|
||||
self.prepare()
|
||||
|
||||
vtluugwiki.vtluug(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
|
||||
self.keywords = ['Arch', 'Linux', 'netctl']
|
||||
self.check_snippet(out)
|
||||
|
||||
def test_vtluug_invalid(self):
|
||||
term = "EAP-TLS#netcfg"
|
||||
input = Mock(groups=lambda: ['', term])
|
||||
vtluugwiki.vtluug(self.phenny, input)
|
||||
self.term = "EAP-TLS"
|
||||
self.section = "netcfg"
|
||||
self.prepare()
|
||||
|
||||
self.phenny.say.assert_called_once_with( "Can't find anything in "\
|
||||
"the VTLUUG Wiki for \"{0}\".".format(term))
|
||||
vtluugwiki.vtluug(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
|
||||
message = "No '{0}' section found.".format(self.section)
|
||||
self.assertEqual(out, '"{0}" - {1}'.format(message, self.url))
|
||||
|
||||
def test_vtluug_none(self):
|
||||
term = "Ajgoajh"
|
||||
input = Mock(groups=lambda: ['', term])
|
||||
vtluugwiki.vtluug(self.phenny, input)
|
||||
self.term = "Ajgoajh"
|
||||
self.prepare()
|
||||
|
||||
vtluugwiki.vtluug(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
|
||||
expected = "Can't find anything in the VTLUUG Wiki for \"{0}\"."
|
||||
self.assertEqual(out, expected.format(self.text))
|
||||
|
||||
self.phenny.say.assert_called_once_with( "Can't find anything in "\
|
||||
"the VTLUUG Wiki for \"{0}\".".format(term))
|
||||
|
||||
@@ -6,7 +6,7 @@ author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
import re
|
||||
import unittest
|
||||
from mock import MagicMock, Mock, patch
|
||||
from modules.weather import location, local, code, f_weather
|
||||
from modules import weather
|
||||
|
||||
|
||||
class TestWeather(unittest.TestCase):
|
||||
@@ -14,58 +14,55 @@ class TestWeather(unittest.TestCase):
|
||||
self.phenny = MagicMock()
|
||||
|
||||
def test_locations(self):
|
||||
def check_places(*args):
|
||||
def validate(actual_name, actual_lat, actual_lon):
|
||||
names = [n.strip() for n in actual_name.split(',')]
|
||||
for arg in args:
|
||||
self.assertIn(arg, names)
|
||||
return validate
|
||||
def check_location(result, expected):
|
||||
self.assertAlmostEqual(result[0], expected[0], places=1)
|
||||
self.assertAlmostEqual(result[1], expected[1], places=1)
|
||||
|
||||
locations = [
|
||||
('92121', check_places("San Diego", "California")),
|
||||
('94110', check_places("SF", "California")),
|
||||
('94041', check_places("Mountain View", "California")),
|
||||
('27959', check_places("Dare County", "North Carolina")),
|
||||
('48067', check_places("Royal Oak", "Michigan")),
|
||||
('23606', check_places("Newport News", "Virginia")),
|
||||
('23113', check_places("Chesterfield County", "Virginia")),
|
||||
('27517', check_places("Chapel Hill", "North Carolina")),
|
||||
('15213', check_places("Allegheny County", "Pennsylvania")),
|
||||
('90210', check_places("Los Angeles County", "California")),
|
||||
('33109', check_places("Miami-Dade County", "Florida")),
|
||||
('80201', check_places("Denver", "Colorado")),
|
||||
('92121', (32.9, -117.2)),
|
||||
('94110', (37.8, -122.4)),
|
||||
('94041', (37.4, -122.1)),
|
||||
('27959', (36.0, -75.6)),
|
||||
('48067', (42.5, -83.1)),
|
||||
('23606', (37.1, -76.5)),
|
||||
('23113', (37.5, -77.6)),
|
||||
('27517', (42.6, -7.8)),
|
||||
('15213', (40.4, -80.0)),
|
||||
('90210', (34.1, -118.3)),
|
||||
('33109', (25.8, -80.1)),
|
||||
('80201', (22.6, 120.3)),
|
||||
|
||||
("Berlin", check_places("Berlin", "Deutschland")),
|
||||
("Paris", check_places("Paris", "France")),
|
||||
("Vilnius", check_places("Vilnius", "Lietuva")),
|
||||
("Berlin", (52.5, 13.4)),
|
||||
("Paris", (48.9, 2.4)),
|
||||
("Vilnius", (54.7, 25.3)),
|
||||
|
||||
('Blacksburg, VA', check_places("Blacksburg", "Virginia")),
|
||||
('Granger, IN', check_places("Granger", "Indiana")),
|
||||
('Blacksburg, VA', (37.2, -80.4)),
|
||||
('Granger, IN', (41.8, -86.1)),
|
||||
]
|
||||
|
||||
for loc, validator in locations:
|
||||
names, lat, lon = location(loc)
|
||||
validator(names, lat, lon)
|
||||
for query, expected in locations:
|
||||
result = weather.location(query)
|
||||
check_location(result, expected)
|
||||
|
||||
def test_code_94110(self):
|
||||
icao = code(self.phenny, '94110')
|
||||
icao = weather.code(self.phenny, '94110')
|
||||
self.assertEqual(icao, 'KSFO')
|
||||
|
||||
def test_airport(self):
|
||||
input = Mock(group=lambda x: 'KIAD')
|
||||
f_weather(self.phenny, input)
|
||||
weather.f_weather(self.phenny, input)
|
||||
|
||||
assert self.phenny.say.called is True
|
||||
|
||||
def test_place(self):
|
||||
input = Mock(group=lambda x: 'Blacksburg')
|
||||
f_weather(self.phenny, input)
|
||||
weather.f_weather(self.phenny, input)
|
||||
|
||||
assert self.phenny.say.called is True
|
||||
|
||||
def test_notfound(self):
|
||||
input = Mock(group=lambda x: 'Hell')
|
||||
f_weather(self.phenny, input)
|
||||
weather.f_weather(self.phenny, input)
|
||||
|
||||
self.phenny.say.called_once_with('#phenny',
|
||||
"No NOAA data available for that location.")
|
||||
|
||||
@@ -2,38 +2,76 @@
|
||||
test_wikipedia.py - tests for the wikipedia module
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
import re
|
||||
import unittest
|
||||
from mock import MagicMock, Mock
|
||||
from mock import MagicMock
|
||||
from modules import wikipedia
|
||||
import wiki
|
||||
|
||||
|
||||
class TestWikipedia(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.phenny = MagicMock()
|
||||
self.input = MagicMock()
|
||||
|
||||
self.term = None
|
||||
self.section = None
|
||||
|
||||
def prepare(self):
|
||||
if self.section:
|
||||
self.text = self.term + '#' + self.section
|
||||
url_text = wiki.format_term(self.term) +\
|
||||
'#' + wiki.format_section(self.section)
|
||||
else:
|
||||
self.text = self.term
|
||||
url_text = wiki.format_term(self.term)
|
||||
|
||||
self.input.groups.return_value = [None, self.text]
|
||||
self.url = 'https://en.wikipedia.org/wiki/{0}'.format(url_text)
|
||||
|
||||
def check_snippet(self, output):
|
||||
self.assertIn(self.url, output)
|
||||
|
||||
for keyword in self.keywords:
|
||||
self.assertIn(keyword, output)
|
||||
|
||||
def test_wik(self):
|
||||
input = Mock(groups=lambda: ['', "Human back"])
|
||||
wikipedia.wik(self.phenny, input)
|
||||
self.term = "Human back"
|
||||
self.prepare()
|
||||
|
||||
wikipedia.wik(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
m = re.match('^.* - https:\/\/en\.wikipedia\.org\/wiki\/Human_back$',
|
||||
out, flags=re.UNICODE)
|
||||
self.assertTrue(m)
|
||||
|
||||
self.keywords = ['human', 'back', 'body', 'buttocks', 'neck']
|
||||
self.check_snippet(out)
|
||||
|
||||
def test_wik_fragment(self):
|
||||
self.term = "New York City"
|
||||
self.section = "Climate"
|
||||
self.prepare()
|
||||
|
||||
wikipedia.wik(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
|
||||
self.keywords = ['New York', 'climate', 'humid', 'subtropical']
|
||||
self.check_snippet(out)
|
||||
|
||||
def test_wik_invalid(self):
|
||||
term = "New York City#Climate"
|
||||
input = Mock(groups=lambda: ['', term])
|
||||
wikipedia.wik(self.phenny, input)
|
||||
self.term = "New York City"
|
||||
self.section = "Physics"
|
||||
self.prepare()
|
||||
|
||||
self.phenny.say.assert_called_once_with( "Can't find anything in "\
|
||||
"Wikipedia for \"{0}\".".format(term))
|
||||
wikipedia.wik(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
|
||||
message = "No '{0}' section found.".format(self.section)
|
||||
self.assertEqual(out, '"{0}" - {1}'.format(message, self.url))
|
||||
|
||||
def test_wik_none(self):
|
||||
term = "Ajgoajh"
|
||||
input = Mock(groups=lambda: ['', term])
|
||||
wikipedia.wik(self.phenny, input)
|
||||
self.term = "Ajgoajh"
|
||||
self.prepare()
|
||||
|
||||
self.phenny.say.assert_called_once_with( "Can't find anything in "\
|
||||
"Wikipedia for \"{0}\".".format(term))
|
||||
wikipedia.wik(self.phenny, self.input)
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
|
||||
expected = "Can't find anything in Wikipedia for \"{0}\"."
|
||||
self.assertEqual(out, expected.format(self.text))
|
||||
|
||||
132
modules/tfw.py
132
modules/tfw.py
@@ -26,7 +26,7 @@ def tfw(phenny, input, fahrenheit=False, celsius=False, mev=False):
|
||||
icao_code = weather.code(phenny, where)
|
||||
|
||||
if not icao_code:
|
||||
phenny.say("WHERE THE FUCK IS THAT? Try another location.")
|
||||
phenny.say("WHERE THE FUCK IS THAT? I guess you might think it's a place, but no one else does. Try again.")
|
||||
return
|
||||
|
||||
uri = 'http://tgftp.nws.noaa.gov/data/observations/metar/stations/%s.TXT'
|
||||
@@ -35,11 +35,11 @@ def tfw(phenny, input, fahrenheit=False, celsius=False, mev=False):
|
||||
except AttributeError:
|
||||
raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.")
|
||||
except web.HTTPError:
|
||||
phenny.say("WHERE THE FUCK IS THAT? Try another location.")
|
||||
phenny.say("WHERE THE FUCK IS THAT? I guess you might think it's a place, but no one else does. Try again.")
|
||||
return
|
||||
|
||||
if 'Not Found' in bytes:
|
||||
phenny.say("WHERE THE FUCK IS THAT? Try another location.")
|
||||
phenny.say("WHERE THE FUCK IS THAT? I guess you might think it's a place, but no one else does. Try again.")
|
||||
return
|
||||
|
||||
w = metar.parse(bytes)
|
||||
@@ -64,33 +64,44 @@ def tfw(phenny, input, fahrenheit=False, celsius=False, mev=False):
|
||||
"Nothing a few shots couldn't fix",
|
||||
"Should have gone south",
|
||||
"You think this is cold? Have you been to upstate New York?",
|
||||
"Why do I live here?", "wang icicles.",
|
||||
"Freezing my balls off out here", "Fuck this place.",
|
||||
"GREAT! If you're a penguin.", "Fresh off the tap.",
|
||||
"Why do I live here?",
|
||||
"wang icicles.",
|
||||
"Freezing my balls off out here",
|
||||
"Fuck this place.",
|
||||
"GREAT! If you're a penguin.",
|
||||
"Fresh off the tap.",
|
||||
"Fantastic do-nothing weather.",
|
||||
"Put on some fucking socks.", "Blue balls x 2",
|
||||
"Put on some fucking socks.",
|
||||
"Blue balls x 2",
|
||||
"Good news, food won't spoil nearly as fast outside. Bad news, who cares?",
|
||||
"Really?", "Wear a fucking jacket.",
|
||||
"Really?",
|
||||
"Wear a fucking jacket.",
|
||||
"I hear Siberia is the same this time of year.",
|
||||
"NOT FUCKING JOGGING WEATHER", "Shrinkage's best friend.",
|
||||
"Warmer than Hoth.", "Good baby making weather.",
|
||||
"NOT FUCKING JOGGING WEATHER",
|
||||
"Shrinkage's best friend.",
|
||||
"Warmer than Hoth.",
|
||||
"Good baby making weather.",
|
||||
"Where's a Tauntaun when you need one?",
|
||||
"My nipples could cut glass", "Global Warming? Bullshit.",
|
||||
"My nipples could cut glass",
|
||||
"Global Warming? Bullshit.",
|
||||
"Call your local travel agency and ask them if they're serious.",
|
||||
"Freezing my balls off IN here",
|
||||
"I'm not sure how you can stand it", "I'm sorry.",
|
||||
"I'm not sure how you can stand it",
|
||||
"I'm sorry.",
|
||||
"Even penguins are wearing jackets.",
|
||||
"Keep track of your local old people.",
|
||||
"WHAT THE FUCK DO YOU MEAN IT'S NICER IN ALASKA?",
|
||||
"Sock warmers are go. Everywhere.",
|
||||
"Why does my car feel like a pair of ice skates?",
|
||||
"Actually, a sharp-stick in the eye might not all be that bad right now.",
|
||||
"THO Season.", "It's a tit-bit nipplie.",
|
||||
"THO Season.",
|
||||
"It's a tit-bit nipplie.",
|
||||
"Anything wooden will make a good fireplace. Thank us later.",
|
||||
"MOVE THE FUCK ON GOLDILOCKS",
|
||||
"I'm defrosting inside of my freezer.",
|
||||
"It's time for a vacation.",
|
||||
"It's bone chilling cold out. Sorry ladies."]
|
||||
"It's bone chilling cold out. Sorry ladies."
|
||||
]
|
||||
elif w.temperature < 20:
|
||||
remark = "IT'S FUCKING...ALRIGHT"
|
||||
flavors = [
|
||||
@@ -98,7 +109,8 @@ def tfw(phenny, input, fahrenheit=False, celsius=False, mev=False):
|
||||
"Better than a sharp stick in the eye.",
|
||||
"Everything's nice butter weather!",
|
||||
"At least you aren't living in a small town in Alaska",
|
||||
"It could be worse.", "FUCKING NOTHING TO SEE HERE",
|
||||
"It could be worse.",
|
||||
"FUCKING NOTHING TO SEE HERE",
|
||||
"Listen, weather. We need to have a talk.",
|
||||
"OH NO. THE WEATHER MACHINE IS BROKEN.",
|
||||
"An Eskimo would beat your ass to be here",
|
||||
@@ -120,31 +132,52 @@ def tfw(phenny, input, fahrenheit=False, celsius=False, mev=False):
|
||||
"Well, at least we're not in prison.",
|
||||
"Slap me around and call me Sally. It'd be an improvement.",
|
||||
"Today is the perfect size, really honey.",
|
||||
"Maybe Jersey Shore is on tonight."]
|
||||
"It's that kind of day where you want zip off pants, until you realize how much of a jackass you look like in them.",
|
||||
"Maybe Jersey Shore is on tonight.",
|
||||
"Praise \"Bob\"!",
|
||||
"Or kill me.",
|
||||
"This statement is false.",
|
||||
"Lies and slander, sire!"
|
||||
]
|
||||
elif w.temperature < 27:
|
||||
remark = "IT'S FUCKING NICE"
|
||||
flavors = [
|
||||
"I made today breakfast in bed.", "FUCKING SWEET",
|
||||
"Quit your bitching", "Enjoy.", "IT'S ABOUT FUCKING TIME",
|
||||
"READ A FUCKIN' BOOK", "LETS HAVE A FUCKING PICNIC",
|
||||
"It is safe to take your ball-mittens off.", "More please.",
|
||||
"uh, can we trade?", "WOO, Spring Break!",
|
||||
"I can't believe it's not porn!", "I approve of this message!",
|
||||
"Operation beach volleyball is go.", "Plucky ducky kinda day.",
|
||||
"I made today breakfast in bed.",
|
||||
"FUCKING SWEET",
|
||||
"Quit your bitching",
|
||||
"Enjoy.",
|
||||
"IT'S ABOUT FUCKING TIME",
|
||||
"READ A FUCKIN' BOOK",
|
||||
"LETS HAVE A FUCKING PICNIC",
|
||||
"It is safe to take your ball-mittens off.",
|
||||
"More please.",
|
||||
"uh, can we trade?",
|
||||
"I approve of this message!",
|
||||
"WE WERE BEGINNING TO THINK YOU LOST YOUR MIND",
|
||||
"WOO, Spring Break!",
|
||||
"I can't believe it's not porn!",
|
||||
"I approve of this message!",
|
||||
"Operation beach volleyball is go.",
|
||||
"Plucky ducky kinda day.",
|
||||
"Today called just to say \"Hi.\"",
|
||||
"STOP AND SMELL THE FUCKING ROSES",
|
||||
"FUCKING NOTHING WRONG WITH TODAY", "LETS HAVE A FUCKING SOIREE",
|
||||
"FUCKING NOTHING WRONG WITH TODAY",
|
||||
"LETS HAVE A FUCKING SOIREE",
|
||||
"What would you do for a holyshititsniceout bar?",
|
||||
"There are no rules today, blow shit up!",
|
||||
"Celebrate Today's Day and buy your Today a present so it knows you care.",
|
||||
"I feel bad about playing on my computer all day.",
|
||||
"Party in the woods.", "It is now safe to leave your home.",
|
||||
"Party in the woods.",
|
||||
"It is now safe to leave your home.",
|
||||
"PUT A FUCKING CAPE ON TODAY, BECAUSE IT'S SUPER",
|
||||
"Today is like \"ice\" if it started with an \"n\". Fuck you, we don't mean nce.",
|
||||
"Water park! Water drive! Just get wet!",
|
||||
"The geese are on their way back! Unless you live where they migrate to for the winter.",
|
||||
"FUCKING AFFABLE AS SHIT", "Give the sun a raise!",
|
||||
"Today is better than an original holographic Charizard. Loser!"]
|
||||
"FUCKING AFFABLE AS SHIT",
|
||||
"Give the sun a raise!",
|
||||
"Go outside and go cycling or some shit, you fitness nerd!",
|
||||
"Today is better than an original holographic Charizard. Loser!"
|
||||
]
|
||||
else:
|
||||
remark = "IT'S FUCKING HOT"
|
||||
flavors = [
|
||||
@@ -161,24 +194,60 @@ def tfw(phenny, input, fahrenheit=False, celsius=False, mev=False):
|
||||
"Isn't the desert nice this time of year?",
|
||||
"Why, oh why did we decide to live in an oven?",
|
||||
"It's hotter outside than my fever.",
|
||||
"I recommend staying away from fat people.",
|
||||
"TAKE IT OFF!",
|
||||
"TAKE FUCKING EVERYTHING OFF!",
|
||||
"EVEN THAT NEEDS TO COME OFF!",
|
||||
"Even your frigid girlfriend can't save you from today.",
|
||||
"I need gloves to touch the steering wheel.",
|
||||
"I can hear that power bill running up right now!",
|
||||
"Lock up yo' ice cream trucks, lock up yo' wife.",
|
||||
"FUCKING SUNBURNED, AND I WAS INSIDE ALL DAY.",
|
||||
"Fuck this shit, I'm moving back to Alaska."]
|
||||
"Fuck this shit, I'm moving back to Alaska."
|
||||
]
|
||||
|
||||
if w.descriptor == "thunderstorm":
|
||||
remark += " AND THUNDERING"
|
||||
flavors += [
|
||||
"Are you sure you want to go out in that? I'm not",
|
||||
"Fuck my ears!",
|
||||
"Don't go flying a kite. Unless you're Ben Franklin",
|
||||
"Did you think Eris would smile upon your failings?"
|
||||
]
|
||||
elif w.precipitation in ("snow", "snow grains"):
|
||||
remark += " AND SNOWING"
|
||||
flavors += [
|
||||
"What's this white stuff that's sticking to everything?",
|
||||
"At least that stuff doesn't glow in the dark!",
|
||||
"How the fuck am I supposed to get around now?",
|
||||
"And you thought four-wheel-drive would help you!",
|
||||
"Go fight those cadets with snowballs",
|
||||
"Where does the white go when the snow melts?",
|
||||
"Just sNOw"
|
||||
]
|
||||
elif w.precipitation in ("drizzle", "rain", "unknown precipitation"):
|
||||
remark += " AND WET"
|
||||
flavors += [
|
||||
"Just like your mom!",
|
||||
"I guess it can't get much worse",
|
||||
"Hope you have a rain coat",
|
||||
"Shower outside?",
|
||||
"If only more buildings had gargoyles..."
|
||||
]
|
||||
elif w.precipitation in ("ice crystals", "ice pellets"):
|
||||
remark += " AND ICY"
|
||||
flavors += [
|
||||
"Nice, but without the N!",
|
||||
"Where's some NaCl when you need it?",
|
||||
"I hope your skates are nearby.",
|
||||
"Studded tyres? What're those?"
|
||||
]
|
||||
elif w.precipitation in ("hail", "small hail"):
|
||||
remark += " AND HAILING"
|
||||
flavors += [
|
||||
"Windshield damage!",
|
||||
"Car alarms!",
|
||||
"Lie face-down outside: free massage!"
|
||||
]
|
||||
|
||||
if int(tempf) == 69:
|
||||
remark = "IT'S FUCKING SEXY TIME"
|
||||
@@ -187,7 +256,8 @@ def tfw(phenny, input, fahrenheit=False, celsius=False, mev=False):
|
||||
"What comes after 69? Mouthwash.",
|
||||
"If you are given two contradictory orders, obey them both.",
|
||||
"a good fuckin' time! ;)",
|
||||
"What's the square root of 69? Eight something."]
|
||||
"What's the square root of 69? Eight something."
|
||||
]
|
||||
|
||||
flavor = random.choice(flavors)
|
||||
|
||||
@@ -210,7 +280,7 @@ def tfwc(phenny, input):
|
||||
tfwc.rule = (['tfwc'], r'(.*)')
|
||||
|
||||
def tfwev(phenny, input):
|
||||
""".tfwc <city/zip> - The fucking weather, in fucking degrees celsius."""
|
||||
""".tfwev <city/zip> - The fucking weather, in fucking electron volts."""
|
||||
return tfw(phenny, input, mev=True)
|
||||
tfwev.rule = (['tfwev'], r'(.*)')
|
||||
|
||||
|
||||
@@ -17,13 +17,6 @@ def urbandict(phenny, input):
|
||||
phenny.say(urbandict.__doc__.strip())
|
||||
return
|
||||
|
||||
# create opener
|
||||
#opener = urllib.request.build_opener()
|
||||
#opener.addheaders = [
|
||||
# ('User-agent', web.Grab().version),
|
||||
# ('Referer', "http://m.urbandictionary.com"),
|
||||
#]
|
||||
|
||||
try:
|
||||
data = web.get(
|
||||
"http://api.urbandictionary.com/v0/define?term={0}".format(
|
||||
@@ -33,11 +26,13 @@ def urbandict(phenny, input):
|
||||
raise GrumbleError(
|
||||
"Urban Dictionary slemped out on me. Try again in a minute.")
|
||||
|
||||
if data['result_type'] == 'no_results':
|
||||
results = data['list']
|
||||
|
||||
if not results:
|
||||
phenny.say("No results found for {0}".format(word))
|
||||
return
|
||||
|
||||
result = data['list'][0]
|
||||
result = results[0]
|
||||
url = 'http://www.urbandictionary.com/define.php?term={0}'.format(
|
||||
web.quote(word))
|
||||
|
||||
|
||||
@@ -10,14 +10,13 @@ modified from Wikipedia module
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
import re
|
||||
import web
|
||||
import wiki
|
||||
|
||||
wikiapi = 'https://vtluug.org/w/api.php?action=query&list=search&srsearch={0}&limit=1&prop=snippet&format=json'
|
||||
wikiuri = 'https://vtluug.org/wiki/{0}'
|
||||
wikisearch = 'https://vtluug.org/wiki/Special:Search?' \
|
||||
+ 'search={0}&fulltext=Search'
|
||||
endpoints = {
|
||||
'api': 'https://vtluug.org/w/api.php?action=query&list=search&srsearch={0}&limit=1&prop=snippet&format=json',
|
||||
'url': 'https://vtluug.org/wiki/{0}',
|
||||
'search': 'https://vtluug.org/wiki/Special:Search?search={0}&fulltext=Search',
|
||||
}
|
||||
|
||||
def vtluug(phenny, input):
|
||||
""".vtluug <term> - Look up something on the VTLUUG wiki."""
|
||||
@@ -26,22 +25,19 @@ def vtluug(phenny, input):
|
||||
if not origterm:
|
||||
return phenny.say('Perhaps you meant ".vtluug VT-Wireless"?')
|
||||
|
||||
term = web.unquote(origterm)
|
||||
term = term[0].upper() + term[1:]
|
||||
term = term.replace(' ', '_')
|
||||
term, section = wiki.parse_term(origterm)
|
||||
|
||||
w = wiki.Wiki(wikiapi, wikiuri, wikisearch)
|
||||
w = wiki.Wiki(endpoints)
|
||||
match = w.search(term)
|
||||
|
||||
try:
|
||||
result = w.search(term)
|
||||
except web.ConnectionError:
|
||||
error = "Can't connect to vtluug.org ({0})".format(wikiuri.format(term))
|
||||
return phenny.say(error)
|
||||
if not match:
|
||||
phenny.say('Can\'t find anything in the VTLUUG Wiki for "{0}".'.format(term))
|
||||
return
|
||||
|
||||
snippet, url = wiki.extract_snippet(match, section)
|
||||
|
||||
phenny.say('"{0}" - {1}'.format(snippet, url))
|
||||
|
||||
if result is not None:
|
||||
phenny.say(result)
|
||||
else:
|
||||
phenny.say('Can\'t find anything in the VTLUUG Wiki for "{0}".'.format(origterm))
|
||||
vtluug.commands = ['vtluug']
|
||||
vtluug.priority = 'high'
|
||||
|
||||
|
||||
@@ -25,13 +25,13 @@ def location(q):
|
||||
results = web.get(uri)
|
||||
data = json.loads(results)
|
||||
|
||||
if len(data) < 1:
|
||||
return '?', None, None
|
||||
if not data:
|
||||
return None, None
|
||||
|
||||
display_name = data[0]['display_name']
|
||||
lat = float(data[0]['lat'])
|
||||
lon = float(data[0]['lon'])
|
||||
return display_name, lat, lon
|
||||
latitude = float(data[0]['lat'])
|
||||
longitude = float(data[0]['lon'])
|
||||
|
||||
return latitude, longitude
|
||||
|
||||
|
||||
def local(icao, hour, minute):
|
||||
@@ -58,7 +58,7 @@ def code(phenny, search):
|
||||
if search.upper() in [loc[0] for loc in data]:
|
||||
return search.upper()
|
||||
else:
|
||||
display_name, latitude, longitude = location(search)
|
||||
latitude, longitude = location(search)
|
||||
if not latitude or not longitude:
|
||||
return False
|
||||
sumOfSquares = (99999999999999999999999999999, 'ICAO')
|
||||
|
||||
@@ -7,14 +7,13 @@ Licensed under the Eiffel Forum License 2.
|
||||
http://inamidst.com/phenny/
|
||||
"""
|
||||
|
||||
import re
|
||||
import web
|
||||
import wiki
|
||||
|
||||
wikiapi = 'https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={0}&limit=1&prop=snippet&format=json'
|
||||
wikiuri = 'https://en.wikipedia.org/wiki/{0}'
|
||||
wikisearch = 'https://en.wikipedia.org/wiki/Special:Search?' \
|
||||
+ 'search={0}&fulltext=Search'
|
||||
endpoints = {
|
||||
'api': 'https://en.wikipedia.org/w/api.php?format=json&action=query&list=search&srsearch={0}&prop=snippet&limit=1',
|
||||
'url': 'https://en.wikipedia.org/wiki/{0}',
|
||||
'search': 'https://en.wikipedia.org/wiki/Special:Search?search={0}&fulltext=Search',
|
||||
}
|
||||
|
||||
def wik(phenny, input):
|
||||
""".wik <term> - Look up something on Wikipedia."""
|
||||
@@ -23,22 +22,19 @@ def wik(phenny, input):
|
||||
if not origterm:
|
||||
return phenny.say('Perhaps you meant ".wik Zen"?')
|
||||
|
||||
term = web.unquote(origterm)
|
||||
term = term[0].upper() + term[1:]
|
||||
term = term.replace(' ', '_')
|
||||
origterm = origterm.strip()
|
||||
term, section = wiki.parse_term(origterm)
|
||||
|
||||
w = wiki.Wiki(wikiapi, wikiuri, wikisearch)
|
||||
w = wiki.Wiki(endpoints)
|
||||
match = w.search(term)
|
||||
|
||||
try:
|
||||
result = w.search(term)
|
||||
except web.ConnectionError:
|
||||
error = "Can't connect to en.wikipedia.org ({0})".format(wikiuri.format(term))
|
||||
return phenny.say(error)
|
||||
|
||||
if result is not None:
|
||||
phenny.say(result)
|
||||
else:
|
||||
if not match:
|
||||
phenny.say('Can\'t find anything in Wikipedia for "{0}".'.format(origterm))
|
||||
return
|
||||
|
||||
snippet, url = wiki.extract_snippet(match, section)
|
||||
|
||||
phenny.say('"{0}" - {1}'.format(snippet, url))
|
||||
|
||||
wik.commands = ['wik']
|
||||
wik.priority = 'high'
|
||||
|
||||
@@ -17,7 +17,7 @@ def wuvt(phenny, input):
|
||||
except:
|
||||
raise GrumbleError("Failed to fetch current track from WUVT")
|
||||
|
||||
if 'listeners' in trackinfo:
|
||||
if 'listeners' in trackinfo and trackinfo['listeners'] is not None:
|
||||
phenny.say(
|
||||
"{dj} is currently playing \"{title}\" by {artist} with "
|
||||
"{listeners:d} online listeners".format(
|
||||
|
||||
Reference in New Issue
Block a user