commit: a25b3a8adc477fec13340af58d23e37620bf7d0b
parent: a5a8483f18d86bac5654066f1f4416cd9581a8ae
Author: lanodan <haelwenn.monnier@gmail.com>
Date: Tue, 8 Jul 2014 23:47:26 +0200
Simplifications
Diffstat:
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/IRCBot/IRCBot.py b/IRCBot/IRCBot.py
@@ -30,7 +30,7 @@ userRegex = re.compile(':[\w\d]')
# Load the config file (config.ini)
config = ConfigParser.ConfigParser()
if (config.read('config.ini')):
- botnick = config.get('Config', 'nick')
+ nick = config.get('Config', 'nick')
passwd = config.get('Config', 'passwd')
server = config.get('Config', 'server')
port = config.get('Config', 'port')
@@ -45,8 +45,8 @@ else:
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #defines the socket
irc.connect((server, int(port))) #connects to the server
irc.send('PASS '+ passwd +'\n')
-irc.send('NICK '+ botnick +'\n')
-irc.send('USER '+ botnick +' irc bot :Bot made by lanodan using python!\n') #user authentication
+irc.send('NICK '+ nick +'\n')
+irc.send('USER '+ nick +' irc bot :Bot made by lanodan using python!\n') #user authentication
time.sleep(1)
irc.send('JOIN '+ channel +'\n')
printIrc(welcomeMsg)
@@ -106,28 +106,25 @@ while 1:
# Output the link to find the source code
if text.find(':!source') != -1:
printIrc(source)
- if text.find('KICK '+channel) != -1: #ISSUE: parse all kick in the channel
+ if text.find('KICK '+channel+' '+nick) != -1:
time.sleep(5)
irc.send('JOIN '+ channel +'\n') #re-join the chan
- time.sleep(1)
printIrc(welcomeMsg) # Say hello
- # rick roll the chan
- if text.find('tetris') != -1:
- if tetris != 1:
- printIrc('Never gonna give you up.')
- printIrc('Never gonna let you down.')
- time.sleep(1)
- printIrc('Never gonna run around and desert you.')
- printIrc('Never gonna make you cry.')
- time.sleep(1)
- printIrc('Never gonna say goodbye.')
- printIrc('Never gonna tell a lie and hurt you.')
- tetris=1 # Prevent another rick roll
+ if text.find('tetris') != -1 and tetris == 0:
+ printIrc('Never gonna give you up.')
+ printIrc('Never gonna let you down.')
+ time.sleep(1)
+ printIrc('Never gonna run around and desert you.')
+ printIrc('Never gonna make you cry.')
+ time.sleep(1)
+ printIrc('Never gonna say goodbye.')
+ printIrc('Never gonna tell a lie and hurt you.')
+ tetris=1 # Prevent another rick roll
if text.find(':!stop in the name of sey') != -1:
irc.send('QUIT : '+quitMsg+'\n')
- break
+ break # break the l∞p
if text == "":
irc.send('QUIT : Empty socket input\n')
- break
+ break # break the loop
irc.close() # Close the socket
sys.exit() # Exit