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] case splitted[0]
when '/add' # open new private chat by its id when '/add' # open new private chat by its id
chat = (resolved) ? resolved.id : splitted[1].to_i chat = (resolved) ? resolved.id : splitted[1].to_i
@client.create_private_chat(chat).wait self.process_chat_info(chat) if chat != 0
self.process_chat_info(chat)
when '/join' # join group/supergroup by invite link or by id when '/join' # join group/supergroup by invite link or by id
chat = splitted[1] chat = (resolved) ? resolved.id : splitted[1]
chat.start_with? "http" ? @client.join_chat_by_invite_link(chat).wait : @client.join_chat(chat.to_i).wait 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 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 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. 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 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 when '/block' # add user to blacklist
@client.block_user(chat_id) @client.block_user(chat_id)
when '/unblock' # add user to blacklist when '/unblock' # add user to blacklist

View file

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