0

I cant create pyrogram client to input an user accaunt data to create program which help to use accaunt automaticly in telegram. when I get text from lables api hash and api id and send it in gunc registr it gives an error when I try to create a client:

    Traceback (most recent call last):
  File "C:\Users\yablo\OneDrive\Рабочий стол\Lessons\calc\some.py", line 58, in inp
    registr(inputed_hash,inputed_api)
  File "C:\Users\yablo\OneDrive\Рабочий стол\Lessons\calc\some.py", line 51, in registr
    app = pyrogram.Client("my_app",inputed_api,inputed_hash)
  File "C:\Users\yablo\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\client.py",         line 267, in __init__
    self.dispatcher = Dispatcher(self)
  File "C:\Users\yablo\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\dispatcher.py", line 58, in __init__
    self.loop = asyncio.get_event_loop()
  File "C:\Users\yablo\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 642, in     get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Dummy-6'.

import dearpygui.dearpygui as dpg
import dearpygui.demo as demo
import pyrogram
from pyrogram  import Client,filters,idle

dpg.create_context()
dpg.create_viewport(title="program",width=500,height=500)


# font for ukrainian letters =========================================================================
big_let_start = 0x00C0  # Capital "A" in cyrillic alphabet
big_let_end = 0x00DF  # Capital "Я" in cyrillic alphabet
small_let_end = 0x00FF  # small "я" in cyrillic alphabet
remap_big_let = 0x0410  # Starting number for remapped cyrillic alphabet
alph_len = big_let_end - big_let_start + 1  # adds the shift from big letters to small
alph_shift = remap_big_let - big_let_start  # adds the shift from remapped to non-remapped


with dpg.font_registry():
    with dpg.font("notomono-regular.ttf", 20) as default_font:
        dpg.add_font_range_hint(dpg.mvFontRangeHint_Default)
        dpg.add_font_range_hint(dpg.mvFontRangeHint_Cyrillic)
        biglet = remap_big_let  # Starting number for remapped cyrillic alphabet
        dpg.add_char_remap( 178 , 1030 )# Remap the big cyrillic letter
        dpg.add_char_remap( 179 , 1110 )# Remap the small cyrillic letter
        dpg.add_char_remap( 175 , 1031 )# Remap the big cyrillic letter
        dpg.add_char_remap( 191 , 1111 )# Remap the small cyrillic letter
        for i1 in range(big_let_start, big_let_end + 1):  # Cycle through big letters in cyrillic alphabet
            dpg.add_char_remap(i1, biglet)  # Remap the big cyrillic letter
            dpg.add_char_remap(i1 + alph_len, biglet + alph_len)  # Remap the small cyrillic letter
            biglet += 1  # choose next letter
        
def to_cyr(instr):  # conversion function
    out = []  # start with empty output
        for i in range(0, len(instr)):  # cycle through letters in input string
            if ord(instr[i]) in range(big_let_start, small_let_end + 1):  # check if the letter is cyrillic
                out.append(chr(ord(instr[i]) + alph_shift))  # if it is change it and add to output list
            elif ord(instr[i]) == 178:
                out.append(chr(1030 ))
            elif ord(instr[i]) == 179:
                out.append(chr(1110 ))
            elif ord(instr[i]) == 175:
                out.append(chr(1031 ))
            elif ord(instr[i]) == 191:
                out.append(chr(1111  ))
            else:
                out.append(instr[i])  # if it isn`t don`t change anything and just add it to output list
        return(''.join(out))  # convert list to string

#=====================================================================================================

def registr(inputed_hash,inputed_api):
    app = pyrogram.Client("my_app",inputed_api,inputed_hash)
    #app = pyrogram.Client("my_app",api_hash=inputed_hash,api_id=inputed_api)

def inp(sender):
    if sender == "get_api_hash,id_label":
        inputed_hash = to_cyr(dpg.get_value("hash"))
        inputed_api  = to_cyr(dpg.get_value("api"))
        registr(inputed_hash,inputed_api)
    



with dpg.window(label="хз",height=300,width=500):

    with dpg.menu_bar():
        with dpg.menu(label="dv",tag="12"):
            dpg.add_menu_item(label="ji")
        
        with dpg.menu(label="dv2",tag="23"):
            dpg.add_text(label="mop")
        
        
    with dpg.tab_bar():
        with dpg.tab(label="accaunt"):
            api_hash_lable = dpg.add_input_text(label="api hash",tag="hash")
            api_id_lable= dpg.add_input_text(label="api id",tag="api")
            dpg.bind_item_font(api_hash_lable, default_font)
            dpg.bind_item_font(api_id_lable, default_font)
            dpg.add_button(label="log in",tag="get_api_hash,id_label",callback=inp)

        with dpg.tab(label="oob2"):
            dpg.add_button(label="h")
        





dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

I tried to create threads to do fix it, but it helps to go to line with creating a client, and nothing more. how to fix it

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.