2
接收的消息我已經寫了從客戶端C1
接收消息,並將其轉發給客戶端C2
,即2人可以通過網關連接Bot
殭屍B
。Ejabberd - 發送 - 通過博特
我正在使用Sleekxmpp,這是一個用於上述目的的Python客戶端XMPP庫。
import logging
from sleekxmpp import ClientXMPP
from sleekxmpp.exceptions import IqError, IqTimeout
class EchoBot(ClientXMPP):
def __init__(self, jid, password):
ClientXMPP.__init__(self, jid, password)
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message", self.message)
def session_start(self, event):
self.send_presence()
def message(self, msg):
if msg['type'] in ('chat'):
# receive message from the Client1
from, to = message['from'], message['to']
message = message['body']
# send message to Client2.
self.send_message(mto=recipient,
mbody=message,
mtype='chat')
if __name__ == '__main__':
xmpp = EchoBot('[email protected]', 'password')
xmpp.connect()
xmpp.process(block=True)
現在客戶端C2收到BOT消息的問題。它應該從客戶端C1接收它。爲了實現這一點,我需要C1的密碼來授權C1,我沒有在消息體中擁有它,也沒有在身體中發送密碼的安全性。
什麼是創建網關BOT的最佳方法?