mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-10-14 17:59:29 +02:00
Updated calc.
This commit is contained in:
parent
06afd9ff3d
commit
d86ebf4e7f
@ -408,6 +408,9 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
googleGroups = privmsgs.urlSnarfer(googleGroups)
|
googleGroups = privmsgs.urlSnarfer(googleGroups)
|
||||||
|
|
||||||
_calcRe = re.compile(r'<td nowrap><font size=\+1><b>(.*?)</b>', re.I)
|
_calcRe = re.compile(r'<td nowrap><font size=\+1><b>(.*?)</b>', re.I)
|
||||||
|
_calcSupRe = re.compile(r'<sup>(.*?)</sup>', re.I)
|
||||||
|
_calcFontRe = re.compile(r'<font size=-2>(.*?)</font>')
|
||||||
|
_calcTimesRe = re.compile(r'×')
|
||||||
def calc(self, irc, msg, args):
|
def calc(self, irc, msg, args):
|
||||||
"""<expression>
|
"""<expression>
|
||||||
|
|
||||||
@ -420,7 +423,11 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
html = webutils.getUrl(url)
|
html = webutils.getUrl(url)
|
||||||
match = self._calcRe.search(html)
|
match = self._calcRe.search(html)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
irc.reply(match.group(1))
|
s = match.group(1)
|
||||||
|
s = self._calcSupRe.sub(r'^(\1)', s)
|
||||||
|
s = self._calcFontRe.sub(r' , ', s)
|
||||||
|
s = self._calcTimesRe.sub(r' * ', s)
|
||||||
|
irc.reply(s)
|
||||||
else:
|
else:
|
||||||
irc.reply('Google\'s calculator didn\'t come up with anything.')
|
irc.reply('Google\'s calculator didn\'t come up with anything.')
|
||||||
|
|
||||||
|
@ -34,6 +34,16 @@ from testsupport import *
|
|||||||
class GoogleTestCase(ChannelPluginTestCase, PluginDocumentation):
|
class GoogleTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Google',)
|
plugins = ('Google',)
|
||||||
if network:
|
if network:
|
||||||
|
def testCalc(self):
|
||||||
|
self.assertNotRegexp('google calc e^(i*pi)+1', r'didn\'t')
|
||||||
|
self.assertNotRegexp('google calc '
|
||||||
|
'the speed of light '
|
||||||
|
'in microns / fortnight', '<sup>')
|
||||||
|
self.assertNotRegexp('google calc '
|
||||||
|
'the speed of light '
|
||||||
|
'in microns / fortnight', '×')
|
||||||
|
|
||||||
|
|
||||||
def testNoNoLicenseKeyError(self):
|
def testNoNoLicenseKeyError(self):
|
||||||
conf.supybot.plugins.Google.groupsSnarfer.setValue(True)
|
conf.supybot.plugins.Google.groupsSnarfer.setValue(True)
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'google blah'))
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'google blah'))
|
||||||
|
Loading…
Reference in New Issue
Block a user