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
|
#!/usr/bin/python
# -*- coding: utf8 -*-
import irclib
import ircbot
from random import randrange
from math import *
CANAL = "#root-me_challenge" # Canal ou l'on veut la connection
enemy = "Candy"
res = 0.0
resOk = 0.0
class myBot(ircbot.SingleServerIRCBot):
def __init__(self):
ircbot.SingleServerIRCBot.__init__(self, [("irc.root-me.org", 6667)],
"bot_boubouf","Bot réalisé en Python avec ircbot")
def on_welcome(self, serv, ev): # A la connection au serveur
serv.join(CANAL)
serv.privmsg(CANAL, "Salut a tous, je vais vaincre Candy")
serv.privmsg(enemy,"!ep1")
def on_privmsg(self, serv, ev): # Quand le bot recoit un message en privé
message = ev.arguments()[0] # On recupére le message
print(message)
arguments = message.split(" / ") # Transformation du message en liste
nb1 = float(arguments[0]) #debut calcul
nb2 = float(arguments[1])
res = float(sqrt(nb1))
resOk = float(res*nb2) #fin calcul
resArr = round(resOk,2) #arrondir au centieme
print(resArr)
serv.privmsg(enemy,"!ep1 -rep",resArr) #<== voila mon probleme
if __name__ == "__main__":
myBot().start() |
Partager