# -*- coding: utf-8 -*-

import sys
import logging
import datetime
import time
import urllib
import json
import socket
import re
from slackbot.bot import Bot, listen_to, respond_to


def get_food(day):
    # Get JSON
    URL = 'http://www.hanssonohammar.se/veckansmeny.json'
    response = urllib.urlopen(URL)
    data = json.loads(response.read().decode('utf-8'))

    if day not in data:
        return "(no mat " + str(day) + ")"

    mat_today = data[day][0]

    if 'IKSU' not in mat_today:
        return "(no IKSU today)"

    return "\n".join(mat_today['IKSU'])


@listen_to(r'^compile (.*)$')
def compile(message, code):
    message.reply(u"Jag klarar inte av sånt längre :'(")


@listen_to(r'^run (.*)$')
def run(message, code):
    message.reply(u"Jag klarar inte av sånt längre :'(")


@listen_to(r'^mat(\+*)$')
def mat(message, plus):
    date = datetime.date.fromtimestamp(time.time() + (86400 * len(plus)))
    try:
        message.reply(u"```IKSU - {}\n{}```".format(str(date), get_food(str(date))))
    except Exception as e:
        message.reply(u"Kom inte åt maten 😞 ({what})".format(what=e.message))


@listen_to(ur'^[e\u00E4\u00C4]r.*fredag.*\?', re.IGNORECASE)
def fredag(message):
    if datetime.datetime.today().weekday() == 4:
        message.reply(u"Japp, idag är det fredag! :kreygasm:")
    else:
        message.reply(u"Nej, idag är det INTE fredag! :qq::gun:")


@listen_to(r'^temp', re.IGNORECASE)
def temp(message):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(('temp.acc.umu.se', 2345))
    tmp = s.recv(1024)
    s.close()
    time, temp = tmp[:len(tmp) - 1].split('=')
    message.reply(u"{} C klockan {}".format(temp, time))


def main():
    kw = {
            'format': '[%(asctime)s] %(message)s',
            'datefmt': '%m/%d/%Y %H:%M:%S',
            'level': logging.DEBUG,
            'stream': sys.stdout,
            }
    logging.basicConfig(**kw)
    bot = Bot()
    bot.run()


if __name__ == '__main__':
    main()

@@ -33,23 +33,8 @@
 sys%0A
-import logging%0A
 impo
@@ -1686,228 +1686,8 @@
 ():%0A
-    kw = %7B%0A            'format': '%5B%25(asctime)s%5D %25(message)s',%0A            'datefmt': '%25m/%25d/%25Y %25H:%25M:%25S',%0A            'level': logging.DEBUG,%0A            'stream': sys.stdout,%0A            %7D%0A    logging.basicConfig(**kw)%0A
     

Remove logging