Esempio n. 1
0
 def tempSave(self,filmName):
     list = []
     conf = config()
     for i in range(self.filterWordList.count()):
         text=self.filterWordList.item(i).text()
         if text != '':
             list.append(text)
     conf.addoption(filmName,'filterword',conf.split(list))
Esempio n. 2
0
 def filmDictBuild():
     conf = config()
     dict = {}
     filmNames = conf.getSection()
     for filmName in filmNames:
         filterWords = conf.splitword(conf.getOption(filmName, "filterWord"))
         dict.update({filmName: filterWords})
     return dict
Esempio n. 3
0
 def addfilmName(self):
     self.filmWindow = MyFilmWindow()
     if self.filmWindow.exec_():
         # 数据插入表格
         conf = config()
         filmName = self.filmWindow.getFilmName()
         self.tempfilmNames.append(filmName)
         self.filmNameBox.addItem(filmName)
         conf.addSection(filmName)
     self.filmWindow.destroy()
Esempio n. 4
0
 def delfilmName(self):
     if self.filmNameBox.currentIndex() == -1:
         return
     index = self.filmNameBox.currentIndex()
     filmName = self.filmNameBox.itemText(index)
     if filmName != '---请选择---':
         conf = config()
         if filmName in self.tempfilmNames:
             self.tempfilmNames.remove(filmName)
         conf.delSection(filmName)
         self.filmNameBox.removeItem(index)
Esempio n. 5
0
 def loadFilter(self):
     try:
         self.filterWordList.clear()
         conf = config()
         index = self.filmNameBox.currentIndex()
         filmName = self.filmNameBox.itemText(index)
         filterWords = conf.splitword(conf.getOption(filmName,"filterWord"))
         for filterWord in filterWords:
             if filterWord != '':
                 self.filterWordList.addItem(filterWord)
     except Exception as e:
         pass
Esempio n. 6
0
 def text_replay(msg):
     config_get = config()
     groups_selects = config_get.splitword(config_get.getOption('qun', 'name'))
     if 'ActualNickName' in msg:
         msg_from_nickname = msg['ActualNickName']
         groups = itchat.get_chatrooms(update=True)
         for group in groups:
             if msg['FromUserName'] == group['UserName'] and group['NickName'] in groups_selects:
                 filmName, type = self.check_msg(msg.text)
                 if type:
                     self.getMsgSignal.emit('WARNING! 消息涉嫌剧透,现已自动屏蔽 FROM:{}'.format(group['NickName'] + '的' + msg_from_nickname))
                     return self.setfilmName(filmName)
Esempio n. 7
0
 def Save(self):
     list = []
     conf = config()
     for i in range(self.qunNameList.count()):
         list.append(self.qunNameList.item(i).text())
     conf.addoption('qun', 'name', conf.split(list))
     apikey = self.apiKeyEdit.text()
     conf.addoption('turing', 'apikey', apikey)
     apiPass = self.apiPassEdit.text()
     conf.addoption('turing', 'apiPass', conf.encrypt(apiPass))
     if self.replace_close.isChecked():
         conf.addoption('turing', 'enable', 'False')
     if self.replace_open.isChecked():
         conf.addoption('turing', 'enable', 'True')
Esempio n. 8
0
 def group_text(msg):
     msg_content = None
     if msg.isAt:
         groups = itchat.get_chatrooms(update=True)
         config_get = config()
         groups_selects = config_get.splitword(
             config_get.getOption('qun', 'name'))
         for group in groups:
             if group['NickName'] in groups_selects:
                 group_id = msg['FromUserName']
                 if not group_id == group['UserName']:
                     continue
                 msg_content = msg['Text']
                 msg_fromUser = msg['ActualUserName']
                 msg_reply = ''
                 group_info = itchat.update_chatroom(
                     group_id, detailedMember=True)
                 memberlist = group_info['MemberList']
                 group_Name = group['NickName']
                 for member in memberlist:
                     # 找到消息的发送者
                     if member['UserName'] == msg_fromUser:
                         # 否则显示成员自己修改的在群里的昵称
                         msg_fromUser = member['DisplayName']
                         if len(msg_fromUser) == 0:
                             # 否则显示他微信号的昵称
                             msg_fromUser = member['NickName']
                 if config_get.getOption('turing', 'enable') == 'True':
                     apiKey = config_get.getOption('turing', 'apikey')
                     msg_reply = talk(apiKey, msg_content,
                                      msg['FromUserName'])
                     itchat.send_msg(
                         '@{}\n{}'.format(msg_fromUser, msg_reply),
                         msg['FromUserName'])
                     self.getMsgSignal.emit("已自动回复" + group_Name +
                                            "的消息")
                 else:
                     for key, value in self.dict.items():
                         if key in msg_content:
                             msg_reply = value
                             itchat.send_msg(
                                 '@{}\n{}'.format(
                                     msg_fromUser, msg_reply),
                                 msg['FromUserName'])
                             self.getMsgSignal.emit("已自动回复" +
                                                    group_Name + "的消息")
Esempio n. 9
0
 def loadConfig(self):
     try:
         conf = config()
         qunNames = conf.splitword(conf.getOption("qun","name"))
         filmNames = conf.getSection()
         for qunName in qunNames:
             if qunName != '':
                 self.qunNameList.addItem(qunName)
         for filmName in filmNames:
             if filmName != '':
                 self.filmNameBox.addItem(filmName)
         apiKey = conf.getOption("turing", "apikey")
         self.apiKeyEdit.setText(apiKey)
         enable = conf.getOption("turing", "enable")
         if enable == 'False':
             self.replace_close.setChecked(True)
         else:
             self.replace_open.setChecked(True)
         apipass = conf.decrypt(conf.getOption("turing", "apiPass"))
         self.apiPassEdit.setText(apipass)
     except Exception as e:
         self.Tips("系统异常,请重试")
Esempio n. 10
0
 def tempDelete(self):
     conf = config()
     for tempfilmName in self.tempfilmNames:
         conf.delSection(tempfilmName)