def check_mentions(self):
     mention_str = "/u/" + self.username.lower()
     for comment in self.reddit.inbox.unread(limit=100):
         if comment.subreddit.display_name.lower() in self.enabled_subs:
             textbody = comment.body.lower()
             lines = textbody.split('\n')
             reply = ""
             for text in lines:
                 if mention_str in text:
                     text = text.replace(mention_str, '').strip()
                     if text.startswith("gif"):
                         text = text.replace("gif", '').strip()
                     rep = gifs.gif(text)
                     if "no matches" != rep:
                         split = rep.split(',')
                         link = split[-1]
                         text = ','.join(split[:-1])
                         reply = reply + "[%s](%s)" % (text, link)
                         reply = reply + "\n*****\n"
                     else:
                         reply = reply + "[Sorry, I couldn't find a matching gif.](https://gfycat.com/CandidHeartfeltDuck)\n*****\n"
             if len(reply) > 0:
                 reply = reply + "^^computer-dude ^^bot ^^made ^^by ^^[/u\/efitz11](/user/efitz11) ^^--- "
                 reply = reply + "[^^more ^^info ^^on ^^computer-dude](https://github.com/efitz11/natsgifbot/blob/master/computer-dude.md)"
                 comment.reply(reply)
         comment.mark_read()
Example #2
0
 def check_mentions(self):
     mention_str = "/u/"+self.username.lower()
     for comment in self.reddit.inbox.unread(limit=100):
         sub = comment.subreddit.display_name.lower()
         if sub in self.all_subs:
             textbody = comment.body.lower()
             lines = textbody.split('\n')
             reply = ""
             for text in lines:
                 if mention_str in text:
                     text = text.replace(mention_str,'').strip()
                     if text.startswith("gif"):
                         text = text.replace("gif",'').strip()
                     rep = gifs.gif(text)
                     if "no matches" != rep:
                         split = rep.split(',') 
                         link = split[-1]
                         text = ','.join(split[:-1])
                         reply = reply + "[%s](%s)" % (text,link)
                         reply = reply + "\n*****\n"
                     else:
                         reply = reply + "[Sorry, I couldn't find a matching gif.](https://gfycat.com/CandidHeartfeltDuck)\n*****\n"
             if len(reply) > 0:
                 if sub in self.banned_subs:
                     user = comment.author.name
                     reply = "Sorry, I am banned in the subreddit you asked me in (f**k the mods), but here is your gif:\n\n" + reply
                     print("attempting to send reply:")
                     self.reddit.redditor(user).message("your gif request", reply)
                 else:
                     reply = reply + "^^computer-dude ^^bot ^^made ^^by ^^[/u\/efitz11](/user/efitz11) ^^--- "
                     reply = reply + "[^^more ^^info ^^on ^^computer-dude](https://github.com/efitz11/natsgifbot/blob/master/computer-dude.md)"
                     comment.reply(reply)
         comment.mark_read()
Example #3
0
async def gif(ctx, *name: str):
    """returns a nationals gif matching the search query"""
    # await ctx.send(gifs.fuzzygif(' '.join(name)))
    await ctx.send(gifs.gif(' '.join(name)))
Example #4
0
async def gif(*name: str):
    """returns a nationals gif matching the search query"""
    # await bot.say(gifs.fuzzygif(' '.join(name)))
    await bot.say(gifs.gif(' '.join(name)))
Example #5
0
    # Funciones de busqueda
    prolog.assertz('conectado(Pos1,Pos2) :- conecta(Pos1,Pos2)')
    prolog.assertz('conectado(Pos1,Pos2) :- conecta(Pos2,Pos1)')
    prolog.assertz('miembro(X,[X|_])')
    prolog.assertz('miembro(X,[_|Y]) :- miembro(X,Y)')
    prolog.assertz('sol :- camino([inicio],Sol),write(Sol)')
    prolog.assertz('camino([fin|RestoDelCamino],[fin|RestoDelCamino])')
    prolog.assertz('camino([PosActual|RestoDelCamino],Sol) :- conectado(PosActual,PosSiguiente),\+ miembro(PosSiguiente,RestoDelCamino), camino([PosSiguiente,PosActual|RestoDelCamino],Sol)')
    
    # Realizar busqueda
    camino = []
    for inf in prolog.query("camino([inicio],Sol)"):
        for j in inf["Sol"]:
            camino += [j]
        break
    camino.reverse()
    camino[0] = "inicio"
    camino[-1] = "fin"
    return camino

camino = inicializar()
#camino = ['inicio', 2, 3, 4, 10, 16, 22, 21, 15, 14, 20, 26, 27, 28, 34, 33, 32, 'fin']
gi = gif(map)
gi.mover(camino)
root = tk.Tk()
lbl = ImageLabel(root)
lbl.pack(side="bottom", fill="both", expand="yes")
lbl.load('resources/movie.gif')
root.mainloop()