From 618d7a11f645eefe21d5d9f1c86534545019f506 Mon Sep 17 00:00:00 2001 From: diSabler Date: Mon, 4 Nov 2013 14:29:49 +0400 Subject: add: steam plugin chg: all api keys moved to one page in setting fix: locale in time function --- data/locales/ru.txt | 36 ++++++++++++++++----------- data/locales/ua.txt | 29 +++++++++++----------- kernel.py | 4 +-- plugins/main.py | 12 ++++++--- plugins/steam.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 117 insertions(+), 34 deletions(-) create mode 100644 plugins/steam.py diff --git a/data/locales/ru.txt b/data/locales/ru.txt index a246b29..7ea726c 100644 --- a/data/locales/ru.txt +++ b/data/locales/ru.txt @@ -871,18 +871,18 @@ Thu Чт Fri Пт Sat Сб Sun Вс -Jan Янв -Fed Фев -Mar Мар -Apr Апр -May мая -Jun Июн -Jul Июл -Aug Авг -Sep Сен -Oct Окт -Nov Ноя -Dec Дек +_Jan Янв +_Fed Фев +_Mar Мар +_Apr Апр +_May Мая +_Jun Июн +_Jul Июл +_Aug Авг +_Sep Сен +_Oct Окт +_Nov Ноя +_Dec Дек no limit без ограничений visitor/none гость без полномочий visitor/member гость и постоянный участник @@ -1280,6 +1280,12 @@ I leave your conference because low activity Сваливаю из-за низк I leave conference %s by condition spy plugin: %s Конференция %s покинута по условию spy плагина: %s Check conference activity\nspy add [ u][ m] - add conference to list. u - count users, m - count message per night. At default At least one condition - the bot will leave the conference\nspy del - remove conference from list\nspy show - show active monitoring. Проверка активности конференции\nspy add [ u][ m] - добавить конференцию в список мониторинга активности. u - среднее число участников, m - количество сообщение за сутки. При невыполнении хотя бы одного условия - бот выйдет из конференции\nspy del - удалить конференцию из списка мониторинга\nspy show - показать активное слежение +# file: plugins/steam.py +Nick: %s\nName: %s\nCountry: %s\nCreated: %s\nLast logoff: %s\nTotal friends: %s\nFriends: %s Ник: %s\nИмя: %s\nСтрана: %s\nСоздан: %s\nПоследний выход: %s\nВсего друзей: %s\nДрузья: %s +Steam API key is wrong! Неверный Steam API ключ! +Steam ID shald be digital! Steam ID должен быть цифровым! +Show information about Steam profile Показ информации о профиле Steam + # file: plugins/svn.py en_EN.UTF8 ru_RU.UTF8 Read user manual for commands... Изучаем инструкции к командам... @@ -1765,6 +1771,7 @@ Troll. Maximal message number for troll command Troll. Максимальное Kernel. Iq anti-ddos. Time limits for requests Kernel. Iq anti-ddos. Лимит времени на запросы Muc-filter. Count of events for notify Muc-filter. Уведомления. Количество событий для уведомления Iq. Number after point in ping Iq. Количество знаков после запятой при пинге +Steam. API-key Steam. API-ключ Muc-filter. Time between presences Muc-filter. Промежуток времени на статус-презенсы Notepad Блокнот Kernel. Anti-ddos time delay between messages Kernel. Промежуток между сообщениями для включения анти-ddos @@ -1793,7 +1800,8 @@ Iq requests settings Настройки Iq запросов Juick settings Настройки juick Logs settings Настройки логов Youtube settings Настройки youtube +API settings Настройки API # write locale file: ru.txt -# total: 1469 -# regenarated without mistakes! +# total: 1475 +# missed translations: 6 diff --git a/data/locales/ua.txt b/data/locales/ua.txt index ccdd22f..70bf988 100644 --- a/data/locales/ua.txt +++ b/data/locales/ua.txt @@ -871,18 +871,18 @@ Thu Чт Fri Пт Sat Сб Sun Нд -Jan Січ -Fed Лют -Mar Бер -Apr Кві -May Трав -Jun Чер -Jul Лип -Aug Сер -Sep Вер -Oct Жов -Nov Лис -Dec Гру +_Jan Січ +_Fed Лют +_Mar Бер +_Apr Кві +_May Тра +_Jun Чер +_Jul Лип +_Aug Сер +_Sep Вер +_Oct Жов +_Nov Лис +_Dec Гру no limit без обмежень visitor/none гість без повноважень visitor/member гість і постійний учасник @@ -1795,5 +1795,6 @@ Logs settings Налаштування логів Youtube settings Налаштування Youtube # write locale file: ua.txt -# total: 1469 -# regenarated without mistakes! +# total: 1475 +# missed translations: 6 + diff --git a/kernel.py b/kernel.py index 703380a..7a48f44 100644 --- a/kernel.py +++ b/kernel.py @@ -748,7 +748,7 @@ def disp_time(*t): else: rn = '' t = t[0] lt=tuple(time.localtime(t)) - return '%02d:%02d:%02d, %02d.%s\'%s, %s' % (lt[3],lt[4],lt[5],lt[2],L(wmonth[lt[1]-1],rn),lt[0],L(wday[lt[6]],rn)) + return '%02d:%02d:%02d, %02d.%s\'%s, %s' % (lt[3],lt[4],lt[5],lt[2],L(wmonth[lt[1]-1],rn).replace('_',''),lt[0],L(wday[lt[6]],rn)) def nice_time(*ttim): if len(ttim) == 2: rn = ttim[1] @@ -761,7 +761,7 @@ def nice_time(*ttim): else: t_gmt = 'GMT+%s' % int(timeofset) if timeofset%1: t_gmt += ':%02d' % int((timeofset%1*60/100) * 100) t_utc='%s%02d%02dT%02d:%02d:%02d' % gt[:6] - t_display = '%02d:%02d:%02d, %02d.%s\'%s, %s, ' % (lt[3],lt[4],lt[5],lt[2],L(wmonth[lt[1]-1],rn),lt[0],L(wday[lt[6]],rn)) + t_display = '%02d:%02d:%02d, %02d.%s\'%s, %s, ' % (lt[3],lt[4],lt[5],lt[2],L(wmonth[lt[1]-1],rn).replace('_',''),lt[0],L(wday[lt[6]],rn)) #t_tz = time.tzname[time.localtime()[8]] #enc = chardet.detect(t_tz)['encoding'] #if t_tz == None: body = '' diff --git a/plugins/main.py b/plugins/main.py index 4364683..8c35787 100644 --- a/plugins/main.py +++ b/plugins/main.py @@ -21,7 +21,7 @@ # # # --------------------------------------------------------------------------- # -# translate: random,smart,full,partial,on,off,kick,ban,replace,mute,visitor,truncate,paste,chat,online,away,xa,dnd,on start,on shutdown,by time,black,white,without highlight,all,ban server,Loading...,Mon,Tue,Wed,Thu,Fri,Sat,Sun,Jan,Fed,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,no limit,visitor/none,visitor/member,participant/none,participant/member,moderator/none,moderator/member,moderator/admin,moderator/owner,bot owner,You should be at least %s to do it.,You must be a %s to do it.,absent +# translate: random,smart,full,partial,on,off,kick,ban,replace,mute,visitor,truncate,paste,chat,online,away,xa,dnd,on start,on shutdown,by time,black,white,without highlight,all,ban server,Loading...,Mon,Tue,Wed,Thu,Fri,Sat,Sun,_Jan,_Fed,_Mar,_Apr,_May,_Jun,_Jul,_Aug,_Sep,_Oct,_Nov,_Dec,no limit,visitor/none,visitor/member,participant/none,participant/member,moderator/none,moderator/member,moderator/admin,moderator/owner,bot owner,You should be at least %s to do it.,You must be a %s to do it.,absent rlmas_min = (('&','&'),('\"','"'),('\'','''),('<','<'),('>','>')) @@ -112,7 +112,7 @@ msg_status_codes = {'102':L('Room now shows unavailable members.'), '174':L('Room now is fully-anonymous.')} wday = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'] -wmonth = ['Jan','Fed','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] +wmonth = ['_Jan','_Fed','_Mar','_Apr','_May','_Jun','_Jul','_Aug','_Sep','_Oct','_Nov','_Dec'] two_en = ['aa', 'aq', 'bc', 'bd', 'bf', 'bg', 'bh', 'bk', 'bn', 'bp', 'bq', 'bw', 'bx', 'bz', 'cb', 'cd', 'cf', 'cg', 'cj', \ 'cm', 'cn', 'cp', 'cs', 'cv', 'cw', 'cx', 'cz', 'db', 'dc', 'dh', 'dj', 'dp', 'dq', 'dt', 'dx', 'dz', 'ej', 'fb', \ @@ -1843,6 +1843,7 @@ owner_prefs = {'syslogs_enable': ['Logger. Enable system logs','b',True], 'html_paste_enable':['Paste. Paste as html. Otherwize as text','b',True], 'yandex_api_key':['City. Yandex.Map API-key','t128','no api'], 'bing_api_key':['Bing. Translator API-key','t128','no api'], + 'steam_api_key':['Steam. API-key','t128','no api'], 'censor_text':['Kernel. Text for hide censore','t32','[censored]'], 'ddos_limit':['Kernel. Time of ignore for anti-ddos','l10','[1800,1800,1800,1800,1800,600,300,150,60,0]'], 'ddos_diff':['Kernel. Anti-ddos time delay between messages','l10','[30,30,30,30,20,20,15,10,5,0]'], @@ -1884,7 +1885,10 @@ owner_group_youtube = ['Youtube settings','#owner-youtube', owner_group_other = ['Other settings','#owner-other', ['anek_private_limit','backup_sleep_time','calendar_default_splitter', - 'disco_max_limit','disco_exclude','html_paste_enable','yandex_api_key','bing_api_key']] + 'disco_max_limit','disco_exclude','html_paste_enable']] + +owner_group_api = ['API settings','#owner-api', + ['yandex_api_key','bing_api_key','steam_api_key','lfm_api']] owner_group_karma = ['Karma settings','#owner-karma', ['karma_limit','karma_show_default_limit','karma_show_max_limit','karma_timeout','karma_discret','karma_discret_lim_up','karma_discret_lim_dn']] @@ -1937,7 +1941,7 @@ owner_groups = [owner_group_amsg,owner_group_rss,owner_group_clear, owner_group_karma,owner_group_sayto,owner_group_age, owner_group_mucfilter,owner_group_iq,owner_group_juick, owner_group_logs,owner_group_youtube,owner_group_other, - owner_group_notepad] + owner_group_api,owner_group_notepad] comms = [ (0, 'help', helpme, 2, 'Help system. Helps without commands: about, donation, access'), diff --git a/plugins/steam.py b/plugins/steam.py new file mode 100644 index 0000000..c56168a --- /dev/null +++ b/plugins/steam.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# --------------------------------------------------------------------------- # +# # +# Plugin for iSida Jabber Bot # +# Copyright (C) diSabler # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +# --------------------------------------------------------------------------- # + +#http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=xxxx&steamids=76561198018559638 +#http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=xxxx&steamid=76561198018559638&relationship=friend + +steam_api_url = 'http://api.steampowered.com/ISteamUser/%s' +steam_summary = steam_api_url % 'GetPlayerSummaries/v0002/?' +steam_friends = steam_api_url % 'GetFriendList/v0001/?' + +def time_str(t): return time.strftime('%Y.%m.%d %H:%M',time.localtime(t)) + +def steam(type, jid, nick, text): + text = text.strip().split() + need_id = len(text) > 1 + text = text[0] + if text.isdigit(): + STEAM_API = GT('steam_api_key') + if len(STEAM_API) == 32: + data = load_page(steam_summary, {'key': STEAM_API, 'steamids': text}) + data = json.loads(data)['response']['players'][0] + _PERSONANAME = data.get('personaname','') + _REALNAME = data.get('realname','') + _LOCCOUNTRYCODE = data.get('loccountrycode','') + _TIMECREATED = data.get('timecreated','') + _LASTLOGOFF = data.get('lastlogoff','') + data = load_page(steam_friends, {'key': STEAM_API, 'steamid': text, 'relationship': 'friend'}) + data = json.loads(data)['friendslist']['friends'] + _FRIENDS = ','.join(t['steamid'] for t in data) + data = load_page(steam_summary, {'key': STEAM_API, 'steamids': _FRIENDS}) + data = json.loads(data)['response']['players'] + _FRIENDS = [(t.get('personaname','-'),t['steamid']) for t in data] + _LEN_FRIENDS = len(_FRIENDS) + if need_id: _FRIENDS = ' | '.join('%s %s' % t for t in _FRIENDS) + else: _FRIENDS = ', '.join(t[0] for t in _FRIENDS) + + msg = L('Nick: %s\nName: %s\nCountry: %s\nCreated: %s\nLast logoff: %s\nTotal friends: %s\nFriends: %s','%s/%s'%(jid,nick)) %\ + (_PERSONANAME,_REALNAME,_LOCCOUNTRYCODE,time_str(_TIMECREATED),time_str(_LASTLOGOFF),_LEN_FRIENDS,_FRIENDS) + + if need_id and type == 'groupchat': + send_msg(type, jid, nick, L('Send for you in private','%s/%s'%(jid,nick))) + type = 'chat' + + else: msg = L('Steam API key is wrong!','%s/%s'%(jid,nick)) + else: msg = L('Steam ID shald be digital!','%s/%s'%(jid,nick)) + send_msg(type, jid, nick, msg) + +global execute + +execute = [(3, 'steam', steam, 2, 'Show information about Steam profile')] -- cgit v1.2.3