From 2e35b010f58462300396242ac6fbb92a970e289e Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Fri, 10 Mar 2017 10:36:48 +0500 Subject: VKontakte: add .js file with stored procedures code --- protocols/VKontakte/src/vkjs.js | 269 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 protocols/VKontakte/src/vkjs.js (limited to 'protocols') diff --git a/protocols/VKontakte/src/vkjs.js b/protocols/VKontakte/src/vkjs.js new file mode 100644 index 0000000000..7ef0f9a791 --- /dev/null +++ b/protocols/VKontakte/src/vkjs.js @@ -0,0 +1,269 @@ +// Copyright (c) 2013-17 Miranda NG project (http://miranda-ng.org) +// 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 version 2 +// of the License. +// 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 . + +// Instruction: +// 1. Go to https://vk.com/editapp?id=3917910§ion=functions +// 2. Create a stored procedure with the appropriate name +// 3. Copy&Paste procedure code to code field. Save it. +// 4. Create additional version(s) stored procedure (if required) + + +// Stored procedure name: RetrieveUserInfo = Begin +// Arguments: +// Args.userid +// Args.fields + +var res=API.users.get({"user_ids":Args.userid,"fields":Args.fields,"name_case":"nom"}); +return{"freeoffline":0,"norepeat":1,"usercount":res.length,"users":res}; +// Stored procedure name: RetrieveUserInfo = End + +// Stored procedure name: RetrieveUsersInfo = Begin +// Arguments: +// Args.userids +// Args.fields +// Args.norepeat +// Args.setonline + +// ver 1 +if (Args.setonline == 1) + API.account.setOnline(); +var US=[]; +var res=API.users.get({"user_ids":API.friends.getOnline(),"fields":Args.fields,"name_case":"nom"}); +var t=10; +while(t>0){ + US=API.users.get({"user_ids":Args.userids,"fields":Args.fields,"name_case":"nom"}); + var index=US.length; + while(index>0){ + index=index-1; + if(US[index].online!=0){ + res.push(US[index]); + }; + }; + t=t-1; + if(res.length>0)t=0;}; +return{"freeoffline":1,"norepeat":Args.norepeat,"usercount":res.length,"users":res,"requests":API.friends.getRequests({"extended":0,"need_mutual":0,"out":0})}; + +// ver 2 +if (Args.setonline == 1) + API.account.setOnline(); +var res=API.users.get({"user_ids":Args.userids,"fields":Args.fields,"name_case":"nom"}); +return{"freeoffline":0,"norepeat":Args.norepeat,"usercount":res.length,"users":res,"requests":API.friends.getRequests({"extended":0,"need_mutual":0,"out":0})}; +// Stored procedure name: RetrieveUsersInfo = End + + +// Stored procedure name: GetServerHistory = Begin +// Arguments: +// Args.userid +// Args.offset +// Args.reqcount +// Args.time +// Args.lastmid +// Args.once + +var Hist=API.messages.getHistory({"user_id":Args.userid,"count":Args.reqcount,"offset":Args.offset}); +var ext=Hist.items.length; +var index=0; +while(ext!=0) { + if(Hist.items[index].date > Args.time) { + if(Hist.items[index].id > Args.lastmid) { + index=index+1; + ext=ext-1; + } else + ext=0; + } else + ext=0; + }; +var ret=Hist.items.slice(0,index); +var FMsgs=ret@.fwd_messages; +var Idx=0; +var Uids=[]; +while(Idx < FMsgs.length) { + var Jdx=0; + var CFMsgs=parseInt(FMsgs[Idx].length); + while(JdxCntLmt){ + Cnt=CntLmt; +} +if(Cnt==0) { + API.audio.setBroadcast(); +} else{ + var i=0; + var j=0; + var Track=" "; + while(iCntLmt){ + Cnt=CntLmt; +} +if(Cnt==0){ + Track="♫ "+Args.statusmsg; + API.status.set({"text":Track}); +} else { + var i=0; + var j=-1; + while(i 0) { + API.messages.delete({"message_ids":itemsMsg}); + Hist=API.messages.getHistory({"chat_id":Args.chatid, "count":200}); + countMsg = Hist.count; + itemsMsg = Hist.items@.id; +}; +return 1; +// Stored procedure name: DestroyChat = End + +// Stored procedure name: RetrieveChatInfo = Begin +// Arguments: +// Args.chatid + +// ver 1 +var Info=API.messages.getChat({"chat_id": Args.chatid}); +var ChatUsers=API.messages.getChatUsers({"chat_id":Args.chatid,"fields":"id,first_name,last_name"}); +return {"info":Info,"users":ChatUsers;}; + + +// ver 2 +var Info=API.messages.getChat({"chat_id": Args.chatid}); +var ChatUsers=API.messages.getChatUsers({"chat_id": Args.chatid, "fields": "id,first_name,last_name"}); +var ChatMsg=API.messages.getHistory({"chat_id": Args.chatid,"count":20,"rev":0}); +var UR = parseInt(ChatMsg.unread); +if(UR>20){ + if(UR>200) + UR=200; + ChatMsg=API.messages.getHistory({"chat_id":Args.chatid,"count":UR,"rev":0}); +}; +var FMsgs = ChatMsg.items@.fwd_messages; +var Idx = 0; +var Uids =[]; +while (Idx < FMsgs.length){ + var Jdx = 0; + var CFMsgs = parseInt(FMsgs[Idx].length); + while (Jdx < CFMsgs){ + Uids.unshift(FMsgs[Idx][Jdx].user_id); + Jdx = Jdx + 1; + }; + Idx = Idx + 1; +}; +var FUsers = API.users.get({"user_ids": Uids, "name_case":"gen"}); +var MsgUsers=API.users.get({"user_ids":ChatMsg.items@.user_id,"fields":"id,first_name,last_name"}); + +return {"info":Info,"users":ChatUsers ,"msgs":ChatMsg,"fwd_users":FUsers,"msgs_users":MsgUsers}; +// Stored procedure name: RetrieveChatInfo = End + +// Stored procedure name: DestroyKickChat = Begin +// Arguments: +// Args.chatid + +var Hist = API.messages.getHistory({"chat_id":Args.chatid, "count":200}); +var countMsg = Hist.count; +var itemsMsg = Hist.items@.id; +while (countMsg > 0) { + API.messages.delete({"message_ids":itemsMsg}); + Hist=API.messages.getHistory({"chat_id":Args.chatid, "count":200}); + countMsg = Hist.count; + itemsMsg = Hist.items@.id; +}; +return 1; +// Stored procedure name: DestroyKickChat = End \ No newline at end of file -- cgit v1.2.3