# Path: mods/cog.py
# class Cog(metaclass=CogMeta):
# 	def __init__(self, bot:NotSoBot):
# 		self._bot = bot
# 
# 	@property
# 	def bot(self):
# 		return self._bot
# 
# 	@classmethod
# 	def setup(cls, bot:NotSoBot):
# 		bot.add_cog(cls(bot))
# 
# Path: utils/checks.py
# class No_Owner(commands.CommandError): pass
# class No_Perms(commands.CommandError): pass
# class No_Role(commands.CommandError): pass
# class No_Admin(commands.CommandError): pass
# class No_Mod(commands.CommandError): pass
# class No_Sup(commands.CommandError): pass
# class No_ServerandPerm(commands.CommandError): pass
# class Nsfw(commands.CommandError): pass
# def is_owner_check(message):
# def is_owner():
# def check_permissions(ctx, perms):
# def role_or_perm(t, ctx, check, **perms):
# def mod_or_perm(**perms):
# 	def predicate(ctx):
# def admin_or_perm(**perms):
# 	def predicate(ctx):
# def is_in_servers(*server_ids):
# 	def predicate(ctx):
# def server_and_perm(ctx, *server_ids, **perms):
# def sup(ctx):
# def nsfw():
# 	def predicate(ctx):


import discord
import asyncio
import random
import re
import sys, linecache
from discord.ext import commands
from mods.cog import Cog
from utils import checks
      path = self.files_path('markov/{0}/'.format(message.server.id))
      await self.add_markov(path, message.content)
    if message.author.id in self.users.keys() and self.users[message.author.id] == message.server.id:
      path = self.files_path('markov/{0}_{1}/'.format(message.author.id, message.server.id))
      await self.add_markov(path, message.content)

  @commands.group(pass_context=True, aliases=['mark', 'm'], no_pm=True, invoke_without_command=True)
  async def markov(self, ctx, *, text:str=None):
    for m in ctx.message.mentions:
      user = m
      text = text.replace(user.mention, '')
      break
    else:
      user = False
    if user:
      if user.id not in self.users.keys():
        return
      elif self.users[user.id] != ctx.message.server.id:
        return
    if ctx.message.server.id not in self.servers:
      return
    path = self.files_path('markov/{0}/'.format('{0}_{1}'.format(ctx.message.author.id, ctx.message.server.id) if user else ctx.message.server.id))
    code = "var markov_ultra = require('markov-ultra');var markov = new markov_ultra['default']('{0}', 6000000000);console.log(markov.generate(2, 2000{1}))".format(path, ', `{0}`'.format(text) if text else '')
    result = await self.bot.run_process(['node', '-e', code], True)
    if result and result != '' and result != '\n':
      await self.bot.say(str(result).replace('http//', 'http://').replace('https//', 'https://').replace('\\\\', '\\'))
    else:
      await self.bot.say(':warning: **Markov Failed**.')

  @markov.command(name='generate', pass_context=True)

# Path: mods/cog.py
# class Cog(metaclass=CogMeta):
# 	def __init__(self, bot:NotSoBot):
# 		self._bot = bot
# 
# 	@property
# 	def bot(self):
# 		return self._bot
# 
# 	@classmethod
# 	def setup(cls, bot:NotSoBot):
# 		bot.add_cog(cls(bot))
# 
# Path: utils/checks.py
# class No_Owner(commands.CommandError): pass
# class No_Perms(commands.CommandError): pass
# class No_Role(commands.CommandError): pass
# class No_Admin(commands.CommandError): pass
# class No_Mod(commands.CommandError): pass
# class No_Sup(commands.CommandError): pass
# class No_ServerandPerm(commands.CommandError): pass
# class Nsfw(commands.CommandError): pass
# def is_owner_check(message):
# def is_owner():
# def check_permissions(ctx, perms):
# def role_or_perm(t, ctx, check, **perms):
# def mod_or_perm(**perms):
# 	def predicate(ctx):
# def admin_or_perm(**perms):
# 	def predicate(ctx):
# def is_in_servers(*server_ids):
# 	def predicate(ctx):
# def server_and_perm(ctx, *server_ids, **perms):
# def sup(ctx):
# def nsfw():
# 	def predicate(ctx):


# Path: mods/Markov.py
import discord
import asyncio
import random
import re
import sys, linecache
from discord.ext import commands
from mods.cog import Cog
from utils import checks

      path = self.files_path('markov/{0}/'.format(message.server.id))
      await self.add_markov(path, message.content)
    if message.author.id in self.users.keys() and self.users[message.author.id] == message.server.id:
      path = self.files_path('markov/{0}_{1}/'.format(message.author.id, message.server.id))
      await self.add_markov(path, message.content)

  @commands.group(pass_context=True, aliases=['mark', 'm'], no_pm=True, invoke_without_command=True)
  async def markov(self, ctx, *, text:str=None):
    for m in ctx.message.mentions:
      user = m
      text = text.replace(user.mention, '')
      break
    else:
      user = False
    if user:
      if user.id not in self.users.keys():
        return
      elif self.users[user.id] != ctx.message.server.id:
        return
    if ctx.message.server.id not in self.servers:
      return
    path = self.files_path('markov/{0}/'.format('{0}_{1}'.format(ctx.message.author.id, ctx.message.server.id) if user else ctx.message.server.id))
    code = "var markov_ultra = require('markov-ultra');var markov = new markov_ultra['default']('{0}', 6000000000);console.log(markov.generate(2, 2000{1}))".format(path, ', `{0}`'.format(text) if text else '')
    result = await self.bot.run_process(['node', '-e', code], True)
    if result and result != '' and result != '\n':
      await self.bot.say(str(result).replace('http//', 'http://').replace('https//', 'https://').replace('\\\\', '\\'))
    else:
      await self.bot.say(':warning: **Markov Failed**.')

  @markov.command(name='generate', pass_context=True)

  @checks.is_owner()