<commit_before>#    Copyright 2017 Starbot Discord Project
#
#    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 api.wikia
#starwiki = api.wikia.Wikia('starvstheforcesofevil')
#results = starwiki.search('Star Butterfly')
#print(results)
#print(results[0]['id'])
#print(starwiki.getPage(results[0]['id'])[0]['title'])

from api import command, message, plugin
from api.wikia import Wikia
import discord

def onInit(plugin_in):
    tinyurl_command = command.command(plugin_in, 'starwiki', shortdesc='Search the Star VS. Wikia')
    return plugin.plugin(plugin_in, 'starwiki', [tinyurl_command])

async def onCommand(message_in):
    if message_in.body == '':
        return message.message(body='Usage:\nstarwiki [search term]')
    else:
        starwiki = Wikia('starvstheforcesofevil')
        results = starwiki.search(message_in.body)
        page = starwiki.getPage(results[0]['id'])
        section = page[0]

        if len(section['content']) < 1:
            return message.message(body="No result found for '{}'".format(message_in.body))

        embed = discord.Embed(color=discord.Color.green())
        embed.set_author(name="Visit the full page here",
                         url=results[0]['url'],
                         icon_url='http://slot1.images.wikia.nocookie.net/__cb1493894030/common/skins/common/images/wiki.png')
        embed.add_field(name=section['title'], value=section['content'][0]['text'])
        return message.message(embed=embed)<commit_msg>More Starwiki error messages<commit_after>#    Copyright 2017 Starbot Discord Project
#
#    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 api.wikia
#starwiki = api.wikia.Wikia('starvstheforcesofevil')
#results = starwiki.search('Star Butterfly')
#print(results)
#print(results[0]['id'])
#print(starwiki.getPage(results[0]['id'])[0]['title'])

from api import command, message, plugin
from api.wikia import Wikia
import discord

def onInit(plugin_in):
    tinyurl_command = command.command(plugin_in, 'starwiki', shortdesc='Search the Star VS. Wikia')
    return plugin.plugin(plugin_in, 'starwiki', [tinyurl_command])

async def onCommand(message_in):
    if message_in.body == '':
        return message.message(body='Usage:\nstarwiki [search term]')
    else:
        starwiki = Wikia('starvstheforcesofevil')
        try:
            results = starwiki.search(message_in.body.strip())
            page = starwiki.getPage(results[0]['id'])
            section = page[0]
        except:
            return message.message("No result found for '{}'".format(message_in.body))

        if len(section['content']) < 1:
            return message.message(body="No result found for '{}'".format(message_in.body))

        embed = discord.Embed(color=discord.Color.green())
        embed.set_author(name="Visit the full page here",
                         url=results[0]['url'],
                         icon_url='http://slot1.images.wikia.nocookie.net/__cb1493894030/common/skins/common/images/wiki.png')
        embed.add_field(name=section['title'], value=section['content'][0]['text'])
        return message.message(embed=embed)
{'fraction_non_alphanumeric': 0.12143028557715382, 'fraction_numerical': 0.012958963282937365, 'mean_word_length': 3.550218340611354, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5131547', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1198, 'n_words': 330}