summaryrefslogtreecommitdiffstats
path: root/rbjbbot.rb
blob: 05268cd59c3bf65279f18080db8af100c60168b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/ruby
require 'rubygems'
require 'xmpp4r'
require 'xmpp4r/muc/helper/simplemucclient'
include Jabber

############## Configuration du bot #################
                                                    #
mucjid   = ""    # JID du salon où connecter le bot #
mucpass  = ""    # Mot de passe du salon            #
botnick  = ""    # Pseudo du bot                    #
botjid   = ""    # JID du bot                       #
botpass  = ""    # Mot de passe du bot              #
                                                    #
#####################################################


begin

xmpp = Client.new(JID::new(botjid))
xmpp.connect
xmpp.auth(botpass)

muc = Jabber::MUC::SimpleMUCClient.new(xmpp)
muc.join(Jabber::JID.new(mucjid + '/' + botnick),mucpass)
  loop do
    muc.on_message { |time,nick,text|
        if nick != botnick
          case text
             when "!ping"
                msg = nick + ', pong.'
             when "!aide"
                msg = nick + ', commandes valides : "!ping", "!aide", "!kick" + pseudo à kicker.'
	     when "!kick moi"
		muc.kick nick, 'Tu me le demande si gentiment :D'
	     when /!kick+/
		nickkick = text.gsub(/!kick /, "")
		muc.kick nickkick, 'Demandé par ' + nick
             when /Xtn-RubyBot+/
                msg = nick + ', je ne te comprends pas, écris "!aide" pour avoir une liste des commandes valides.'
           end
           muc.say(msg)
        end
        }
    sleep 1
    end
end