Nestor

Mon petit bot Discord
Log | Files | Refs

commit 7865e10903e0dbdf27e5268f03f5006e47066409
parent 08c81f46cc26db5dfa54a0b5b4b45ba9df1d08ab
Author: Doshirae <doshirae@doshirae.fr>
Date:   Fri, 22 Dec 2017 16:43:28 +0100

.

Diffstat:
commandes.rb | 60+++++++++++++++++++++++++++++++++---------------------------
1 file changed, 33 insertions(+), 27 deletions(-)

diff --git a/commandes.rb b/commandes.rb @@ -2,40 +2,46 @@ require_relative "insultotron.rb" require "httparty" def random(*args) - if args[1] - max = args[1].to_i - min = args[0].to_i - elsif args[0] - max = args[0].to_i - min = 0 - else - max = 1.to_f - min = 0.to_f - end - rand(min..max) + if args[1] + max = args[1].to_i + min = args[0].to_i + elsif args[0] + max = args[0].to_i + min = 0 + else + max = 1.to_f + min = 0.to_f + end + rand(min..max) end def insulte(mode = nil) - "#{Insulte.new(mode)}" + "#{Insulte.new(mode)}" end def strawpoll(name, *choices) - if choices.empty? - return "Mais enfin ! Quelle curieuse idée de faire un sondage sans le moindre choix... On se croirait en Russie" - else - choices = choices.join(' ').split(' | ') - multi = false - if choices[0] =~ /q\s.*/ - question = choices.shift[2..-1] - elsif choices[0] =~ /qm\s.*/ - question = choices.shift[2..-1] - multi = true + if choices.empty? + return "Mais enfin ! Quelle curieuse idée de faire un sondage sans le moindre choix... On se croirait en Russie" + else + choices = choices.join(' ').split(' | ') + multi = false + if choices[0] =~ /q\s.*/ + question = choices.shift[2..-1] + elsif choices[0] =~ /qm\s.*/ + question = choices.shift[2..-1] + multi = true + end + question ||= "Poll de #{name}" + json = HTTParty.post("https://strawpoll.me/api/v2/polls", body: {title: "#{question}", options: choices, multi: multi}.to_json).body + id = JSON.parse(json)["id"] + return "Voici pour vous, mon cher\nhttps://strawpoll.me/#{id}" + end +end + +def doggo + File.open("doggo.png", 'w') do |file| + file.write HTTParty.get("https://www.randomdoggiegenerator.com/randomdoggie.php") end - question ||= "Poll de #{name}" - json = HTTParty.post("https://strawpoll.me/api/v2/polls", body: {title: "#{question}", options: choices, multi: multi}.to_json).body - id = JSON.parse(json)["id"] - return "Voici pour vous, mon cher\nhttps://strawpoll.me/#{id}" - end end