Beispiel #1
0
 def call_howdoi(self, query):
     """ Crete parser. Parser musi ustawiac sparsowane argumenty jako atrybuty. Dlatego pojawia sie vars.
         vars zwraca slownik gdzie kluczem jest atrybutu. Vars
     """
     parser = howdoi.get_parser()
     args = vars(parser.parse_args(query.split(' ')))
     return howdoi.howdoi(args)
Beispiel #2
0
async def howdoi_cmd(event):
    if not event.args:
        await event.edit(f"`Syntax: {ldr.settings.get_config('cmd_prefix') or '.'}hdi <question>`")
        return

    response = howdoi.howdoi(vars(howdoi.get_parser().parse_args(event.args.split(' '))))
    response = re.sub(r'\n\n+', '\n\n', response).strip()

    await event.edit(f"**Query:**\n{event.args}\n**Answer:**\n{response}")
Beispiel #3
0
    def search(self, word):

        parser = howdoi.get_parser()
        args = vars(parser.parse_args(word.split(' ')))

        output = howdoi.howdoi(args)

        return output if output.strip(
        ) != "" else "Did not find anything containing that"
Beispiel #4
0
    def howdoi(self):
        if not self.values: return 'Howdoi what now?'

        try:
            parser = hownow.get_parser()
            args = vars(parser.parse_args(self.values))
            return hownow.howdoi(args)
        except:
            return 'Dunno bro'
Beispiel #5
0
    def howdoi(self):
        if not self.values: return 'Howdoi what now?'

        try:
            parser = hownow.get_parser()
            args = vars(parser.parse_args(self.values))
            return hownow.howdoi(args)
        except:
            return 'Dunno bro'
Beispiel #6
0
    async def howdoi(
            self, ctx,
            question):  #sanitize the **** out of the user input (question)

        # Get howdoi answer
        query = question
        parser = howdoi.get_parser()
        args = vars(parser.parse_args(query.split(' ')))
        output = howdoi.howdoi(args)
        await ctx.send("```" + "\n" + output + "\n" + "```")

        # Get stackoverflow Link to that answer
        linkCommand = '-l'
        query = linkCommand + ' ' + question
        parser = howdoi.get_parser()
        args = vars(parser.parse_args(query.split(' ')))
        output = howdoi.howdoi(args)
        await ctx.send("\n" + output + "\n")
        return
Beispiel #7
0
async def on_howdoi(ctx, *, query):
    if ctx.channel.id in allowed_channels:
        parser = howdoi.get_parser()
        args = vars(parser.parse_args(query.split(" ")))
        output = howdoi.howdoi(args)
        if len(output) > 2000:
            output = output[0:1997] + "..."
        embed = Embed(title="Query: " + query, description=output, color=0xff0000)
        await ctx.reply(content="", embed=embed, mention_author=True)
    else:
        await ctx.reply(content=f"**Please use this in a development channel only!**", mention_author=True)
Beispiel #8
0
def code():
    answer.delete(1.0, END)
    try:
        entry_value = search_entry.get()
        parser = howdoi.get_parser()
        args = vars(parser.parse_args(entry_value.split(' ')))

        output = howdoi.howdoi(args)
        answer.insert(INSERT, output)
    except:
        answer.insert(INSERT, "Internet Connection Error!!!")
Beispiel #9
0
    async def howdoi(self, ctx, *, query=None):
        if query is not None:
            parser = howdoi.get_parser()
            arguments = vars(parser.parse_args(query.split(' ')))

            embed = discord.Embed(title=f'how to {query}',
                                  description=howdoi.howdoi(arguments))
            async with ctx.typing():
                await asyncio.sleep(2)
            await ctx.channel.send(embed=embed)
        else:
            await ctx.send(f'What did you wanted to ask? {ctx.author.mention}')
Beispiel #10
0
def howdoi_view(request):
    if request.method == 'POST':
        query = request.POST['query']
        parser = howdoi.get_parser()
        args = vars(parser.parse_args(query.split(' ')))

        print(args)
        print(type(args))
        output = howdoi.howdoi(args)

        context = {"output": output}
        return render(request, 'howdoi_view.html', context)
    return render(request, 'howdoi_view.html')
Beispiel #11
0
def howdoiWrapper(strArg):
    """howdoi is meant to be called from the command line - this wrapper lets it be called programatically
    
    Arguments:
        strArg {str} -- search term
    """

    if strArg.lower() == 'use arepl' or strArg.lower() == 'arepl':
        returnVal = 'using AREPL is simple - just start coding and arepl will show you the final state of your variables. For more help see https://github.com/Almenon/AREPL-vscode/wiki'
    else:
        try:
            parser = howdoi.get_parser()
        except NameError as e:
            # alter error to be more readable by user
            e.args = (['howdoi is not installed'])
            raise

        args = vars(parser.parse_args(strArg.split(' ')))
        returnVal = howdoi.howdoi(args)

    print(returnVal)
    return returnVal  # not actually necessary but nice for unit testing
Beispiel #12
0
def _call_howdoi(query):
    parser = hdi.get_parser()
    args = vars(parser.parse_args(query.split(' ')))
    return hdi.howdoi(args)
Beispiel #13
0
 def call_howdoi(self, query):
     parser = howdoi.get_parser()
     args = vars(parser.parse_args(query.split(' ')))
     return howdoi.howdoi(args)
Beispiel #14
0
#1. Pyperclip
import pyperclip
pyperclip.copy('Heyyy this is being copied to clipboard')
print(pyperclip.paste())

#2. Emoji
from emoji import emojize
print(emojize(':thumbs_up:'),emojize(':snake:'))

#3. Howdoi
from howdoi import howdoi
query = "open a file in python"
parser = howdoi.get_parser()
args = vars(parser.parse_args(query.split(' ')))
output = howdoi.howdoi(args)
print(output)

#4. Antigravity
import antigravity

#5. Wikipedia
import wikipedia
page = wikipedia.page("Python")
print(page.summary)

#6. Dissemble Python
import dis
def myfun(num):
    return('Number to string : ',str(num))

dis.dis(myfun)
Beispiel #15
0
def solve_query(query):
    search_query = query
    parser = howdoi.get_parser()
    args = vars(parser.parse_args(query.split(' ')))
    output = howdoi.howdoi(args)
    return output
def main():

    query = takecommand()

    try:

        if 'wikipedia' in query:
            speak("Searching in wikipedia")
            query = query.replace("in wikipedia", "")
            results = wikipedia.summary(query, sentences=2)
            speak(results)
            return 0
        elif 'browser' in query:
            url = re.search("([a-zA-Z0-9]*\.[a-zA-Z]*)", query)
            url = url.group()  #f"https://{url.group()}"
            chromepath = "C:/Users/kbalaraman/AppData/Local/Google/Chrome/Application/chrome.exe %s"
            webbrowser.get(chromepath).open(url)
            return 0
        elif 'time' in query:
            strTime = datetime.datetime.now().strftime("%H:%M:%S")
            speak(f"{master} the time is {strTime}")
            return 0
        elif "open code" in query:
            codepath = "C:/Users/kbalaraman/AppData/Local/Programs/Microsoft VS Code/code.exe"
            os.startfile(codepath)
            return 0
        elif "check" in query:
            query = query.replace("check", "")
            parser = howdoi.get_parser()
            args = vars(parser.parse_args(query.split(' ')))
            output = howdoi.howdoi(args)
            print("i hope this helps you \n {} ".format(output))
            return 0
        elif "song" in query:
            try:
                x = Youtube_mp3()
                speak("Please say the song name")
                query = song_cmd()
                search = query
                max_search = 5
                x.dict = {}
                x.dict_names = {}
                x.url_search(search, max_search)
                x.get_search_items(max_search)
                song_num = number_command()
                song_num = re.search("\d", song_num)
                song_num = int(song_num.group())
                with futures.ThreadPoolExecutor(3) as executor:
                    executor.submit(x.play_media(song_num))

            except:
                print("error")
                return 0
            return 0
        elif "Good" or "fine" in query:
            speak("Sounds good")
            return 0
        elif "hold" or "wait" in query:
            if "minutes" or "min" in query:
                w = re.search("\d", query)
                waits = int(w.group())
                waits = waits * 60
                time.sleep(waits)
            elif "secs" or "seconds" in query:
                w = re.search("\d", query)
                waits = int(w.group())
                time.sleep(waits)
            return 0
        elif "wasted" in query:
            return 1
    except:
        speak("sorry")
        return 1
Beispiel #17
0
 def call_howdoi(self, query):
     parser = howdoi.get_parser()
     args = vars(parser.parse_args(query.split(' ')))
     return howdoi.howdoi(args)
Beispiel #18
0
def get_output(query):
    parser = howdoi.get_parser()
    args = vars(parser.parse_args(query.split(' ')))
    output = howdoi.howdoi(args)
    return output