def main(self, datadict):
if self.nochannel:
return
if datadict['type'] == 'message' and \
datadict.get('subtype') == "file_share" and \
datadict.get('channel') == self.channel_id:
self.imageAdd(datadict['file'])
if not datadict['type'] == 'message' or 'subtype' in datadict:
return
if datadict['text'].startswith("food "):
text = re.search(
r"(?<=food ).*", datadict['text'], re.DOTALL).group().strip()
payload = {
"username": "?? Midnight",
"icon_emoji": ":_e9_a3_9f:",
"thread_ts": datadict.get("thread_ts")or'',
"channel": datadict['channel']}
try:
ans = self.wordSearch(text)
self.slack.api_call("chat.postMessage",
attachments=[self.wordParse(ans)],
**payload
)
except BaseException:
self.slack.api_call("chat.postMessage",
text="Sorry Not Found",
**payload
)
elif datadict['text'].startswith("foodadd "):
text = re.search(r"(?<=foodadd ).*",
datadict['text']).group().strip()
jieba.add_word(text)
self.rundata.append("FOOD_addword", text)
self.init()
elif datadict['text'].startswith("fooddel "):
text = re.search(r"(?<=fooddel ).*",
datadict['text']).group().strip()
jieba.del_word(text)
self.rundata.append("FOOD_delword", text)
self.init()
评论列表
文章目录