예제 #1
0
    def processMessageBody(self, message):
        if MessageWithError.matches(message):
            return  # silently ignore error responces
        j = jid.JID(message["from"])
        if j.host != self.me.host:
            return  #ignore other domains
        text = str(message.body)
        if text.lower() == "help":
            answer = """The Great HERMES welcomes you!!!
Хотя можешь называть меня просто "О, великий", я не обижусь.
Итак, смертный, ты посмел попросить у меня помощи и на твое везение я сегодня
крайне добр и великодушен, посему спрашивай чего ты хочешь:

ibash - читать ibash
S - подписка
"""
        elif text.lower() in ["привет", "hi", "хай"]:
            answer = "и вам здоровья, боярин!"
        elif text == ".":
            answer = "..-.---....-..--..."
        elif text == "ibash":
            self.sendIBashTo(message["from"])
            return
        elif text[:2].strip(" ") == "S":  # subscription
            new = text[2:].strip(" \n")
            if new:
                c = Core.instance().contacts.subscribe(AT_XMPP, j.userhost(),
                                                       new)
                answer = "The Greate Hermes remembered you: " + str(c)
            else:
                c = Core.instance().contacts.getByAddress(
                    AT_XMPP, j.userhost())
                answer = "The Great Hermes knows you as: " + str(c) if c else \
                    "The Great Hermes really tried to find you in ancient scrolls but unsuccessfully"
                answer += """\n\nTo change your subscribtion try to write something after letter S
after space ;-) Keep in mind there is no any subscription by default.

Examples:
1) S * - subscribe to everything
2) S @serv1[*],@serv2[*] - subscribe to everything for serv1 and serv2
3) S error,@serv1[warning] - subscribe to tag "error" but for serv1 "warning" as well
4) S *,^notice - subscrive to everything except "notice" tag

Next services are available:
"""
                for k, v in Core.instance().servicesDict().iteritems():
                    answer += "%s - %s\n" % (k, v)
        else:
            if datetime.datetime.today(
            ) - self.lastSendTime < datetime.timedelta(seconds=5):
                print("RATE LIMIT exceeded: " + message.toXml())
                return  # don't send too often
            answer = "Hm I don't know what is \"%s\". " \
                     "I'm just stupid bot.." % text
        self.sendMessage([message["from"]], answer)
예제 #2
0
파일: xmpp.py 프로젝트: Ri0n/Hermes
    def processMessageBody(self, message):
        if MessageWithError.matches(message):
            return # silently ignore error responces
        j = jid.JID(message["from"])
        if j.host != self.me.host:
            return #ignore other domains
        text = str(message.body)
        if text.lower() == "help":
            answer = """The Great HERMES welcomes you!!!
Хотя можешь называть меня просто "О, великий", я не обижусь.
Итак, смертный, ты посмел попросить у меня помощи и на твое везение я сегодня
крайне добр и великодушен, посему спрашивай чего ты хочешь:

ibash - читать ibash
S - подписка
"""
        elif text.lower() in ["привет", "hi", "хай"]:
            answer = "и вам здоровья, боярин!"
        elif text == ".":
            answer = "..-.---....-..--..."
        elif text == "ibash":
            self.sendIBashTo(message["from"])
            return
        elif text[:2].strip(" ") == "S": # subscription
            new = text[2:].strip(" \n")
            if new:
                c = Core.instance().contacts.subscribe(AT_XMPP, j.userhost(), new)
                answer = "The Greate Hermes remembered you: " + str(c)
            else:
                c = Core.instance().contacts.getByAddress(AT_XMPP, j.userhost())
                answer = "The Great Hermes knows you as: " + str(c) if c else \
                    "The Great Hermes really tried to find you in ancient scrolls but unsuccessfully"
                answer += """\n\nTo change your subscribtion try to write something after letter S
after space ;-) Keep in mind there is no any subscription by default.

Examples:
1) S * - subscribe to everything
2) S @serv1[*],@serv2[*] - subscribe to everything for serv1 and serv2
3) S error,@serv1[warning] - subscribe to tag "error" but for serv1 "warning" as well
4) S *,^notice - subscrive to everything except "notice" tag

Next services are available:
"""
                for k, v in Core.instance().servicesDict().iteritems():
                    answer += "%s - %s\n" % (k, v)
        else:
            if datetime.datetime.today() - self.lastSendTime < datetime.timedelta(seconds=5):
                print ("RATE LIMIT exceeded: " + message.toXml())
                return # don't send too often
            answer = "Hm I don't know what is \"%s\". " \
                     "I'm just stupid bot.." % text
        self.sendMessage([message["from"]], answer)
예제 #3
0
파일: demon.py 프로젝트: Ri0n/Hermes
 def xmlrpc_directNotify(self, message, recipients):
     recipients = [
         contacts.Contact.fromDict(
             dict(address=r[1],
                  type=contacts.__dict__["AT_" +
                                         r[0]]))  #@UndefinedVariable
         for r in recipients
     ]
     return Core.instance().directNotify(message, recipients)
예제 #4
0
파일: demon.py 프로젝트: Ri0n/Hermes
 def xmlrpc_subscribe(self,
                      addressType,
                      address,
                      subscription="",
                      privilege="USER"):
     addressType = contacts.__dict__["AT_" +
                                     addressType]  #@UndefinedVariable
     privilege = contacts.__dict__["PRIV_" + privilege]  #@UndefinedVariable
     return Core.instance().subscribe(addressType, address, subscription,
                                      privilege).toDict()
예제 #5
0
파일: demon.py 프로젝트: Ri0n/Hermes
 def xmlrpc_unsubscribe(self, addressType, address):
     addressType = contacts.__dict__["AT_" +
                                     addressType]  #@UndefinedVariable
     return Core.instance().unsubscribe(addressType, address)
예제 #6
0
파일: demon.py 프로젝트: Ri0n/Hermes
 def xmlrpc_getContacts(self):
     return [c.toDict() for c in Core.instance().getContacts()]
예제 #7
0
파일: demon.py 프로젝트: Ri0n/Hermes
 def xmlrpc_notifyAll(self, message):
     Core.instance().notifyAll(message)
     return True
예제 #8
0
파일: demon.py 프로젝트: Ri0n/Hermes
 def xmlrpc_notify(self, message, tags=[]):
     Core.instance().notify(message, tags)
     return True
예제 #9
0
파일: demon.py 프로젝트: Ri0n/Hermes
 def auth(self, user, passwd):
     return Core.instance().auth(user, passwd)