Commits

yohann Gabory  committed c30838d

code cleanup

  • Participants
  • Parent commits 627d28a

Comments (0)

Files changed (2)

                                         settings.BOT_NAME, "I'm a slave 4U")
 
     def on_welcome(self, serv, ev):
-        serv.join("#chezleo")
+        serv.join(settings.CHAN_NAME)
 
     def on_pubmsg(self, serv, ev):
         if settings.BOT_NAME in ev.arguments()[0]:
             if "photo" in ev.arguments()[0]:
                 pic = self.parse_ask("photo", ev.arguments()[0])
                 client.create_photo(
-                        "itschezleobitch", source=pic)
-                serv.privmsg("#chezleo", "Et voila : " + pic)
+                    settings.BLOG_NAME, source=pic)
+                serv.privmsg(settings.CHAN_NAME, "Et voila : " + pic)
 
             elif "vidéo" in ev.arguments()[0]:
                 video = self.parse_ask("vidéo", ev.arguments()[0])
                 if video.startswith("http"):
-                    client.create_video("itschezleobitch", embed=video)
-                serv.privmsg("#chezleo", "Et voila : " + video)
+                    client.create_video(settings.BLOG_NAME, embed=video)
+                serv.privmsg(settings.CHAN_NAME, "Et voila : " + video)
 
             else:
 
-                serv.privmsg("#chezleo", unicode(ia_bot.responding(ev.arguments()[0])))
+                serv.privmsg(
+                    settings.CHAN_NAME,
+                    unicode(ia_bot.responding(ev.arguments()[0])))
         response = self.parse(ev.arguments()[0])
         user = ev.source().split('!')[0]
         if response is not None:
-            serv.privmsg("#chezleo", response + " " + user)
-
-    def on_kick(self, serv, ev):
-        pass
+            serv.privmsg(settings.CHAN_NAME, response + " " + user)
 
     def is_image(self, response):
         """
         elif soup.find(id="small_embed_link") is not None:
             video = url
         if video is not None:
-            client.create_video("itschezleobitch", embed=video)
+            client.create_video(settings.BLOG_NAME, embed=video)
             return True
         else:
             print "No video in this link"
                 response = requests.get(url)
                 if self.is_image(response):
                     client.create_photo(
-                        "itschezleobitch", source=url)
+                        settings.BLOG_NAME, source=url)
                     return "Ok l'image est dans la boite"
                 elif self.is_video(response, url):
                     return "Hu Hu jolie video dis donc !"
-                # print "youtube" in url
-                # response = requests.get(url)
-                # print response.headers
-                # client.create_link("boblefrag", url=url)
 
 if __name__ == "__main__":
 
     IRCToTumblr().start()
-    # video = None
-    # url = "http://www.dailymotion.com"
-
-#    print response.content

File settings.py.dist

 AUTHORIZE_ENDPOINT = "http://www.tumblr.com/oauth/authorize"
 ACCESS_TOKEN_ENDPOINT = "http://www.tumblr.com/oauth/access_token"
 BLOG_ENDPOINT = "http://api.tumblr.com/v2/blog/<blog user>.tumblr.com/"
+BLOG_NAME = "blog name"
 OAUTH_TOKEN = "user token"
 OAUTH_TOKEN_SECRET = "user secret"
 BOT_NAME = "<bot name>"
+CHAN_NAME = "<chan_name>"