def process(self, msg, type):
if not self.isInitialized:
logging.error('The forwarder was not properly initialized. Please send a message in the groups you want to connect and try again.')
return
shallSendObj = self.shallSend(msg)
if not shallSendObj['shallSend']:
return
if type == TEXT:
fromText = '[{0}]'.format(self.chatroomDisplayNames[shallSendObj['fromChatroom']])
destinationChatroomId = self.chatroomIds[not shallSendObj['fromChatroom']]
content = '{0} {1}: {2}'.format(fromText, msg['ActualNickName'], msg['Content'])
logging.info(content)
itchat.send(content, destinationChatroomId)
elif type == PICTURE:
fn = msg['FileName']
newfn = os.path.join(self.fileFolder, fn)
msg['Text'](fn)
os.rename(fn, newfn)
type = {'Picture': 'img', 'Video': 'vid'}.get(msg['Type'], 'fil')
typeText = {'Picture': '??', 'Video': '??'}.get(msg['Type'], '??')
fromText = '[{0}]'.format(self.chatroomDisplayNames[shallSendObj['fromChatroom']])
destinationChatroomId = self.chatroomIds[not shallSendObj['fromChatroom']]
content = '{0} {1} ???{2}:'.format(fromText, self.nickNameLookup.lookupNickName(msg), typeText)
itchat.send(content, destinationChatroomId)
logging.info(content)
itchat.send('@{0}@{1}'.format(type, newfn), destinationChatroomId)
elif type == SHARING:
fromText = '[{0}]'.format(self.chatroomDisplayNames[shallSendObj['fromChatroom']])
destinationChatroomId = self.chatroomIds[not shallSendObj['fromChatroom']]
content = '{0} {1} ?????: {2} {3}'.format(fromText, self.nickNameLookup.lookupNickName(msg), msg['Text'], msg['Url'])
logging.info(content)
itchat.send(content, destinationChatroomId)
else:
logging.info('Unknown type encoutered.')
pass
评论列表
文章目录