Пример #1
0
 def __init__(self, irc):
     self.__parent = super(RealRaum, self)
     self.__parent.__init__(irc)
     self.mjam = Mjam(None, None)
Пример #2
0
class RealRaum(callbacks.Plugin):

    """realraum related IRC stuff"""

    threaded = True

    def __init__(self, irc):
        self.__parent = super(RealRaum, self)
        self.__parent.__init__(irc)
        self.mjam = Mjam(None, None)

    def roomstatus(self, irc, msg, args):
        """takes no arguments

        Grap the roomstatus from the space-api and display it.
        """
        resp = requests.get(url="http://realraum.at/status.json")
        data = json.loads(resp.text)

        status = str(data['state']['message'])
        lastChange = data['state']['lastchange']

        irc.reply(status)
    roomstatus = wrap(roomstatus)

    def food(self, irc, msg, args, url):
        """[mjam.net url]

        Lets food happen (maybe).
        """

        restaurant_name = ""
        sender = msg.nick

        text = "Hi,\n\n" + sender + \
            " at realraum wants some food! Wanna join in?\n\n"
        text += "If so, check #realrauim @ OFTC"

        if url is None:
            if self.mjam.url is not None:
                self.mjam.loadOrder()
                if not self.mjam.isOrderGone() and not self.mjam.isOrderSubmitted():
                    irc.reply("ongoing food order: " + self.mjam.url)
                    return
                else:
                    if not self.mjam.isOrderGone():
                        self.mjam.getOrderNumer()
                        # TODO: check if ETA already passed, if so: delete link
                        irc.reply(
                            "Order already submitted. ETA: " + self.mjam.loadOrderETA())
                    else:
                        irc.reply(
                            "Order already submitted. Care to start a new one?")
                        self.mjam.url = None
                    return
            else:
                url = ""
                irc.reply(
                    "let food happen! (please give people some time to reply ...)", prefixNick=False)

        else:
            text += ",\nor this link: " + url
            irc.reply(
                "thanks for the link, now let food happen! (please give people some time to reply ...)", prefixNick=False)

            if "mjam.net" in url:
                # "quickfix" for mjam cert issues:
                self.mjam.url = url.replace("https", "http")
                self.mjam.loadOrder()
                if not self.mjam.isOrderSubmitted() and not self.mjam.isOrderGone():
                    restaurant_name = " from  " + self.mjam.getRestaurantName()
                else:
                    irc.reply("Sorry, order already gone ...")
                    self.mjam.url = None
                    return

            url = " ---> " + url

        persons = ""
        for p in self.registryValue('food.listeners'):
            if p != sender:
                persons += p + ", "

        irc.reply("Yo " + persons + "want some food" +
                  restaurant_name + "? " + url, prefixNick=False)

        text += " ...\n\nCheers, \nr3bot"
        print text

        # TODO: send 'text' via email to  self.registryValue('food.emails')

    food = wrap(food, [optional('httpUrl')])

    def tschunk(self, irc, msg, args):
        """takes no arguments

        I say disco, you say party!
        """
        irc.reply("Yo nicoo, let tschunk happen! :)", prefixNick=False)
    tschunk = wrap(tschunk)

    def isPeterTheOneAlreadyRealraumMember(self, irc, msg, args):
        """takes no arguments

        Tell me!
        """
        irc.reply("NO! :( *sadPandaIsSad*", prefixNick=False)

    ispetertheonealreadyrealraummember = wrap(
        isPeterTheOneAlreadyRealraumMember)

    def sender(self, irc, msg, args):
        """takes no arguments

        Tell me the sender (can be fun!).
        """

        irc.reply(
            "you are " + msg.nick + ", what did you expect?", prefixNick=False)

    sender = wrap(sender)