Hello
I am trying to create a Telegram client with Telethon library
import configparser
import json
import appdaemon.plugins.hass.hassapi as hass
from telethon.sync import TelegramClient
import asyncio
import threading
class read_channel(hass.Hass):
def initialize(self):
self.listen_event(self.update, "FIRST_EVENT")
config = configparser.ConfigParser()
config.read("/config/cred.ini")
#self.log("a")
# Setting configuration values
api_id = config['Telegram']['api_id']
api_hash = config['Telegram']['api_hash']
api_hash = str(api_hash)
phone = config['Telegram']['phone']
username = config['Telegram']['username']
stringSession=config['Telegram']['stringSession']
client=TelegramClient(StringSession(stringSession), api_id, api_hash)
client.start()
def update(self, event, data, kvargs):
# Reading Configs
self.log("start")
But I am receiving the error:
RuntimeError: There is no current event loop in thread ‘ThreadPoolExecutor-0_0’.
I am not very familiar with threads and asyncio, so will be thankful for any assistance.