Merge branch 'develop' of github.com:ClouDev/CloudBot into develop

This commit is contained in:
Luke Rogers 2012-05-19 22:10:14 +12:00
commit c5e05c0063
3 changed files with 30 additions and 34 deletions

View file

@ -98,26 +98,26 @@ The developers of CloudBot run two CloudBots on [Espernet](http://esper.net).
They can both be found in [#CloudBot](irc://irc.esper.net/cloudbot "Connect via IRC to #CloudBot on irc.esper.net).
**mau5bot** is the stable bot, and runs on the latest release version of CloudBot. (mau5bot is running on **Ubuntu Server** *Oneric Ocelot/11.10* with **Python** *2.7.2*)
**mau5bot** is the semi-stable bot, and runs on the latest stable development version of CloudBot. (mau5bot is running on **Ubuntu Server** *Oneric Ocelot/11.10* with **Python** *2.7.2*)
**neerbot** is the unstable bot, and runs on the latest development² version of CloudBot. (neerbot is running on **Debian** *Wheezy/Testing* with **Python** *2.7.2*)
**neerbot** is the unstable bot, and runs on the latest(ish) development version of CloudBot. (neerbot is running on **Debian** *Wheezy/Testing* with **Python** *2.7.2*)
## Requirements
CloudBot runs on **Python** *2.7.x*. It is developed on **Debian** *Wheezy/Testing* and **Ubuntu** *11.10* with **Python** *2.7.2*.
It **requires Python modules** `lXML`, `BeautifulSoup`, `Enchant`, `psutil`, and `HTTPlib2`.
It **requires Python modules** `lXML`, `BeautifulSoup` and `Enchant`, `psutil`, and `HTTPlib2`.
The programs `screen` or `daemon` are recomended for the wrapper to run optimaly.
The programs `daemon` or `screen` are recomended for the wrapper to run optimaly.
**Windows** users: Windows compatibility with the wrapper and some plugins is **broken** (such as the ping), but we do intend to add it.³
**Windows** users: Windows compatibility with the wrapper and some plugins is **broken** (such as ping), but we do intend to add it.³
## License
CloudBot is **licensed** under the **GPL v3** license. The terms are as follows.
CloudBot/DEV
Copyright © 2011 ClouDev - <[cloudev.github.com](http://cloudev.github.com)>
Copyright © 2011-2012 Luke Rogers / ClouDev - <[cloudev.github.com](http://cloudev.github.com)>
CloudBot is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -134,8 +134,4 @@ CloudBot is **licensed** under the **GPL v3** license. The terms are as follows.
## Notes
¹ if you prefer to run the bot with a custom backend/run it manually, or are on **Windows**, run the bot with `./bot.py`
² or whatever version [neersighted](http://git.io/neersighted) is currently hacking on
³ eventually

View file

@ -15,7 +15,7 @@ def suggest(inp, inp_unstripped=''):
num, inp = m.groups()
num = int(num)
if num > 10:
return 'can only get first ten suggestions'
return 'I can only get the first ten suggestions.'
else:
num = 0
@ -23,10 +23,10 @@ def suggest(inp, inp_unstripped=''):
page_json = page.split('(', 1)[1][:-1]
suggestions = json.loads(page_json)[1]
if not suggestions:
return 'no suggestions found'
return 'No suggestions found.'
if num:
if len(suggestions) + 1 <= num:
return 'only got %d suggestions' % len(suggestions)
return 'I only got %d suggestions.' % len(suggestions)
out = suggestions[num - 1]
else:
out = random.choice(suggestions)

View file

@ -1,13 +1,13 @@
# written by Scaevolus, modified by Lukeroge
from util import hook, http
import random
import re
from time import strftime
from time import strptime
from time import strftime, strptime
from datetime import datetime
from util import hook
from util import http
from util import timesince
from util.timesince import timesince
def unescape_xml(string):
@ -47,8 +47,8 @@ def parseDateTime(s):
@hook.command
def twitter(inp):
"twitter <user>/<user> <n>/<id>/#<hashtag>/@<user> -- Gets last/<n>th "\
"tweet from <user>/gets tweet <id>/Gets random tweet with #<hashtag>/"\
"twitter <user>/<user> <n>/<id>/#<hashtag>/@<user> -- Gets last/<n>th " \
"tweet from <user>/gets tweet <id>/Gets random tweet with #<hashtag>/" \
"gets replied tweet from @<user>."
def add_reply(reply_name, reply_id):
@ -105,25 +105,25 @@ def twitter(inp):
url = 'http://search.twitter.com/search.atom?q=%23' + inp[1:]
searching_hashtag = True
else:
return 'error: invalid request'
return 'Error: Invalid request.'
try:
tweet = http.get_xml(url)
except http.HTTPError, e:
errors = {400: 'bad request (ratelimited?)',
401: 'tweet is private',
403: 'tweet is private',
404: 'invalid user/id',
500: 'twitter is broken',
502: 'twitter is down ("getting upgraded")',
503: 'twitter is overloaded (lol, RoR)'}
except http.HTTPError as e:
errors = {400: 'Bad request (ratelimited?)',
401: 'Tweet is private',
403: 'Tweet is private',
404: 'Invalid user/id',
500: 'Twitter is broken',
502: 'Twitter is down ("getting upgraded")',
503: 'Twitter is overloaded'}
if e.code == 404:
return 'error: invalid ' + ['username', 'tweet id'][getting_id]
if e.code in errors:
return 'error: ' + errors[e.code]
return 'error: unknown %s' % e.code
except http.URLError, e:
return 'error: timeout'
return 'Error: %s.' % errors[e.code]
return 'Unknown Error: %s' % e.code
except http.URLError as e:
return 'Error: Request timed out.'
if searching_hashtag:
ns = '{http://www.w3.org/2005/Atom}'
@ -153,7 +153,7 @@ def twitter(inp):
strptime(time.text,
'%a %b %d %H:%M:%S +0000 %Y'))
time_nice = timesince.timesince(parseDateTime(time_raw), datetime.utcnow())
time_nice = timesince(parseDateTime(time_raw), datetime.utcnow())
if tweet.find(retweeted_text) is not None:
text = 'RT @%s:' % tweet.find(retweeted_screen_name).text