Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/isida/3.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiSabler <dissy@ya.ru>2013-11-04 14:29:49 +0400
committerdiSabler <dissy@ya.ru>2013-11-04 14:29:49 +0400
commit618d7a11f645eefe21d5d9f1c86534545019f506 (patch)
treec16ad9f28f4ba12d627cc7dcad8fbe9a93fda696 /plugins
parentc098e9bce94f8e5fa4b6187b8238dd6216f591ae (diff)
add: steam plugin
chg: all api keys moved to one page in setting fix: locale in time function
Diffstat (limited to 'plugins')
-rw-r--r--plugins/main.py12
-rw-r--r--plugins/steam.py70
2 files changed, 78 insertions, 4 deletions
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 = (('&','&amp;'),('\"','&quot;'),('\'','&apos;'),('<','&lt;'),('>','&gt;'))
@@ -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 <dsy@dsy.name> #
+# #
+# 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://www.gnu.org/licenses/>. #
+# #
+# --------------------------------------------------------------------------- #
+
+#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')]