<commit_before>#!/usr/bin/env python3

# License MIT
# Copyright 2016-2022 <NAME>
# Version 4.0.0

import discord
from discord import app_commands
from discord.ext import commands
from ftsbot import data
from ftsbot.functions import autocomplete, wikifunctions
import typing

class wikicommands(commands.Cog):
	def __init__(self, bot):
		self.bot = bot

	@app_commands.command(description='See pending changes')
	@app_commands.describe(
		wiki='Which wiki do you want the pending changes of?',
	)
	@app_commands.autocomplete(wiki=autocomplete.wiki)
	async def pendingchanges(self, interaction: discord.Interaction, wiki: typing.Optional[str]):
		usewiki = None
		if wiki in data.wikis:
			usewiki = wiki
		elif isinstance(interaction.channel, discord.channel.TextChannel) and interaction.channel.name in data.wikis:
			usewiki = interaction.channel.name
		if usewiki is not None:
			result = wikifunctions.pendingchanges(usewiki)
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0x00ff00), description=result))
		else:
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0xff0000), description='There seems to be no wiki with such a url!'))

	@app_commands.command(description='See unreviewed pages')
	@app_commands.describe(
		wiki='Which wiki do you want the unreviewed pages of?',
	)
	@app_commands.autocomplete(wiki=autocomplete.wiki)
	async def unreviewedpages(self, interaction: discord.Interaction, wiki: typing.Optional[str]):
		print(type(interaction.channel))
		usewiki = None
		if wiki in data.wikis:
			usewiki = wiki
		elif isinstance(interaction.channel, discord.channel.TextChannel) and interaction.channel.name in data.wikis:
			usewiki = interaction.channel.name
		if usewiki is not None:
			result = wikifunctions.unreviewedpages(usewiki)
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0x00ff00), description=result))
		else:
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0xff0000), description='There seems to be no wiki with such a url!'))

	@app_commands.command(description='Search Liquipedia')
	@app_commands.describe(
		search='What do you want to search?',
		wiki='Which wiki do you want to search?',
	)
	@app_commands.autocomplete(wiki=autocomplete.wiki)
	async def search(self, interaction: discord.Interaction, search: str, wiki: typing.Optional[str]):
		usewiki = None
		if wiki in data.wikis:
			usewiki = wiki
		elif isinstance(interaction.channel, discord.channel.TextChannel) and interaction.channel.name in data.wikis:
			usewiki = interaction.channel.name
		if usewiki is not None:
			result = wikifunctions.search(usewiki, search)
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0x00ff00), description=result))
		else:
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0xff0000), description='There seems to be no wiki with such a url!'))
<commit_msg>add some sanity checking<commit_after>#!/usr/bin/env python3

# License MIT
# Copyright 2016-2022 <NAME>
# Version 4.0.0

import discord
from discord import app_commands
from discord.ext import commands
from ftsbot import data
from ftsbot.functions import autocomplete, wikifunctions
import typing

class wikicommands(commands.Cog):
	def __init__(self, bot):
		self.bot = bot

	@app_commands.command(description='See pending changes')
	@app_commands.describe(
		wiki='Which wiki do you want the pending changes of?',
	)
	@app_commands.autocomplete(wiki=autocomplete.wiki)
	async def pendingchanges(self, interaction: discord.Interaction, wiki: typing.Optional[str]):
		usewiki = None
		if wiki in data.wikis:
			usewiki = wiki
		elif isinstance(interaction.channel, discord.channel.TextChannel) and interaction.channel.name in data.wikis:
			usewiki = interaction.channel.name
		if usewiki is not None:
			result = wikifunctions.pendingchanges(usewiki)
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0x00ff00), description=result))
		else:
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0xff0000), description='There seems to be no wiki with such a url!'))

	@app_commands.command(description='See unreviewed pages')
	@app_commands.describe(
		wiki='Which wiki do you want the unreviewed pages of?',
	)
	@app_commands.autocomplete(wiki=autocomplete.wiki)
	async def unreviewedpages(self, interaction: discord.Interaction, wiki: typing.Optional[str]):
		usewiki = None
		if wiki in data.wikis:
			usewiki = wiki
		elif isinstance(interaction.channel, discord.channel.TextChannel) and interaction.channel.name in data.wikis:
			usewiki = interaction.channel.name
		if usewiki is not None:
			result = wikifunctions.unreviewedpages(usewiki)
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0x00ff00), description=result))
		else:
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0xff0000), description='There seems to be no wiki with such a url!'))

	@app_commands.command(description='Search Liquipedia')
	@app_commands.describe(
		search='What do you want to search?',
		wiki='Which wiki do you want to search?',
	)
	@app_commands.autocomplete(wiki=autocomplete.wiki)
	async def search(self, interaction: discord.Interaction, search: str, wiki: typing.Optional[str]):
		usewiki = None
		if wiki in data.wikis:
			usewiki = wiki
		elif isinstance(interaction.channel, discord.channel.TextChannel) and interaction.channel.name in data.wikis:
			usewiki = interaction.channel.name
		if usewiki is not None:
			result = wikifunctions.search(usewiki, search)
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0x00ff00), description=result))
		else:
			await interaction.response.send_message(embed=discord.Embed(colour=discord.Colour(0xff0000), description='There seems to be no wiki with such a url!'))

{'fraction_non_alphanumeric': 0.10040093551620448, 'fraction_numerical': 0.014032743067156699, 'mean_word_length': 5.834474885844749, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '895407', 'n_tokens_mistral': 2063, 'n_tokens_neox': 1840, 'n_words': 456}