From 0625b5c3d4aed9ee63ef1cfba903485bdfb2fde5 Mon Sep 17 00:00:00 2001 From: annelin Date: Sun, 5 May 2019 00:21:59 +0300 Subject: [PATCH] Release 1.0-beta2 [FIX] Fixed /connect command [ADD] Added session counter (active/total) in /debug command --- inc/telegramclient.rb | 2 +- inc/xmppcomponent.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/telegramclient.rb b/inc/telegramclient.rb index 1e0bbc7..4d5c749 100644 --- a/inc/telegramclient.rb +++ b/inc/telegramclient.rb @@ -528,7 +528,7 @@ class TelegramClient return path end - ########################################### + # state functions # def online?() @online end def tz_set?() return @timezone != '-00:00' end end diff --git a/inc/xmppcomponent.rb b/inc/xmppcomponent.rb index aace9f6..c53c4a8 100644 --- a/inc/xmppcomponent.rb +++ b/inc/xmppcomponent.rb @@ -204,7 +204,7 @@ class XMPPComponent when '/code', '/password' # pass auth data to telegram @sessions[from.bare.to_s].process_auth(body.split[0], body.split[1]) if @sessions.key? from.bare.to_s when '/connect' # go online - @sessions[from.bare.to_s].client.connect() if @sessions.key? from.bare.to_s + @sessions[from.bare.to_s].connect() if @sessions.key? from.bare.to_s when '/disconnect' # go offline (without destroying a session) @sessions[from.bare.to_s].disconnect() if @sessions.key? from.bare.to_s when '/logout' # go offline and destroy session @@ -218,6 +218,7 @@ class XMPPComponent Memprof2.report(out: dump) if dump response = "Debug information: \n\n" response += "Running from: %s\n" % `ps -p #{$$} -o lstart`.lines.last.strip + response += "Sessions: %d online | %d total \n" % [ @sessions.inject(0){ |cnt, (jid, sess)| cnt = (sess.online?) ? cnt + 1 : cnt }, @sessions.count] response += "System memory used: %d KB\n" % `ps -o rss -p #{$$}`.lines.last.strip.to_i response += "Objects memory allocated: %d bytes \n" % `cut -d' ' -f1 #{dump}`.lines.map(&:to_i).reduce(0, :+) if dump response += "\nDetailed memory info saved to %s\n" % dump if dump