Exemple #1
0
 def __init__(self):
     self.discord = discord.Client()
     self.config = None
     self.check_config()
     self.forumdb = Forum(self)
     self.wikidb = Wiki(self)
     self.random = Random(self)
     self.dcmanager = DCManager(self)
     self.ircmanager = IRCManager(self)
     # Discord events
     self.discord.event(self.on_ready)
     self.discord.event(self.on_message)
     self.discord.event(self.on_member_join)
Exemple #2
0
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('!wiki'):
        content = message.content[5:]
        content = re.sub('\s', '_', content)
        w = Wiki(content)
        response = w.getSum()
        await message.channel.send(response)
        if 'more at' not in response:
            await message.channel.send('Wanna see more information?(y/n)')
            msg = await client.wait_for('message')
            if msg.content == 'y':
                await message.channel.send('See more at ' + w.getLink())
Exemple #3
0
def main():
    screen.shot()
    question_options = localocr.getText()
    wiki_search = Wiki(question_options['question'],
                       question_options['options'])
    wiki_result = wiki_search.getResults()
    google_search = GoogleSearch()
    google_search_result = google_search.getResult(
        question_options['question'], question_options['options'])
    wiki_index = wiki_result.index(max(wiki_result))
    google_index = google_search_result.index(max(google_search_result))

    print("WIKI FOUND: " + str(question_options['options'][wiki_index]) +
          "\t Frequency of Option: " + str(wiki_result[wiki_index]))
    print("GOOGLE FOUND: " + str(question_options['options'][google_index]) +
          "\t Number of Results: " + str(google_search_result[google_index]))
    def ans(self, text: str):
        text = text.lower()
        if self.last_msg == "вики":
            w = Wiki()
            self.last_msg = ""
            return w.get_wiki(text)

        for i in self.hello:
            if text == i:
                self.last_msg = ""
                return "Привет, я БОТ_ИМЯ!\nЯ умею присылать статью из Википедии(напиши: вики или wiki)"

        for i in self.whatsup:
            if text == i:
                self.last_msg = ""
                return "У меня всгда все круто, я же рообот\nА у тебя как дела?"

        for i in self.wiki:
            if text == i:
                self.last_msg = "вики"
                return "Что ты хочешь узнать?"

        return "Я тебя не понял"
Exemple #5
0
 def __init__(self):
     self.items = []
     self.wiki = Wiki()
     self.youtube = Youtube()
     self.path = os.getcwd()
     self.s = schedule.every().saturday.do(self.job)
Exemple #6
0
import os
import re
import codecs
import requests
import concurrent.futures
import time
import utils.global_vars

from enchant.checker import SpellChecker
from enchant.tokenize import URLFilter, EmailFilter, WikiWordFilter, MentionFilter

from wiki import Wiki

IBEX_ISSUES = "IBEX/issues/"

DEV_MANUAL = Wiki("ibex_developers_manual")
IBEX_MANUAL = Wiki("IBEX")
USER_MANUAL = Wiki("ibex_user_manual")
TEST_WIKI = Wiki("ibex_wiki_checker")
WIKI_INCLUDELIST = [USER_MANUAL, IBEX_MANUAL, DEV_MANUAL, TEST_WIKI]


def strip_between_tags(expression, text):
    if text is None:
        return text
    matches = list(re.finditer(expression, text))
    if len(matches) == 0:
        new_text = text
    elif len(matches) % 2 != 0:
        print("Uneven number of {} detected. Doing nothing to be safe".format(
            expression))
Exemple #7
0
def wiki_action():
    from wiki import Wiki
    wiki = Wiki()
    return wiki.get_wiki_info()
Exemple #8
0
 def __init__(self):
     self.items=[]
     self.wiki = Wiki()
     self.path = os.getcwd()
Exemple #9
0
app.config['CONTENT_DIR'] = 'content'
# app.config['DEBUG'] = options.debug
# app.config['CONTENT_DIR'] = options.directory
app.config['TITLE'] = 'wiki'
# app.config['AUTHENTICATION_METHOD'] = options.authentication_method
app.config['AUTHENTICATION_METHOD'] = 'cleartext'
app.config['SEARCH_IGNORE_CASE'] = True

try:
    app.config.from_pyfile(
        os.path.join(app.config.get('CONTENT_DIR'), 'config.py'))
except IOError:
    print("Startup Failure: You need to place a "
          "config.py in your content directory.")

wiki = Wiki(app.config.get('CONTENT_DIR'))
users = UserManager(app.config.get('CONTENT_DIR'))

users.add_user('admin',
               'dev',
               authentication_method=app.config.get('AUTHENTICATION_METHOD'))

loginmanager = LoginManager()
loginmanager.init_app(app)
loginmanager.login_view = 'user_login'
"""
    Forms
    ~~~~~
"""

Exemple #10
0
def wiki_action():
    wiki = Wiki()
    return wiki.get_wiki_info()
    args = load_args()
    setup_logging(args.verbose)
    logging.info("Creating projects.")
    config_path = args.config
    with open(config_path) as config_file:
        config = yaml.safe_load(config_file)
    logging.info("Loaded config from '{}'".format(config_path))
    with open(args.goal_file[0], newline="") as file_:
        goals_reader = csv.reader(file_, delimiter="\t")
        goals, goal_fulfillments = read_goals(goals_reader, config["goals"])
    if args.year:
        year = args.year
    else:
        year = datetime.date.today().year
    project_columns = config["project_columns"]
    wiki = Wiki(config["wiki"], project_columns, args.dry_run,
                args.overwrite_wiki, year)
    phab = Phab(config["phab"], args.dry_run)

    with open(args.project_file[0], newline="") as file_:
        projects_reader = csv.DictReader(file_, delimiter="\t")
        single_project_found = False
        for unsanitized_project_information in projects_reader:
            project_information = sanitize(unsanitized_project_information)
            if args.project:
                if args.project not in (
                        project_information[project_columns["swedish_name"]],
                        project_information[project_columns["english_name"]]):
                    continue
                else:
                    single_project_found = True
                    wiki.single_project_info(
Exemple #12
0
     except Exception as error:
         message(
             f'ошибка!\nкоманда "qr" завершилась с ошибкой\n{error}'
         )
 if (text and text.startswith("/github") and
     (event.from_user
      or str(peer_id - 2000000000) in settings and
      settings[str(peer_id - 2000000000)]["github"] == "True")):
     message(getGitHubAccInfo(text.split()[1]))
 if (text and text.startswith("/wiki") and
     (event.from_user
      or str(peer_id - 2000000000) in settings and
      settings[str(peer_id - 2000000000)]["wiki"] == "True")):
     if text.split()[-1].isdigit():
         message(
             Wiki(text[5:].replace(text.split()[-1], ""),
                  int(text.split()[-1])))
     else:
         message(Wiki(text[5:]))
 if (text and text.startswith("/курс") and
     (event.from_user
      or str(peer_id - 2000000000) in settings and
      settings[str(peer_id - 2000000000)]["rate"] == "True")):
     if len(text.split()) > 1 and text.split()[1] == "-евро":
         rate = exchangeRate("EUR").value
         message(f"Курс евро {rate} руб.")
     elif len(
             text.split()) > 1 and text.split()[1] == "-доллар":
         rate = exchangeRate("USD").value
         message(f"Курс доллара {rate} руб.")
     else:
         rateUSD = exchangeRate("USD").value
Exemple #13
0
                                )
                        if (command.lower().startswith("github") and
                            (event.from_user
                             or str(peer_id - 2000000000) in settings
                             and settings[str(peer_id - 2000000000)]["github"]
                             == "True")):
                            message(getGitHubAccInfo(command.split()[1]))

                        if (command.lower().startswith("wiki") and
                            (event.from_user
                             or str(peer_id - 2000000000) in settings
                             and settings[str(peer_id - 2000000000)]["wiki"]
                             == "True")):
                            if command[-1].isdigit():
                                message(
                                    Wiki(" ".join(command.split()[1:-1]),
                                         int(command[-1])))
                            else:
                                message(Wiki(" ".join(command.split()[1:])))
                        if (command.lower().startswith("курс") and
                            (event.from_user
                             or str(peer_id - 2000000000) in settings
                             and settings[str(peer_id - 2000000000)]["rate"]
                             == "True")):
                            if len(command.split()) > 1 and command.split(
                            )[1] == "-евро":
                                rate = exchangeRate("EUR").value
                                message(f"Курс евро {rate} руб.")
                            elif len(command.split()) > 1 and command.split(
                            )[1] == "-доллар":
                                rate = exchangeRate("USD").value
                                message(f"Курс доллара {rate} руб.")