This commit is contained in:
2019-02-27 18:52:12 +01:00
parent 498d392165
commit cea496c808

View File

@@ -1,8 +1,6 @@
import re, sys, os, io, sqlite3, hashlib, time, datetime
import xml.etree.ElementTree as ET
import logging, traceback, pprint
import time
import logging, pprint
from xmpp_tg.mtproto import TelegramGateClient
from xmpp_tg.utils import var_dump, display_tg_name, get_contact_jid, localtime
# modified by adnidor
@@ -85,236 +83,235 @@ class CommandHandler():
class GateCommandHandler(CommandHandler):
_helptext = "Available Gateway commands:"
def configure(hndl, self):
def configure(self, gate):
"""Get config/set config options"""
config_exclude = ['jid', 'tg_phone']
option = hndl.arguments[0] if len(hndl.arguments) >= 1 else None
value = hndl.arguments[1] if len(hndl.arguments) == 2 else None
option = self.arguments[0] if len(self.arguments) >= 1 else None
value = self.arguments[1] if len(self.arguments) == 2 else None
if value is not None and option not in config_exclude:
self.db_connection.execute("update accounts set {} = ? where jid = ?".format(option), (value,hndl.jid,) )
self.accounts[hndl.jid] = self.db_connection.execute("SELECT * FROM accounts where jid = ?", (hndl.jid,) ).fetchone()
gate.db_connection.execute("update accounts set {} = ? where jid = ?".format(option), (value, self.jid,))
gate.accounts[self.jid] = gate.db_connection.execute("SELECT * FROM accounts where jid = ?", (self.jid,)).fetchone()
message = "=== Your current configuration ===\n\n"
for param, value in self.accounts[hndl.jid].items():
for param, value in gate.accounts[self.jid].items():
message = message + "<%s>: %s" % (param, value) + "\n"
message = message + "\nTo modify some option, please, send !configure param value"
return message
def login(hndl, self): #1 arg
def login(self, gate): #1 arg
"""Initiates Telegram session
Usage: !login <phone number in international format>"""
hndl._min_args(1)
self._min_args(1)
phone_no = hndl.arguments[0]
phone_no = self.arguments[0]
hndl._update("Please wait...")
self.spawn_tg_client(hndl.jid, phone_no)
self._update("Please wait...")
gate.spawn_tg_client(self.jid, phone_no)
if self.tg_connections[hndl.jid].is_user_authorized():
self.send_presence(pto=jid, pfrom=self.boundjid.bare, ptype='online', pstatus='connected')
if gate.tg_connections[self.jid].is_user_authorized():
gate.send_presence(pto=jid, pfrom=gate.boundjid.bare, ptype='online', pstatus='connected')
return "You are already authenticated in Telegram"
else:
# remove old sessions for this JID #
self.db_connection.execute("DELETE from accounts where jid = ?", (hndl.jid, ) )
self.tg_connections[hndl.jid].send_code_request(phone_no)
self._update('Gate is connected. Telegram should send SMS message to you.')
gate.db_connection.execute("DELETE from accounts where jid = ?", (self.jid,))
gate.tg_connections[self.jid].send_code_request(phone_no)
gate._update('Gate is connected. Telegram should send SMS message to you.')
return 'Please enter one-time code via !code 12345.'
def code(hndl, self):
def code(self, gate):
"""nolist Enter confirmation code"""
hndl._min_args(1)
self._min_args(1)
code = hndl.arguments[0]
jid = hndl.jid
code = self.arguments[0]
jid = self.jid
if not self.tg_connections[jid].is_user_authorized():
if not gate.tg_connections[jid].is_user_authorized():
try:
hndl._update('Trying authenticate...')
self.tg_connections[jid].sign_in(self.tg_phones[jid], code)
self._update('Trying authenticate...')
gate.tg_connections[jid].sign_in(gate.tg_phones[jid], code)
except SessionPasswordNeededError:
self.gate_reply_message(iq, 'Two-factor authentication detected.')
self.gate_reply_message(iq, 'Please enter your password via !password abc123.')
self._update('Two-factor authentication detected.')
self._update('Please enter your password via !password abc123.')
return
if self.tg_connections[jid].is_user_authorized():
self.send_presence(pto=jid, pfrom=self.boundjid.bare, ptype='online', pstatus='connected')
self.gate_reply_message(iq, 'Authentication successful. Initiating Telegram...')
self.db_connection.execute("INSERT INTO accounts(jid, tg_phone) VALUES(?, ?)", (jid, self.tg_phones[jid],))
self.accounts[jid] = self.db_connection.execute("SELECT * FROM accounts where jid = ?", (jid,) ).fetchone()
self.init_tg(jid)
if gate.tg_connections[jid].is_user_authorized():
gate.send_presence(pto=jid, pfrom=gate.boundjid.bare, ptype='online', pstatus='connected')
self._update('Authentication successful. Initiating Telegram...')
gate.db_connection.execute("INSERT INTO accounts(jid, tg_phone) VALUES(?, ?)", (jid, gate.tg_phones[jid],))
gate.accounts[jid] = gate.db_connection.execute("SELECT * FROM accounts where jid = ?", (jid,)).fetchone()
gate.init_tg(jid)
else:
return 'Authentication failed.'
else:
return 'You are already authenticated. Please use !logout before new login.'
def password(hndl, self):
def password(self, gate):
"""nolist Enter password"""
hndl._min_args(1)
self._min_args(1)
password = hndl.arguments[1]
jid = self.jid
password = self.arguments[1]
jid = gate.jidhndl
if not self.tg_connections[jid].is_user_authorized():
self.gate_reply_message(iq, 'Checking password...')
self.tg_connections[jid].sign_in(password=password)
if not gate.tg_connections[jid].is_user_authorized():
self._update('Checking password...')
gate.tg_connections[jid].sign_in(password=password)
if self.tg_connections[jid].is_user_authorized():
self.send_presence(pto=jid, pfrom=self.boundjid.bare, ptype='online', pstatus='connected')
self.gate_reply_message(iq, 'Authentication successful. Initiating Telegram...')
self.db_connection.execute("INSERT INTO accounts(jid, tg_phone) VALUES(?, ?)", (jid, self.tg_phones[jid],))
self.accounts[jid] = self.db_connection.execute("SELECT * FROM accounts where jid = ?", (jid,) ).fetchone()
self.init_tg(jid)
if gate.tg_connections[jid].is_user_authorized():
gate.send_presence(pto=jid, pfrom=gate.boundjid.bare, ptype='online', pstatus='connected')
self._update('Authentication successful. Initiating Telegram...')
gate.db_connection.execute("INSERT INTO accounts(jid, tg_phone) VALUES(?, ?)", (jid, gate.tg_phones[jid],))
gate.accounts[jid] = gate.db_connection.execute("SELECT * FROM accounts where jid = ?", (jid,)).fetchone()
gate.init_tg(jid)
else:
self.gate_reply_message(iq, 'Authentication failed.')
return 'Authentication failed.'
else:
self.gate_reply_message(iq, 'You are already authenticated. Please use !logout before new login.')
return 'You are already authenticated. Please use !logout before new login.'
def reload_dialogs(hndl, self):
def reload_dialogs(self, gate):
"""Reload Telegram dialogs"""
if not self.tg_connections[hndl.jid].is_user_authorized():
if not gate.tg_connections[self.jid].is_user_authorized():
return "Error"
self.tg_process_dialogs(hndl.jid)
gate.tg_process_dialogs(self.jid)
return "Dialogs reloadad"
def logout(hndl, self):
def logout(self, gate):
"""Deletes current Telegram session at Gateway"""
self.tg_connections[hndl.jid].log_out()
self.db_connection.execute("DELETE FROM accounts WHERE jid = ?", (hndl.jid,))
gate.tg_connections[self.jid].log_out()
gate.db_connection.execute("DELETE FROM accounts WHERE jid = ?", (self.jid,))
return 'Your Telegram session was deleted'
def add(hndl, self): #1 arg
def add(self, gate): #1 arg
"""Add contact by nickname or t.me link"""
hndl._min_args(1)
self._min_args(1)
argument = hndl.arguments[0]
jid = hndl.jid
argument = self.arguments[0]
jid = self.jid
result = self.tg_connections[jid].get_entity(argument)
result = gate.tg_connections[jid].get_entity(argument)
if type(result) == User:
tg_peer = InputPeerUser( result.id, result.access_hash )
result = self.tg_connections[jid].invoke( SendMessageRequest(tg_peer, 'Hello! I just want to add you in my contact list.', generate_random_long() ) )
result = gate.tg_connections[jid].invoke(SendMessageRequest(tg_peer, 'Hello! I just want to add you in my contact list.', generate_random_long()))
elif type(result) == Channel:
tg_peer = InputPeerChannel( result.id, result.access_hash )
self.tg_connections[jid].invoke(JoinChannelRequest( InputPeerChannel(result.id, result.access_hash) ) )
gate.tg_connections[jid].invoke(JoinChannelRequest(InputPeerChannel(result.id, result.access_hash)))
else:
self.gate_reply_message(iq, 'Sorry, nothing found.')
return
self.tg_process_dialogs(jid)
return 'Sorry, nothing found.'
gate.tg_process_dialogs(jid)
def join(hndl, self): #1 arg
def join(self, gate): #1 arg
"""Join conference via invite link"""
hndl._min_args(1)
self._min_args(1)
argument = hndl.arguments[0]
jid = hndl.jid
argument = self.arguments[0]
jid = self.jid
link = argument.split('/') # https://t.me/joinchat/HrCmckx_SkMbSGFLhXCvSg
self.tg_connections[jid].invoke(ImportChatInviteRequest(link[4]))
gate.tg_connections[jid].invoke(ImportChatInviteRequest(link[4]))
time.sleep(1)
self.tg_process_dialogs(jid)
gate.tg_process_dialogs(jid)
def group(hndl, self): #2 args
def group(self, gate): #2 args
"""Creat a Group"""
hndl._min_args(2)
self._min_args(2)
# group name? #
groupname = parsed[1]
# group users? #
groupuser = self.tg_connections[jid].get_entity(parsed[2])
groupuser = gate.tg_connections[jid].get_entity(parsed[2])
# we re ready to make group
self.tg_connections[jid].invoke(CreateChatRequest([groupuser], groupname))
self.tg_process_dialogs(jid)
gate.tg_connections[jid].invoke(CreateChatRequest([groupuser], groupname))
gate.tg_process_dialogs(jid)
def supergroup(hndl, self): #1 arg
def supergroup(self, gate): #1 arg
"""Create a channel"""
hndl._min_args(1)
self._min_args(1)
groupname = hndl.arguments[0]
self.tg_connections[hndl.jid].invoke(CreateChannelRequest(groupname, groupname, megagroup = True))
self.tg_process_dialogs(hndl.jid)
groupname = self.arguments[0]
gate.tg_connections[self.jid].invoke(CreateChannelRequest(groupname, groupname, megagroup = True))
gate.tg_process_dialogs(self.jid)
channel = supergroup
def username(hndl, self): #1 arg
def username(self, gate): #1 arg
"""Change your Telegram nickname"""
hndl._min_args(1)
self._min_args(1)
username = hndl.arguments[0]
username = self.arguments[0]
self.tg_connections[hndl.jid].invoke(UpdateUsernameRequest(username))
gate.tg_connections[self.jid].invoke(UpdateUsernameRequest(username))
def name(hndl, self): #1 or 2 args
def name(self, gate): #1 or 2 args
"""Change your Telegram display name"""
hndl._min_args(1)
self._min_args(1)
firstname = hndl.arguments[0]
lastname = hndl.arguments[1] if len(hndl.arguments) > 1 else None
firstname = self.arguments[0]
lastname = self.arguments[1] if len(self.arguments) > 1 else None
self.tg_connections[hndl.jid].invoke(UpdateProfileRequest(first_name = firstname, last_name = lastname))
gate.tg_connections[self.jid].invoke(UpdateProfileRequest(first_name = firstname, last_name = lastname))
def about(hndl, self): #>0 args
def about(self, gate): #>0 args
"""Change your Telegram 'about' text"""
hndl._min_args(1)
self._min_args(1)
about = hndl.msg['body'][7:]
self.tg_connections[hndl.jid].invoke(UpdateProfileRequest(about = about))
about = self.msg['body'][7:]
gate.tg_connections[self.jid].invoke(UpdateProfileRequest(about = about))
def import_contact(hndl, self): #2 args
def import_contact(self, gate): #2 args
"""Add contact by phone number"""
hndl._min_args(2)
self._min_args(2)
phone = hndl.arguments[0]
firstname = hndl.arguments[1]
lastname = hndl.arguments[2] if len(hndl.arguments) > 2 else None
phone = self.arguments[0]
firstname = self.arguments[1]
lastname = self.arguments[2] if len(self.arguments) > 2 else None
contact = InputPhoneContact(client_id=generate_random_long(), phone=phone, first_name=firstname, last_name=lastname)
self.tg_connections[hndl.jid].invoke(ImportContactsRequest([contact]))
self.tg_process_dialogs(jid)
gate.tg_connections[self.jid].invoke(ImportContactsRequest([contact]))
gate.tg_process_dialogs(jid)
def roster(hndl, self):
def roster(self, gate):
"""Send Telegram contact list back, with JIDs"""
response = "Telegram chats:\n"
for jid,tid in self.contact_list[hndl.jid].items():
for jid,tid in gate.contact_list[self.jid].items():
response += "{}: {}\n".format(tid, jid)
return response
def oldhelp(hndl, self):
def oldhelp(self, gate):
"""nolist Old !help message"""
return ('=== Available gateway commands ===:\n\n'
'!help - Displays this text\n'
'!login +123456789 - Initiates Telegram session\n'
'!code 12345 - Entering one-time code during auth\n'
'!password abc123 - Entering password during two-factor auth\n'
'!configure - Configure transport settings\n'
#'!list_sessions - List all created sessions at Telegram servers\n'
#'!delete_session 123 - Delete session\n'
'!logout - Deletes current Telegram session at gate\n'
'!reload_dialogs - Reloads dialogs list from Telegram\n\n'
'!help - Displays this text\n'
'!login +123456789 - Initiates Telegram session\n'
'!code 12345 - Entering one-time code during auth\n'
'!password abc123 - Entering password during two-factor auth\n'
'!configure - Configure transport settings\n'
#'!list_sessions - List all created sessions at Telegram servers\n'
#'!delete_session 123 - Delete session\n'
'!logout - Deletes current Telegram session at gate\n'
'!reload_dialogs - Reloads dialogs list from Telegram\n\n'
'!add - Find and add Telegram contact. Any formats accepted (nickname or t.me link)\n\n'
'!add - Find and add Telegram contact. Any formats accepted (nickname or t.me link)\n\n'
'!join - Join Telegram conference via invite link \n\n'
'!join - Join Telegram conference via invite link \n\n'
'!import phone firstname lastname - Add Telegram contact with phone number \n\n'
'!import phone firstname lastname - Add Telegram contact with phone number \n\n'
'!group GroupName @InviteContact - Create a normal group\n'
'!supergroup SupergroupName - Create a supergroup\n'
'!channel ChannelName - Create a channel\n\n'
'!group GroupName @InviteContact - Create a normal group\n'
'!supergroup SupergroupName - Create a supergroup\n'
'!channel ChannelName - Create a channel\n\n'
'!name first last - Change your name in Telegram\n'
'!about text - Change about text in Telegram\n'
'!username - Changes your @username in Telegram\n\n'
'!name first last - Change your name in Telegram\n'
'!about text - Change about text in Telegram\n'
'!username - Changes your @username in Telegram\n\n'
'!roster - Lists yout TG roster\n')
'!roster - Lists yout TG roster\n')
class ChatCommandHandler(CommandHandler):
_helptext = "Available Userchat commands:"
@@ -325,43 +322,43 @@ class ChatCommandHandler(CommandHandler):
self._handler = self._replace
self.tg_id = int(msg['to'].node[1:])
def block(hndl, self):
def block(self, gate):
"""Block this user"""
nickname = display_tg_name(self.tg_dialogs[hndl.jid]['users'][hndl.tg_id])
self.tg_connections[hndl.jid].invoke(BlockRequest( InputPeerUser(hndl.tg_id, self.tg_dialogs[jid]['users'][hndl.tg_id].access_hash) ) )
self.gate_reply_message(iq, 'User %s blacklisted!' % nickname)
nickname = display_tg_name(gate.tg_dialogs[self.jid]['users'][self.tg_id])
gate.tg_connections[self.jid].invoke(BlockRequest(InputPeerUser(self.tg_id, gate.tg_dialogs[self.jid]['users'][self.tg_id].access_hash)))
gate.gate_reply_message(iq, 'User %s blacklisted!' % nickname)
def unblock(hndl, self):
def unblock(self, gate):
"""Unblock this user"""
nickname = display_tg_name(self.tg_dialogs[hndl.jid]['users'][hndl.tg_id])
self.tg_connections[hndl.jid].invoke(UnblockRequest( InputPeerUser(hndl.tg_id, self.tg_dialogs[jid]['users'][hndl.tg_id].access_hash) ) )
self.gate_reply_message(iq, 'User %s unblacklisted!' % nickname)
def remove(hndl, self):
nickname = display_tg_name(gate.tg_dialogs[self.jid]['users'][self.tg_id])
gate.tg_connections[self.jid].invoke(UnblockRequest(InputPeerUser(self.tg_id, gate.tg_dialogs[self.jid]['users'][self.tg_id].access_hash)))
gate.gate_reply_message(iq, 'User %s unblacklisted!' % nickname)
def remove(self, gate):
"""Remove User from Telegram contact list"""
peer = InputPeerUser(hndl.tg_id, self.tg_dialogs[hndl.jid]['users'][hndl.tg_id].access_hash)
c_jid = get_contact_jid(self.tg_dialogs[hndl.jid]['users'][hndl.tg_id], self.boundjid.bare)
peer = InputPeerUser(self.tg_id, gate.tg_dialogs[self.jid]['users'][self.tg_id].access_hash)
c_jid = get_contact_jid(gate.tg_dialogs[self.jid]['users'][self.tg_id], gate.boundjid.bare)
self.tg_connections[hndl.jid].invoke( DeleteContactRequest(peer) )
self.tg_connections[hndl.jid].invoke( DeleteHistoryRequest( peer, max_id = 0, just_clear = None ) )
gate.tg_connections[self.jid].invoke(DeleteContactRequest(peer))
gate.tg_connections[self.jid].invoke(DeleteHistoryRequest(peer, max_id = 0, just_clear = None))
self.send_presence(pto = hndl.jid, pfrom = c_jid, ptype = 'unavailable')
self.send_presence(pto = hndl.jid, pfrom = c_jid, ptype = 'unsubscribed')
self.send_presence(pto = hndl.jid, pfrom = c_jid, ptype = 'unsubscribe')
gate.send_presence(pto = self.jid, pfrom = c_jid, ptype ='unavailable')
gate.send_presence(pto = self.jid, pfrom = c_jid, ptype ='unsubscribed')
gate.send_presence(pto = self.jid, pfrom = c_jid, ptype ='unsubscribe')
def _replace(hndl, self):
peer = InputPeerUser(hdnl.tg_id, self.tg_dialogs[hndl.jid]['users'][hndl.tg_id].access_hash)
def _replace(self, gate):
peer = InputPeerUser(hdnl.tg_id, gate.tg_dialogs[self.jid]['users'][self.tg_id].access_hash)
msg_id, edited = self.edit_message(hdnl.jid, hdnl.tg_id, hndl.msg['body'])
msg_id, edited = gate.edit_message(hdnl.jid, hdnl.tg_id, self.msg['body'])
if not edited: return
# and send it
if edited != '' and edited != ' ':
self.tg_dialogs[hndl.jid]['messages'][hndl.tg_id]["body"] = edited
self.tg_connections[hndl.jid].invoke( EditMessageRequest(peer, msg_id, message = edited) )
gate.tg_dialogs[self.jid]['messages'][self.tg_id]["body"] = edited
gate.tg_connections[self.jid].invoke(EditMessageRequest(peer, msg_id, message = edited))
else:
del(self.tg_dialogs[hndl.jid]['messages'][hndl.tg_id])
self.tg_connections[hndl.jid].invoke( DeleteMessagesRequest([msg_id], revoke = True) )
del(gate.tg_dialogs[self.jid]['messages'][self.tg_id])
gate.tg_connections[self.jid].invoke(DeleteMessagesRequest([msg_id], revoke = True))
class GroupchatCommandHandler(CommandHandler):
_helptext = "Available Groupchat commands:"
@@ -370,38 +367,43 @@ class GroupchatCommandHandler(CommandHandler):
super(GroupchatCommandHandler, self).__init__(msg)
if self._command.startswith("s/"):
self._handler = self._replace
self.tg_id = int(self.msg['to'].node[1:])
def leave(hndl, self):
def leave(self, gate):
"""Leave group or channel"""
tg_id = int(hndl.msg['to'].node[1:])
if tg_id in self.tg_dialogs[hndl.jid]['supergroups']:
peer = InputPeerChannel(tg_id, self.tg_dialogs[hndl.jid]['supergroups'][tg_id].access_hash)
self.tg_connections[hndl.jid].invoke(LeaveChannelRequest(peer))
self.tg_connections[hndl.jid].invoke(DeleteHistoryRequest(peer, max_id = 0, just_clear = None))
c_jid = get_contact_jid(self.tg_dialogs[hndl.jid]['supergroups'][tg_id], self.boundjid.bare)
self.send_presence(pto =hndl.jid, pfrom = c_jid, ptype ='unavailable')
self.send_presence(pto =hndl.jid, pfrom = c_jid, ptype ='unsubscribed')
self.send_presence(pto =hndl.jid, pfrom = c_jid, ptype ='unsubscribe')
if tg_id in self.tg_dialogs[hndl.jid]['groups']:
self.tg_connections[hndl.jid].invoke(DeleteChatUserRequest(tg_id, self.tg_connections[hndl.jid].me))
self.tg_connections[hndl.jid].invoke(DeleteHistoryRequest(InputPeerChat(tg_id), max_id = 0, just_clear = None))
c_jid = get_contact_jid(self.tg_dialogs[hndl.jid]['groups'][tg_id], self.boundjid.bare)
self.send_presence(pto =hndl.jid, pfrom = c_jid, ptype ='unavailable')
self.send_presence(pto =hndl.jid, pfrom = c_jid, ptype ='unsubscribed')
self.send_presence(pto =hndl.jid, pfrom = c_jid, ptype ='unsubscribe')
if self.tg_id in gate.tg_dialogs[self.jid]['supergroups']:
peer = InputPeerChannel(self.tg_id, gate.tg_dialogs[self.jid]['supergroups'][self.tg_id].access_hash)
gate.tg_connections[self.jid].invoke(LeaveChannelRequest(peer))
gate.tg_connections[self.jid].invoke(DeleteHistoryRequest(peer, max_id = 0, just_clear = None))
c_jid = get_contact_jid(gate.tg_dialogs[self.jid]['supergroups'][self.tg_id], gate.boundjid.bare)
gate.send_presence(pto =self.jid, pfrom = c_jid, ptype ='unavailable')
gate.send_presence(pto =self.jid, pfrom = c_jid, ptype ='unsubscribed')
gate.send_presence(pto =self.jid, pfrom = c_jid, ptype ='unsubscribe')
if self.tg_id in gate.tg_dialogs[self.jid]['groups']:
gate.tg_connections[self.jid].invoke(DeleteChatUserRequest(self.tg_id, gate.tg_connections[self.jid].me))
gate.tg_connections[self.jid].invoke(DeleteHistoryRequest(InputPeerChat(self.tg_id), max_id = 0, just_clear = None))
c_jid = get_contact_jid(gate.tg_dialogs[self.jid]['groups'][self.tg_id], gate.boundjid.bare)
gate.send_presence(pto =self.jid, pfrom = c_jid, ptype ='unavailable')
gate.send_presence(pto =self.jid, pfrom = c_jid, ptype ='unsubscribed')
gate.send_presence(pto =self.jid, pfrom = c_jid, ptype ='unsubscribe')
def invite(hndl, self):
def invite(self, gate):
"""Invite user to group"""
tg_id = int(hndl.msg['to'].node[1:])
if tg_id in self.tg_dialogs[hndl.jid]['supergroups']:
invited_user = self.tg_connections[[hndl.jid]].get_entity(parsed[1])
if self.tg_id in gate.tg_dialogs[self.jid]['supergroups']:
invited_user = gate.tg_connections[[self.jid]].get_entity(parsed[1])
if type(invited_user) == User:
self.tg_connections[[hndl.jid]].invoke(EditBannedRequest(InputPeerChannel(tg_id, self.tg_dialogs[[hndl.jid]]['supergroups'][tg_id].access_hash), invited_user, ChannelBannedRights(until_date=None, view_messages=False)))
self.tg_connections[[hndl.jid]].invoke(InviteToChannelRequest(InputPeerChannel(tg_id, self.tg_dialogs[[hndl.jid]]['supergroups'][tg_id].access_hash), [invited_user]))
if tg_id in self.tg_dialogs[[hndl.jid]]['groups']:
invited_user = self.tg_connections[[hndl.jid]].get_entity(parsed[1])
gate.tg_connections[[self.jid]].invoke(EditBannedRequest(InputPeerChannel(self.tg_id, gate.tg_dialogs[[self.jid]]['supergroups'][
self.tg_id].access_hash), invited_user, ChannelBannedRights(until_date=None, view_messages=False)))
gate.tg_connections[[self.jid]].invoke(InviteToChannelRequest(InputPeerChannel(self.tg_id, gate.tg_dialogs[[self.jid]]['supergroups'][
self.tg_id].access_hash), [invited_user]))
if self.tg_id in gate.tg_dialogs[[self.jid]]['groups']:
invited_user = gate.tg_connections[[self.jid]].get_entity(parsed[1])
if type(invited_user) == User:
self.tg_connections[[hndl.jid]].invoke(AddChatUserRequest(tg_id, invited_user, 0))
gate.tg_connections[[self.jid]].invoke(AddChatUserRequest(self.tg_id, invited_user, 0))
def kick(hndl, self):
"""Kick user"""