Release 0.4.1

[FIX] fixed joining groups/adding contacts
[FIX] fixed kick/ban/unban commands
[FIX] fixed status of supergroups
This commit is contained in:
annelin 2019-04-13 18:39:20 +03:00
parent 7cff994cba
commit 0032a83894
2 changed files with 11 additions and 10 deletions

View file

@ -232,18 +232,17 @@ class TelegramClient
case splitted[0]
when '/add' # open new private chat by its id
chat = (resolved) ? resolved.id : splitted[1].to_i
@client.create_private_chat(chat).wait
self.process_chat_info(chat)
self.process_chat_info(chat) if chat != 0
when '/join' # join group/supergroup by invite link or by id
chat = splitted[1]
chat.start_with? "http" ? @client.join_chat_by_invite_link(chat).wait : @client.join_chat(chat.to_i).wait
chat = (resolved) ? resolved.id : splitted[1]
chat.to_s[0..3] == "http" ? @client.join_chat_by_invite_link(chat).wait : @client.join_chat(chat.to_i).wait
when '/invite' # invite user to chat
@client.add_chat_member(chat_id, response.id).wait if resolved
@client.add_chat_member(chat_id, resolved.id).wait if resolved
when '/kick' # removes user from chat
@client.set_chat_member_status(chat_id, response.id, TD::Types::ChatMemberStatus::Left.new()).wait if resolved
@client.set_chat_member_status(chat_id, resolved.id, TD::Types::ChatMemberStatus::Left.new()).wait if resolved
when '/ban' # removes user from chat. argument = hours to ban.
until_date = (splitted[1]) ? Time.now.getutc.to_i + splitted[1].to_i * 3600 : 0
@client.set_chat_member_status(chat_id, response.id, TD::Types::ChatMemberStatus::Banned.new(banned_until_date: until_date)).wait if resolved
@client.set_chat_member_status(chat_id, resolved.id, TD::Types::ChatMemberStatus::Banned.new(banned_until_date: until_date)).wait if resolved
when '/block' # add user to blacklist
@client.block_user(chat_id)
when '/unblock' # add user to blacklist

View file

@ -1,5 +1,6 @@
require 'sqlite3'
require 'xmpp4r'
require 'digest'
#############################
### Some constants #########
@ -102,14 +103,15 @@ class XMPPComponent
def iq_handler(iq)
@logger.debug "New iq received"
@logger.debug(iq.to_s)
reply = iq.answer
if iq.vcard and @sessions.key? iq.from.bare.to_s then
vcard = @sessions[iq.from.bare.to_s].make_vcard(iq.to.to_s)
reply = iq.answer
reply.type = :result
reply.elements["vCard"] = vcard
@@transport.send(reply)
else
reply = iq.answer
reply.type = :error
end
@@transport.send(reply)