]> jfr.im git - erebus.git/commitdiff
regex
authorConny Sjöblom <redacted>
Sat, 8 Feb 2014 21:56:06 +0000 (23:56 +0200)
committerConny Sjöblom <redacted>
Sat, 8 Feb 2014 21:56:06 +0000 (23:56 +0200)
modules/coins.py
modules/urls.py

index 34bbb545a7ffc94fa54405dada45edd67466d175..5a92fad90e8ecb23bbd4476c87c79582aeda4b41 100644 (file)
@@ -22,8 +22,11 @@ import json
 import requests
 
 coin_regex = (
-#  re.compile(r'([0-9., ]+[0-9]+) (BTC|bitcoin|doge|dogecoin|ltc|litecoin)'), # Fix regex
-       re.compile(r'([0-9.\s]+)\s(btc|bitcoin|doge|dogecoin|ltc|litecoin)'),
+       re.compile(r'([0-9.,\s]+)\s(btc|bitcoin|doge|dogecoin|ltc|litecoin)'),
+)
+
+cur_regex = (
+       re.compile(r'([0-9.,\s]+)\s([a-zA-Z]{3})\sin\s([a-zA-Z]{3})'),
 )
 
 url = 'http://www.cryptocoincharts.info/v2/api/tradingPairs'
@@ -88,9 +91,22 @@ def privmsg_hook(bot, line):
 
        chan = line.split()[2]
 
+       if 'in' in line:
+               for r in cur_regex:
+                       for a, f, t in r.findall(linetx):
+
+                               # https://www.google.com/finance/converter?a=1.2&from=USD&to=EUR
+
+                               a = a.replace(",", ".")
+                               a = a.replace(" ", "")
+                               print a
+                               print f
+                               print t
+
        if 'btc' in line or 'bitcoin' in line or 'doge' in line or 'dogecoin' in line:
                for r in coin_regex:
                        for amount, coin in r.findall(linetx):
+                               amount = amount.replace(",", ".")
                                amount = amount.replace(" ", "")
                                if 'btc' in coin or 'bitcoin' in coin:
                                        try:
index 9e8e3e2b4776fda0db0a3c81d962a35422ebed1e..2908dc0af1e20d29830d3377db8c1a7539d85557 100644 (file)
@@ -10,6 +10,8 @@ modinfo = {
        'depends': [], # other modules required to work properly?
 }
 
+# http://embed.ly/tools/generator
+
 # preamble
 import modlib
 lib = modlib.modlib(__name__)
@@ -149,3 +151,4 @@ def gottwitch(url):
                                bot.msg(line.split()[2], 'Twitch: %s (%s playing %s)' % (twitch[0]['channel']['status'], twitch[0]['channel']['login'], twitch[0]['channel']['meta_game']))
                        except:
                                bot.msg(line.split()[2], 'Twitch: Channel offline.')
+