text: #   Copyright 2019 - 2020 DarkPrinc3
  
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  
  #       http://www.apache.org/licenses/LICENSE-2.0
  
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import asyncio
  
  from coffeehouse.api import API
  from coffeehouse.lydia import LydiaAI
  from telethon import events
  
  # Non-SQL Mode
  ACC_LYDIA = {}
  
  if Var.LYDIA_API_KEY:
      api_key = Var.LYDIA_API_KEY
      api_client = API(api_key)
      lydia = LydiaAI(api_client)
  
  
  @command(pattern="^.repcf", outgoing=True)
  async def repcf(event):
      if event.fwd_from:
          return
      await event.edit("Processing...")
      try:
          session = lydia.create_session()
          session.id
          reply = await event.get_reply_message()
          msg = reply.text
          text_rep = session.think_thought(msg)
          await event.edit("💫 {0}".format(text_rep))
      except Exception as e:
          await event.edit(str(e))
  
  
  @command(pattern="^.addcf", outgoing=True)
  async def addcf(event):
      if event.fwd_from:
          return
      await event.edit("Running on Non-SQL mode for now...")
      await asyncio.sleep(3)
      await event.edit("Processing...")
      reply_msg = await event.get_reply_message()
      if reply_msg:
          session = lydia.create_session()
          session.id
          if reply_msg.from_id is None:
              return await event.edit("Invalid user type.")
          ACC_LYDIA.update({(event.chat_id & reply_msg.from_id): session})
          await event.edit(
              "Lydia successfully (re)enabled for user: {} in chat: {}".format(
                  str(reply_msg.from_id), str(event.chat_id)
              )
          )
      else:
          await event.edit("Reply to a user to activate Lydia AI on them")
  
  
  @command(pattern="^.remcf", outgoing=True)
  async def remcf(event):
      if event.fwd_from:
          return
      await event.edit("Running on Non-SQL mode for now...")
      await asyncio.sleep(3)
      await event.edit("Processing...")
      reply_msg = await event.get_reply_message()
      try:
          del ACC_LYDIA[event.chat_id & reply_msg.from_id]
          await event.edit(
              "Lydia successfully disabled for user: {} in chat: {}".format(
                  str(reply_msg.from_id), str(event.chat_id)
              )
          )
      except Exception:
          await event.edit("This person does not have Lydia activated on him/her.")
  
  
  @bot.on(events.NewMessage(incoming=True))
  async def user(event):
      event.text
      try:
          session = ACC_LYDIA[event.chat_id & event.from_id]
          msg = event.text
          async with event.client.action(event.chat_id, "typing"):
              text_rep = session.think_thought(msg)
              wait_time = 0
              for i in range(len(text_rep)):
                  wait_time = wait_time + 0.1
              await asyncio.sleep(wait_time)
              await event.reply(text_rep)
      except (KeyError, TypeError):
          return
  