Nestor

Mon petit bot Discord
Log | Files | Refs

commit 8a1d9cf11f112b7d9c8f32a10fbcc411de03dca3
parent c0d80d35968b1f2155e1138dabf8c191d30aedf0
Author: Doshirae <doshirae@doshirae.fr>
Date:   Thu, 19 Apr 2018 11:54:57 +0200

XKCD: Added the link to the comic in the caption of the image, not in a
message before

Diffstat:
Nestor.rb | 7+++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/Nestor.rb b/Nestor.rb @@ -29,8 +29,6 @@ end # ping ==> bot.command :ping do |event| - # The `respond` method returns a `Message` object, which is stored in a variable `m`. The `edit` method is then called - # to edit the message with the time difference between when the event was received and after the message was sent. m = event.respond('Pong!') m.edit "Pong! `#{(Time.now - event.timestamp).round(2)}s`" end @@ -114,12 +112,12 @@ bot.command(:xkcd, description: "Renvoie une page XKCD") do |event, num| # "https://xkcd.com/#{num}" page = Nokogiri::HTML(open("https://xkcd.com/#{num}")) # TODO : Recuperer l'image sur le site, et l'upload sur le chat url = xkcd(num) - event.respond url - event.channel.send_file File.new('xkcd.png') + event.channel.send_file File.new('xkcd.png'), caption: url `rm xkcd.png` end # <== +# dl ==> bot.command(:dl) do |event, uri| require "net/http" if idx = uri =~ /jpe?g|png|gif$/ @@ -136,6 +134,7 @@ bot.command(:dl) do |event, uri| "Je ne peux pas poster un fichier qui ne soit pas une image, enfin !" end end +# <== # insulte ==> bot.command(:insulte, description: "Renvoie une insulte générée") do |event, action|