diff options
author | diSabler <dissy@ya.ru> | 2014-05-01 14:46:01 +0400 |
---|---|---|
committer | diSabler <dissy@ya.ru> | 2014-05-01 14:46:01 +0400 |
commit | 77dacd28415709f07f2f695fdce424f9e78b4ee3 (patch) | |
tree | 997f7d554bb240ab31d4f7c1316501f96b7f4830 | |
parent | 2f69725e958274877e3ba032b7eab6f25d03ac6b (diff) |
fix: some fixes in ai parser and locale generator
-rw-r--r-- | data/ai/ru.txt | 4 | ||||
-rw-r--r-- | data/locales/ru.txt | 6 | ||||
-rw-r--r-- | data/locales/ua.txt | 6 | ||||
-rw-r--r-- | dev-tools/locale_generator/locale_generator.py | 1 | ||||
-rw-r--r-- | plugins/ai.py | 30 |
5 files changed, 31 insertions, 16 deletions
diff --git a/data/ai/ru.txt b/data/ai/ru.txt index fc01497..0c703b9 100644 --- a/data/ai/ru.txt +++ b/data/ai/ru.txt @@ -34,7 +34,7 @@ uptime {PAR} сколько|работает|аптайм|какой||мой|м ### Other commands ### anek анекд|расска|? -calend {DATE} праздник|?|какой|что|сегодня -calend {DATE+D1} праздник|?|какой|что|завтра +calend праздник|?|какой|что|сегодня +calend {TOMORROW} праздник|?|какой|что|завтра oboobs сиськи|сиську|титьки|титьку|покажи|покаж obutts попу|попку|зад|жопу|покажи|покаж diff --git a/data/locales/ru.txt b/data/locales/ru.txt index b84b62e..c72946b 100644 --- a/data/locales/ru.txt +++ b/data/locales/ru.txt @@ -1623,6 +1623,8 @@ Raw adblock muc filter is %s Блокировка скрытой рекламы: Raw adblock filter Блокировка скрытой рекламы Repeat muc filter is %s Блокировка повтора сообщений: %s Repeat same messages filter Фильтр повтора похожих сообщений +AI is %s Искусственный интеллект: %s +AI parser for messages Использовать искусственный интеллект при парсинге сообщений Censor is %s Цензор: %s Censor Включение/выключение цензора Bomb. Time between random bombs %s Bomb. Время между случайными бомбами: %s @@ -1830,5 +1832,5 @@ Youtube settings Настройки youtube API settings Настройки API # write locale file: ru.txt -# total: 1478 -# regenarated without mistakes! +# total: 1480 +# missed translations: 2 diff --git a/data/locales/ua.txt b/data/locales/ua.txt index 70ae12c..faa611f 100644 --- a/data/locales/ua.txt +++ b/data/locales/ua.txt @@ -1623,6 +1623,8 @@ Raw adblock muc filter is %s Блокування прихованої рекл Raw adblock filter Блокування прихованої реклами Repeat muc filter is %s Повтор повідомлень: %s Repeat same messages filter Фільтр повторів схожих повідомлень +AI is %s Штучний інтелект: %s +AI parser for messages Використовувати штучний інтелект при парсінгу повідомлень Censor is %s Цензор: %s Censor Ввімкнення вимкнення цензора Bomb. Time between random bombs %s Bomb. Час між випадковими бомбами: %s @@ -1830,5 +1832,5 @@ Youtube settings Налаштування Youtube API settings Налаштування API # write locale file: ua.txt -# total: 1478 -# regenarated without mistakes! +# total: 1480 +# missed translations: 2 diff --git a/dev-tools/locale_generator/locale_generator.py b/dev-tools/locale_generator/locale_generator.py index 7fca427..60a54da 100644 --- a/dev-tools/locale_generator/locale_generator.py +++ b/dev-tools/locale_generator/locale_generator.py @@ -156,6 +156,7 @@ loc_folder = data_folder % 'locales/%s.txt' log_folder = data_folder % 'conflogs/%s' public_log = log_folder % 'chatlogs/%s' system_log = log_folder % 'syslogs/%s' +gmessage = [] locale_mark = 'NO_TRANSLATE' file_mark = '# file: ' diff --git a/plugins/ai.py b/plugins/ai.py index f099974..09bbb64 100644 --- a/plugins/ai.py +++ b/plugins/ai.py @@ -46,12 +46,12 @@ def AI_PARSE(room, jid, nick, type, text): if CUR_SCORE > SCORE: SCORE, CMD = CUR_SCORE, [PHRASES] elif CUR_SCORE == SCORE: CMD.append(PHRASES) if not CMD: return + nowname = getResourse(cur_execute_fetchone('select room from conference where room ilike %s',('%s/%%'%room,))[0]) + if nowname == nick: return pprint('AI score %s|%s|%s' % (SCORE, '|'.join([t[0] for t in CMD]), text),'cyan') CMD = random.choice(CMD) CMD_RAW = CMD[0].split()[0] pprint('AI selected %s' % CMD_RAW,'cyan') - - nowname = getResourse(cur_execute_fetchone('select room from conference where room ilike %s',('%s/%%'%room,))[0]) access_mode = get_level(room,nick)[0] if cur_execute_fetchone('select * from commonoff where room=%s and cmd=%s',(room,CMD_RAW)): return ptype = '' @@ -72,11 +72,17 @@ def AI_PARSE(room, jid, nick, type, text): break if not PP: PRM.append(nick) + COMMAND = CMD[0] + COMMAND = COMMAND.replace('{TOMORROW}',time.strftime('%d.%m', time.localtime(time.time()+86400))) + WAS_PARAM = False for PARAM in PRM: if PARAM: - COMMAND = CMD[0].replace('{PAR}',PARAM) - print COMMAND - com_parser(access_mode, nowname, type, room, nick, COMMAND, jid) + if time_nolimit: time.sleep(time_nolimit) + com_parser(access_mode, nowname, type, room, nick, COMMAND.replace('{PAR}',PARAM), jid) + WAS_PARAM = True + if not WAS_PARAM: + if time_nolimit: time.sleep(time_nolimit) + com_parser(access_mode, nowname, type, room, nick, COMMAND, jid) def AI_RATING(s, text, room): r,s = 0.0,s.split('|') @@ -86,23 +92,27 @@ def AI_RATING(s, text, room): return r def AI_PARAMETER(body, type, room): - P_NICK, P_JID, P_SERVER = None, None, None + P_NICK, P_JID, P_SERVER = [], [], [] if 'nick' in type: NICKS = [t[1] for t in megabase if t[0]==room] for NICK in NICKS: if NICK in body: - P_NICK = NICK + P_NICK.append(NICK) break if 'jid' in type: JID = re.findall(u'[-a-z0-9а-яё_]+@[-0-9a-z\.]+',body,re.S|re.I|re.U) - if JID: P_JID = JID[0] + if JID: P_JID += JID if 'server' in type: SERVER = re.findall(u'[-0-9a-zа-яё\.]+\.[-a-zа-я]{2,}',body,re.S|re.I|re.U) - if SERVER: P_SERVER = SERVER[0] + if SERVER: P_SERVER += SERVER - return [P_NICK, P_JID, P_SERVER] + RESULT = [] + for t in P_NICK + P_JID + P_SERVER: + if t not in RESULT: RESULT.append(t) + + return RESULT gmessage.append(AI_PARSE) |