commit: baad75f5978aa54cb8f733897559ba6e6c07775b
parent: f0496aa26084bace48f37aba272b504bf018262d
Author: lanodan <lanodan.delta@free.fr>
Date: Thu, 24 Jul 2014 22:05:40 +0200
Duh update
Diffstat:
4 files changed, 2 insertions(+), 215 deletions(-)
diff --git a/IRCBot/IRCBot.py b/IRCBot/IRCBot.py
@@ -1,130 +0,0 @@
-#!/usr/bin/env python
-
-__Author__ = "Haelwenn Monnier (lanodan) <haelwenn.monnier@gmail.com>"
-__License__ = "CC-BY-SA"
-
-import socket, sys, re, time, urllib, subprocess, ConfigParser, os
-
-tetris=0
-
-def get_element(dataInput, elem):
- idx1=dataInput.find('<'+elem+'>')
- idx2=dataInput.find('</'+elem+'>')
- return dataInput[idx1+len('<'+elem+'>'):idx2].strip()
-
-# Output to the channel and console
-def printIrc(ircout):
- irc.send('PRIVMSG '+channel+' :'+ircout+'\n')
- print 'PRIVMSG '+channel+' :'+ircout
-
-#line: append to the log (output it to the console too)
-def log(line):
- print '[LOG]'+line
- log = open('IRCBot.log', 'a')
- log.write(line+'\n')
- log.close()
-
-urlRegex = re.compile('[hf]t+ps?://')
-
-# Load the config file (config.ini)
-config = ConfigParser.ConfigParser()
-if (config.read('config.ini')):
- nick = config.get('Config', 'nick')
- passwd = config.get('Config', 'passwd')
- server = config.get('Config', 'server')
- port = config.get('Config', 'port')
- channel = config.get('Config', 'channel')
- quitMsg = config.get('Config', 'quitMessage')
- welcomeMsg = config.get('Config', 'welcomeMessage')
- source = config.get('Config', 'source')
-else:
- print '[ERROR] Couln\'d load config.ini. Example config file: config.ini.example. Exiting'
- sys.exit(1)
-
-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 '+ 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)
-
-# Make a while loop to alway parse input
-while 1:
- data=irc.recv(2048) # text is the socket input (I use text because input is already taken)
- text=data.lower() # text is the socket input (I use text because input is already taken)
- print data # print the input for debugging purpose
-
- # Below is a bunch of conditions to see if something the bot can deal with is found
-
- if text.find('ping') != -1:
- irc.send('PONG ' + text.split() [1] + '\n') # Return PONG back (sort of "I'm alive")
- if text.find(':!hi') !=-1:
- t = data.split(':!hi') # split the message received at the :!hi part
- to = t[1].strip() # take the string after !hi
- printIrc('Ohayo-nyan '+str(to)+' ! [http://i.imgur.com/vzYFOkp.jpg]') # Say something crazy
- #TODO: Custom !hi is the config
- if text.find(':!say') != -1:
- t = data.split(':!say')
- out = t[1].strip()
- printIrc(str(out))
- if text.find(':!action') != -1:
- t = data.split(':!action')
- out = t[1].strip()
- printIrc('\x01ACTION '+out+'\x01') # equivalent of /me
- if urlRegex.search(text) is not None: # Use httpRegex on input
- parse = re.findall('[HhFf][Tt]{1,2}[Pp][Ss]?://[^\{\}\|\\\^\~\[\]\"\'\`\(\)\<\>\ ]+', data) # parse URL
- try:
- url = str(parse[0]).rstrip() # Take the parsed link
- if (len(url) > 8) : # I assume a link is more than 8 characters long
- try:
- get = urllib.urlopen(url) # Open the link
- wget = get.read() # Read the input of the url
- print get.info() # Print Headers
- mimeType = get.info().type # Get the Content-Type
- get.close() # Close the connection
- # find the title
- if wget.find('<title>') != -1:
- title = get_element(wget, 'title')
- printIrc('Title: '+title)
- log(url+'; '+str(mimeType)+'; '+title)
- elif wget.find('<TITLE>') != -1:
- title = get_element(wget, 'TITLE')
- printIrc('Title: '+title)
- log(url+'; '+str(mimeType)+'; '+title)
- #If we can't find the title print the Content-Type
- else:
- printIrc('Type: '+mimeType)
- log(url+'; '+str(mimeType))
- except Exception, e:
- printIrc('Exception: '+str(e))
- else:
- printIrc('Link too short (not more than 8)')
- except Exception, e:
- printIrc('Exception: '+str(e))
- # Output the link to find the source code
- if text.find(':!source') != -1:
- printIrc(source)
- if text.find('kick '+channel+' '+nick) != -1:
- time.sleep(5)
- irc.send('JOIN '+ channel +'\n') #re-join the chan
- printIrc(welcomeMsg) # Say hello
- 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 the loop
- if text == "":
- irc.send('QUIT : Empty socket input\n')
- break # break the loop
-irc.close() # Close the socket
-sys.exit() # Exit
diff --git a/IRCBot/README.md b/IRCBot/README.md
@@ -1,75 +0,0 @@
-#IRCBot
-
-A simple IRCBot for only one channel. Works on all IRC servers.
-
-Commands
---------
-syntax ``[optional] <required>``
-
-``
-!action <text>
-``
-do some actions(same as the /me)
-
-``
-!hi [text]
-``
-Welcome users. (the bot doesn't welcome users on join yet)
-
-``
-!say <text>
-``
-say something
-
-``
-!source
-``
-Give a link to the sourcode
-
-``
-!stop in the name of sey
-``
-Stop the bot with a nice reference to SYRSA
-
-Configuration
--------------
-``
-nick=
-``
-nickname
-
-``
-passwd=
-``
-password. if you don't have any password do as you want.
-
-``
-server=
-``
-Server address (e.g ``server=irc.freenode.net``)
-
-``
-port=
-``
-Server Port (note: Most of the time it's ``port=6667``)
-
-``
-channel=
-``
-Channel, put one channel where you want to the bot to run.
-
-``
-quitMessage=
-``
-The message when the bot quits the server
-
-``
-welcomeMessage=
-``
-The message when the bot arrives in the channel
-
-``
-source=
-``
-The sourcecode of the bot (e.g ``source=My sourcecode is under CC-BY-SA and available at the following address:
-https://github.com/lanodan/scripts/tree/master/IRCBot``)
diff --git a/IRCBot/config.ini.example b/IRCBot/config.ini.example
@@ -1,8 +0,0 @@
-[Config]
-nick=feyris-nyannyan
-passwd=
-server=holmes.freenode.net
-port=6667
-channel=#kisune
-quitMessage=Sayonara-nyan !
-source=My sourcecode is under CC-BY-SA and available at the following address: https://github.com/lanodan/scripts/tree/master/IRCBot
diff --git a/screenshot b/screenshot
@@ -1,4 +1,4 @@
#!/bin/sh
-# FORMAT: YYYY-MM-DD-HH:MM:SS
-date=`date +%F-%H:%M:%S`
+# FORMAT: YYYY-MM-DDTHH:MM:SS+00:00 (ISO 8601)
+date=`date +%FT%H:%M:%S%:z`
import "/seagate/net/the-delta/datalove/img/screens/$date.png" && x-www-browser "http://the-delta.net/datalove/img/screens/$date.png"